-
Notifications
You must be signed in to change notification settings - Fork 6
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
double free exception #55
Comments
The lines you refer to don't seem to exist in either 2.7.x or 2.8.0? udaClient.cpp looks like this
and the freeIdamErrorStack doesn't actually contain a free anymore, just assigns a nullptr.
Ideally I'd like to put the free back into the freeIdamErrorStack function to avoid memory leaks. Please could you instead test with this updated function in the freeIdamErrorStack function (and then only call this function in the udaClient) ? or provide me with a minimal example of the multithreaded client code which causes the fault you see so I can test? do I just need to make 2 uda requests in separate threads where the first call fails in order to reproduce?
|
yes you are right, sorry it is a commit we did on our side but actually it causes other issues. |
Managed to reproduce. For me I think adding these 2 lines in the udaLockThread function (client/accAPI.cpp:151) may work. I think that without this, the same (global) "server_block" structure is always used in udaClient.cpp for all threads. This change (or something similar) can ensure each thread-specific server_block from the idamState store gets used instead.
Let me know what you think. For info: This is the errorstack free function I tested it with.
|
i think it is more complex than that because we have public API which retrieves information directly from the server_block if retrieval of data failed. Some of them can be used directly in the user client library . All these methods need to be reviewed...
|
Do you mean you will need additional calls to udaLockThread/udaUnlockThread around all of your calls to these functions in a multi-threaded context? I think this is the way to ensure you access the correct server block in each thread |
yes even though honestly i'm not a big fan of having server_block a global variable |
With UDA 3.0 and the new C++ client, we should hopefully be able to review a lot of this code, as the client will encapsulate all state and the API functions will retrieve the state from the relevant thread local client. In this way the above API function would become something like:
|
ok it would be much better so are you suggesting to wait for 3.0 for the complete rework? when is it plan then? |
I agree: I'm not a fan of having any global state. This is the main improvement in the client2 and server2 implementations as well as some further work going on in v3.0 that Jonathan has mentioned. My initial feeling though is that for advanced use-cases such as multi-threaded client applications, handling thread locks can be the responsibility of the multithreaded application developer using e.g. manual calls to udaLockThread. (though we'll happily merge in any improvements into a 2.8.X release if you have work in-process that does something better) On the uda side we can improve documentation for this (for the existing client with all its global state) and otherwise just continue to work on enhanced concurrency support for release 3.0. We are planning to release version 3.0 by April. |
ok i think we will try to make some suggestions so that we can push a few things for 2.8.X |
we had to patch our uda server (both 2.7 and 2.8.0) due to a double free error
it happened when the client is multi-threaded and when some requests generate an error
for the fix we removed the lines (around 400 of client/udaClient.cpp).
the full stack shown by gdb
The text was updated successfully, but these errors were encountered: