Compiler injected code and multi-thread safeness

Got a chance to read gynvael’s ( old article on multithread issue in dynamic initialization of static variable. You can read his article here Recently i was working in a project that uses Microsoft “Unified Event Model”. You can read about this here ( You can read my previous blog on how this __hook() and __event() is working behind the screen ( So what is the relation here ?

In both the cases we are talking about “compiler injected code”. In the first case we discussed about “compiler injected code” when we are dynamically initializing static variables. In the second case, we discussed about the underlying code to implement Microsoft “Unified Event Model”. If you closely audit the code injected by compiler then you will see the relation here.

Compiler injected code to implement Microsoft “Unified Event Model” is not thread safe ! Both the lock() and unlock() functions are just dummy.

The point is, in both the cases CL compiler injected code that is not thread safe. We should be auditing the codebase keeping this in mind.

Time for me to re-read “WYSINWYX: What You See Is Not What You eXecute” paper (

This entry was posted in C/C++, Windows VC++ and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s