<div dir="ltr"><div>Hi,</div><div><br></div><div>In the gdal rust bindings (<a href="https://github.com/georust/gdal" target="_blank">https://github.com/georust/gdal</a>), we're trying to facilitate the use of CPLSetErrorHandlerEx and related APIs.  While setting a handler, we may pass a heap allocated data pointer to the second argument, which is then read via the CPLGetErrorHandlerUserData in the handler and passed to the user.</div><div><br></div><div>However, while removing or setting another handler, we're unable to find a race-free method to get the associated user data of the previous handler.   This is needed to properly deallocate the memory.</div><div><br></div><div>Is there an atomic way to get both the previous handler (as returned by CPLSetErrorHandler), along with the associated user data?  The issue with making two calls, is that another thread might make changes in between the two calls.</div><div><br></div><div>We could synchronize in our API, but it still has the same issue if the user parallely used the C APIs directly or via a different interface.<br></div><br><div></div><div>Relevant PR in rust gdal bindings: <a href="https://github.com/georust/gdal/pull/215" target="_blank">https://github.com/georust/gdal/pull/215</a></div><div><br></div><div>-</div><div>Regards</div><br></div>