mailing list of musl libc
 help / color / mirror / code / Atom feed
* Bugs found while working on global thread list
@ 2019-02-15 18:38 Rich Felker
  2019-02-15 19:03 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Felker @ 2019-02-15 18:38 UTC (permalink / raw)
  To: musl

1. __dl_thread_cleanup, used to free the thread-local dlerror buffer,
calls free from a context where the thread is no longer in a
consistent state, which is invalid now what free may be defined by the
application. The simplest fix seems to be queuing the buffer to a
global list where it will be seen and freed by some future call to dl
functions; this precludes unbounded (memory leak) growth.

2. dlsym for RTLD_NEXT or RTLD_DEFAULT walks the symbol-defining DSOs
list without holding any lock on it, and the full DSOs list for
addr2dso lookup. This is intentional in some sense, to avoid heavy
overhead, but it seems incorrect and unsafe, as it can cause a
definition which is only temporarily-global (as part of an in-progress
dlopen with RTLD_LOCAL) or not-yet-committed (as part of an
in-progress dlopen that eventually fails) to spuriously return success
for a symbol that should be seen as undefined. I think this may be
salvagable with some atomic sentinels, but it's probably better
(simpler, clearly correct without complex reasoning) to just use a
rwlock. (This issue was found looking at whether dlsym would be a
place to perform deferred free of buffers for #1 above.)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bugs found while working on global thread list
  2019-02-15 18:38 Bugs found while working on global thread list Rich Felker
@ 2019-02-15 19:03 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2019-02-15 19:03 UTC (permalink / raw)
  To: musl

3. Not exactly a bug, but found looking at cruft/bloat in struct
pthread: the start function pointer and argument are reused in a
hackish way for timer threads. There are actually a lot of ugly hacks
in the whole way SIGEV_THREAD timers are implemented, that could be
eliminated by either waiting for the signal (rather than handling it)
or doing away with use of signals and kernel timers entirely for
SIGEV_THREAD, and instead implementing it all in userspace with
clock_nanosleep.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-15 19:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15 18:38 Bugs found while working on global thread list Rich Felker
2019-02-15 19:03 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).