Incorrect pthread_t
definition on Darwin (should be a raw pointer, not an uintptr_t
)
#2903
Labels
breakage-candidate
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Milestone
This is a bug, but not one we can probably fix without breaking too much (it would break
std
's reexport ofpthread_t
). Aside from breaking code that treats it directly as an integer, it would meanpthread_t
would suddenly become!Send
and!Sync
, and I wouldn't be surprised if that's a problem for some.Anyway, on Darwin-based OSes,
pthread_t
should be a pointer, but is instead an integer. I noticed this when trying to passptr::null_mut()
into a function that Apple documents as having special behavior when passed aNULL
forpthread_t
.However, it's worth noting that the structure it points to is not opaque (at least not fully), and low level code on Darwin could potentially need to access it (at the moment this is likely not possible to do correctly on stable Rust, due to the lack of stable
"C-unwind"
). Specifically it has a list of functions that may be manipulated by code that wants to have cleanup functions run on thread cancellation. This list is directly manipulated by thepthread_cleanup_push
andpthread_cleanup_pop
function-style C macros, but this would be done directly by Rust code, which cannot use such macros. This is pretty niche, but is a case that's slightly relevant to rust-lang/rust#95496.The correct definition on Darwin would look more like:
I suppose it's fine for code that cares about this to maintain its own bindings, though.
The text was updated successfully, but these errors were encountered: