It seems that we grabbed the manpages for hcreate*(3) from NetBSD, but the actual implementation is patterned after Linux. In particular, .../contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c tests that text code from a non-existent item when action=FIND, but the value it tests it against is 1 (Linux -> non-zero -> error), not 0 (NetBSD -> zero -> error). I opened a bug for the non-intuitive behavior on NetBSD here: http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=51957 . The documentation should match the implementation, at bare minimum. Whether or not the implementation matches Linux or NetBSD is a point of debate.
A commit references this bug: Author: ngie Date: Tue Feb 7 02:57:12 UTC 2017 New revision: 313375 URL: https://svnweb.freebsd.org/changeset/base/313375 Log: Expect :hsearch_r_nonexistent to fail on FreeBSD The docs and the behavior mismatch; as noted in the bug, the behavior for hsearch_r matches Linux, whereas the docs seem to match NetBSD requirements wise. PR: 216872 Changes: projects/netbsd-tests-upstream-01-2017/contrib/netbsd-tests/lib/libc/stdlib/t_hsearch.c
(In reply to Ngie Cooper from comment #0) Some historical context as it seems to have been lost somehow: The original implementation of hsearch(3) for FreeBSD up to 10.x release, was indeed based on NetBSD. For the case of hsearch_r we adopted hsearch_r but the NetBSD code never made it into a release as ed@ wrote a new implementation in r292767. The implementation for hcreate(3) functions should match POSIX. hsearch_r(3) is a glibc extension.
For the following conditions Product: Base System, Documentation Status: New, Open, In Progress, UNCONFIRMED Assignee: Former FreeBSD committer Reset to default assignee. Reset status to "Open".