-
Notifications
You must be signed in to change notification settings - Fork 865
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
Thrown bad_alloc unhandled during lazy allocation of an application durable thread local error object #915
Comments
As an extra idea for this one only, the new |
One more idea: the object that defines the memory allocation error can be introduced as a global variable and it will be pointed from the thread specific error description. It should be, of course, taken into account before trying to delete the associated object. |
With the changed definition of the thread local error (after merging C++11 sync stuff), the thread local error is no longer using reallocation, but overwrites the application-durable object with the new error specification. Throwing an exception is then prevented in the mentioned cases. There's one problem remaining, though: there's an uncaught new allocation done by lazy allocation done in the POSIX version of sync; this should be fixed (changing the description). |
UPDATE: With the new implementation of the "sync" stuff, the problem is likely gone. |
This fragment, repeated in every wrapper for an API function:
It actually catches an exception thrown by the system-default
new
operator. It is then likely that the next use ofnew
operator will throw this exception again. If this happens, this time anotherbad_alloc
exception will be thrown, and this time this exception isn't handled at all; it will simply make the application abnormally exit and do exactly the thing that this whole set of so loud function wrappers are designed to prevent - the exception will slip through the API layer, which contradicts the basic statement for the SRT API.The problem isn't easy to solve, as the error is written into the thread-specific data that are allocated dynamically. A nice proposal that probably could be easily implemented is:
bad_alloc
with simply deleting the dynamic data and set it to nullsetError
calls should only overwrite the existing error informationAlso, the memory allocation in
setError
should handle any errors fromnew
operator by itself, that is, set the thread-specific error data to null, regardless of what kind of error was about to be reported. Thebad_alloc
handlers, again, should only reset the error to null, as well as no explicit call tonew
operator should appear in any exception handler.The text was updated successfully, but these errors were encountered: