Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libc++ passes invalid values to pthread_equal #42263

Closed
mclow opened this issue Aug 7, 2019 · 3 comments
Closed

libc++ passes invalid values to pthread_equal #42263

mclow opened this issue Aug 7, 2019 · 3 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@mclow
Copy link
Contributor

mclow commented Aug 7, 2019

Bugzilla Link 42918
Resolution FIXED
Resolved on Aug 14, 2019 14:33
Version unspecified
OS FreeBSD
CC @emaste,@mclow

Extended Description

[ received from Ed Maste at FreeBSD ]

We just had a FreeBSD bug submitted for a failure arising from
libc++'s use of pthread_equal.

FreeBSD's pthread_equal stub implementation (used in non-threaded
programs) returns true unconditionally, since a non-threaded program
cannot have two different threads. However, std::thread::id defines a
special value that should not equal any real thread, and this is may
be passed to pthread_equal. See FreeBSD PR 239550 for more details,
and PR 239038 for the user-facing issue that prompted this.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239550
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239038

Now the most expedient fix is probably for us to make pthread_equal
somewhat less of a stub, but for correctness it seems
__libcpp_thread_id_equal would need to check for libc++'s special
value before calling pthread_equal.

@mclow
Copy link
Contributor Author

mclow commented Aug 7, 2019

assigned to @mclow

@mclow
Copy link
Contributor Author

mclow commented Aug 7, 2019

I've looked at this, and it seems like the best place to fix this is in __thread_id, which is where the "no thread == 0" is imposed.

However, the recursive_timed_mutex implementation doesn't use __thread_id, but instead goes right to the underlying type __libcpp_thread_id.

Also, we have no tests :-(

@mclow
Copy link
Contributor Author

mclow commented Aug 14, 2019

Fixed in revision 368916.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

No branches or pull requests

1 participant