Jump to content
Perpeto

Is loading a resourcestring not threadsafe?

Recommended Posts

Hallo everyone,

I get access violations in my multi-threaded application, if it tries to read a resourcestring. I do not understand why or at least, why this is a problem. If I surround those calls with critical sections, everything is fine.

It gets an AV here:

image.png.928e5e6cd1adf72c941d3ca6d96a6d57.png

 

Thanks in advance!

Share this post


Link to post

Loading resource strings should be thread-safe. Issue probably happens because you are loading string resource to a shared string variable. Without seeing your code it is impossible to tell exactly.

Share this post


Link to post

I am loading resource strings from several threads and never had a problem. That doesn't mean it's ok to do so, but I never had anything while you make it sound like an AV is guarenteed to happen unless you surround it with critical sections. Can you create a reproducable sample?

Share this post


Link to post

Some time ago I had a similar problem with RESOURCESTRING, both in overwriting (with the VirtualProtect function) and with LOADRESSTRING in multithreading.
Since that time I have created a unit in which I perform all the functions of loading the resources and their eventual overwriting by calling it at the end of the initialization of all the other modules, and since then I have not had more problems. I mainly use the function for translation purposes.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×