Page MenuHomeFreeBSD

__cxa_thread_call_dtors(3): fix dtor pointer validity check
ClosedPublic

Authored by kib on Fri, May 3, 9:38 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 5, 8:48 PM
Unknown Object (File)
Sat, May 4, 5:03 AM
Unknown Object (File)
Sat, May 4, 2:57 AM
Restricted File
Fri, May 3, 11:00 AM
Subscribers

Details

Summary
When checking for the destructor pointer belonging to some still
loaded dso, do not limit the possible dso to the one instantiated the
destructor. For instance, dso could set up the dtr pointer to a function
from libcxx.

PR:     278701

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Fri, May 3, 9:38 AM

Does the cxa_thread_dtor::dso field serve any function after this change? I couldn't see any other references to it.

In D45074#1027845, @dim wrote:

Does the cxa_thread_dtor::dso field serve any function after this change? I couldn't see any other references to it.

It is unused indeed. I looked at the glibc code, they use it to deref the dso after dtr call, but then it would have the same issue. Musl seems to not have the cxa_* stuff at all.

I can remove the member, but prefer to keep it for now (not a rational decision).

I confirm that this change silences the message from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278701 and also that the destructor is actually being called.

Further as mentioned above by @dim the dso member is no longer used and can be removed together with the arguments of some functions, see the attached patch.{F82874513}

Thank you!

In D45074#1027873, @kib wrote:
In D45074#1027845, @dim wrote:

Does the cxa_thread_dtor::dso field serve any function after this change? I couldn't see any other references to it.

It is unused indeed. I looked at the glibc code, they use it to deref the dso after dtr call, but then it would have the same issue. Musl seems to not have the cxa_* stuff at all.

Yeah musl doesn't implement unloading DSOs altogether, avoiding a huge can of worms! That's apparently POSIX-compliant...

I can remove the member, but prefer to keep it for now (not a rational decision).

Oh it's fine, it might be handy for other things later, possibly in debug output or such.

This revision is now accepted and ready to land.Fri, May 3, 11:18 AM