Page MenuHomeFreeBSD

Add pthread_getname_np() and pthread_setname_np() aliases for pthread_get_name_np() and pthread_set_name_np().
ClosedPublic

Authored by kib on Jun 3 2020, 3:51 PM.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kib requested review of this revision.Jun 3 2020, 3:51 PM

Thanks, I started doing this too but you are faster.

lib/libthr/pthread.map
250 ↗(On Diff #72616)

_pthread_get_name_np is not in the private namespace. Should it be there? Should we also provide non-weak _pthread_(get|set)name_np symbols?

share/man/man3/pthread_set_name_np.3
82 ↗(On Diff #72616)

The new functions should be mentioned here too. It might be useful to note that getname/setname are "more" compatible with other OS'.

share/man/man3/Makefile
497 ↗(On Diff #72616)

Missing backslash.

kib marked 2 inline comments as done.Jun 3 2020, 4:59 PM
kib added inline comments.
lib/libthr/pthread.map
250 ↗(On Diff #72616)

I do not think we should export anything from the private namespace until there are users of it in the base system.

Also we prefer to export non-ANSI-C symbols as weak (but this is not a hard rule). Our weak symbols have a semantic beyond what is required by ELF standard, rtld prefers non-weak over weak regardless of the lookup order.

Fix Makefile.
Update man page portability section.

This revision is now accepted and ready to land.Jun 3 2020, 5:11 PM
kib updated this revision to Diff 72659.

Make functions more compatible with Linux:
return errors
put declarations into pthread.h undef BSD_VISIBLE.

lib/libthr/thread/thr_info.c
50 ↗(On Diff #72659)

Duplicate. Typo?

include/pthread.h
306 ↗(On Diff #72659)

The indentation is inconsistent.

lib/libthr/thread/thr_info.c
83 ↗(On Diff #72659)

This can fail with ENOMEM.

yuripv added inline comments.
share/man/man3/pthread_set_name_np.3
53 ↗(On Diff #72659)

apply

62 ↗(On Diff #72659)

retrieve

85 ↗(On Diff #72659)

Insert .Pp after .El to make this more readable.

kib marked 3 inline comments as done.Jun 4 2020, 5:18 PM
kib added inline comments.
lib/libthr/thread/thr_info.c
83 ↗(On Diff #72659)

I know it, I do not consider the case important, syscall would fail anyway for too long string, and this is the only case that really matters.

But I fixed it anyway.

kib marked 4 inline comments as done.

Fix exports aliases.
Handle NULL from strdup().
Minor man page/style etc issues.

This revision is now accepted and ready to land.Jun 4 2020, 7:53 PM

Some Haskell ports are now failing with

ld-elf.so.1: /usr/local/bin/cabal: Undefined symbol "pthread_setname_np@FBSD_1.6"

Full log here: http://beefy18.nyi.freebsd.org/data/head-amd64-default/p538068_s361855/logs/hs-threadscope-0.2.12.log

Don't tell me this is another breaking change that would require us to have another flavor of bootstrap compiler.

Some Haskell ports are now failing with

ld-elf.so.1: /usr/local/bin/cabal: Undefined symbol "pthread_setname_np@FBSD_1.6"

Full log here: http://beefy18.nyi.freebsd.org/data/head-amd64-default/p538068_s361855/logs/hs-threadscope-0.2.12.log

Don't tell me this is another breaking change that would require us to have another flavor of bootstrap compiler.

I do not know what exactly happens there, but the message itself means that the binary was built against newer libthr that exports the symbol, but then you tried to activate the binary with libthr that is older and does not export the symbol. We do support backward compatibility, where you can run binary against newer library than it was built against, but not older (that would be forward compatibility, unfortunately we still cannot see the future).