[Xapian-tickets] [Xapian] #665: Avoid C library functions not guaranteed to be thread-safe

Xapian nobody at xapian.org
Sat Oct 26 21:38:33 BST 2019


#665: Avoid C library functions not guaranteed to be thread-safe
-------------------------+--------------------------
 Reporter:  olly         |             Owner:  olly
     Type:  defect       |            Status:  new
 Priority:  normal       |         Milestone:  1.4.x
Component:  Library API  |           Version:  1.3.2
 Severity:  normal       |        Resolution:
 Keywords:               |        Blocked By:
 Blocking:               |  Operating System:  All
-------------------------+--------------------------

Comment (by olly):

 `xapian-check-patch` already strips comment content so that shouldn't be
 an issue.

 I think the `#define inet_ntoa DO_NOT_USE_inet_ntoa` approach would (like
 the poison pragma) require something like `#include "poison.h"` to be
 included after any other header in every source which is part of the
 library.  But that's easy to fail to do (and easy for someone to merge
 that include into a block of others thinking it's out of place or add an
 include after it which might work on one platform but fail on another
 depending which system headers implicitly include others), so we'd really
 need `xapian-check-patch` to check it's suitably included where it should
 be.  Probably simpler to just check for a list of bad functions in
 `xapian-check-patch`.

 Another benefit of checking from a script is we can be a little more
 nuanced - e.g. `strerror()` is used in the library, but only as a fallback
 option if we don't have `strerror_r()` or `sys_errlist` or similar - with
 a script we can allow the use in `common/errno_to_string.cc`.

 Also the poison pragma is based only on identifiers, so e.g. would
 complain about a class with an `atoi()` method.  I'm not sure if any of
 the identifiers we would want to poison would be likely method names
 though.

--
Ticket URL: <https://trac.xapian.org/ticket/665#comment:16>
Xapian <https://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list