jcferretti commented on PR #41927: URL: https://github.com/apache/arrow/pull/41927#issuecomment-2145266611
> That said, this doesn't seem like a guaranteed fix. https://stackoverflow.com/a/47117985/262727 > > Mutating the shared_ptr while another thread is copying it is still thread-unsafe I believe that is incorrect. I believe you are applying the context for that stack overflow answer wrong here. The `shared_ptr` ensures the integrity of the count and its /own/ state. The shared_ptr does not ensure that accessing the pointer payload or /its/ operations are done in a thread safe manner. Here we need the first, not the second. When a call to `FlightClient.authenticate` ends up replacing the `auth_handler_` data member while SetToken is executing, the end result is that the shared_ptr in SetToken has its count reduced, atomically and consistently, and the `auth_handler_` data member shared_ptr is replaced with a new object. I believe your concern would be valid if our problem was preventing concurrent access to the object pointed to; it is not. I completely agree that the documentation should be improved here; had it been improved after the first time this issue was reported, that would have saved my team a considerable amount of effort debugging. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
