Know if a global var is inside mutex?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Caronte3D
Addict
Addict
Posts: 1048
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Know if a global var is inside mutex?

Post by Caronte3D »

Hi, I have a huge project (threaded) and it crash very rare times, but it does with a invalid memory error.
I think this can be caused while acceding to a global variable not locked with mutex.
Is there a way to know if a gloval variable is inside LockMutex-UnlockMutex pair?
Thanks in advance :wink:
P.D: The project is a DLL dependant of another app (not mine) and I can´t use (or don't know how) the purifier
User avatar
spikey
Enthusiast
Enthusiast
Posts: 586
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Know if a global var is inside mutex?

Post by spikey »

Not definitely, no. You could 'grep' lines containing the word 'Mutex'. Hopefully, reducing the number of lines you have to review and collecting them together will make reviewing for improper mutex handling slightly more easy. Something like this powershell command will output procedure start/ends and lock/unlock mutex lines. If you add in the name of your suspect variable as an alternate too then you will get output which should be relevant to your investigation rather than having to review the whole source.

Code: Select all

select-string -Path "*.pb" -Pattern "(Procedure|EndProcedure|LockMutex|UnlockMutex|MyVariable)"
User avatar
Caronte3D
Addict
Addict
Posts: 1048
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Know if a global var is inside mutex?

Post by Caronte3D »

Thanks I will take a look to this approach
Post Reply