I swore POSIX forbid sharing some state between processes? What prevents structure serialization across process restart? @RichFelker ?
Yes. Only the original mutex object can be used. Copying it in any manner/using it as a value does not yield a usable mutex.
-
-
Agreed, I feel strongly that only explicitly initialized objects can be used, but I was looking for such wording in POSIX.
-
"If mutex does not refer to an initialized mutex object, the behavior of pthread_mutex_lock(), ... is undefined."
-
That is indeed sufficient to forbid such behaviour. If you consider initialization an action that is lost at process shutdown.
-
If nothing else it's lost by unreachability. The pthread_mutex_t object representation is not "the mutex" but repr's all you have
-
Right, and I think "2.9.9 Synchronization Object Copies and Alternative Mappings" would consider it an invalid alt map.
-
Yep, that's the text I was looking for but failed to find.
-
Thanks, your comments jogged my memory enough that I found the section. It's a pretty strong case for unsupported behaviour.
-
Whether glibc wants to support it as an extension is a valid question but per POSIX this is very clearly UB.
- 4 more replies
New conversation -
-
-
As some examples, the mutex may contain its own address, or it may contain no state at all with its addr just reg'd with kernel.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.