none
Very wierd application error, Need to know how to debug multi threaded application efficiently. RRS feed

  • Question

  • Hi All,

    I am working on quite huge application(Sorry, I cannot mention it's name) which consist of may DLL's some in C++ 11 and some in C# with x64 architecture (VS2012) and now I have come across a very weird issue.

    1) The problem is that it runs smoothly on dev machine, whereas it gives user defined error(i.e. variable "XXX" is null) on VM. Please note both VM and dev machine have Win7-Sp1 OS.

    2) When I install WinDbg on VM and run that application with the help of win debugger it runs smoothly; whereas while application is running If I simply detach debugger, And perform same steps it gives error once again.

    3) I have found out a possible problem area, but don't know why it happens like that.

        a) There is a function (Say "A", Which executes very first) in which I am trying to log message, If I comment this line then application runs smoothly. else If LogMessage() is present I get error somewhere far ahead (In another function say "B") in my code. And this goes in cycle for all the items in list.(first A then B, again A then B, and so on.)

    Kindly note that function (A) executes nicely even with or without LogMessage() but error occur in function (B) if LogMessage() is present in function (A).

        b) In another function (say "C"), I initialize variable "XXX" = null on very first line and then assign it some value below in the function. If I remove initialization part, App runs smoothly.

    4) So, I suspect there is some threading issue; since, function "A" access null value of "XXX" while function "C" is in process to set it back. But how can I confirm it is threading issue all together, Since I just suspect it to be ?

    5) Is there a way to know which thread is accessing variable "XXX" at particular point of time ? (Say by putting function "C" in critical section can I get the details of thread who is trying to access it.)

    Any help would be really appreciated.

    Thanks and Regards

    AhmerSH

    Friday, August 30, 2013 10:46 AM

All replies

  • Hi AhmerSH,

    Your problem description was very generic and it is difficult to think what was going on.

    Assuming that it is a multithreaded application, please go through the below links, which provide overview on how to debug Multithreaded application in VS 2012.

    http://msdn.microsoft.com/en-us/library/vstudio/ms164746.aspx 

    http://msdn.microsoft.com/en-us/library/vstudio/bb157784.aspx ( C++ ) 

    http://msdn.microsoft.com/en-us/library/vstudio/hh368280.aspx ( C++ AMP GPU debugging)

    regards,

    Pavan

    Friday, August 30, 2013 7:26 PM
  • Hi Pavan

    Thanks for the reply, And much appreciate your suggestion.

    First of all, My apologies for being so generic in problem description but I could not reveal details as it is companies project.

    Secondly, This problem is so weird that it does not allow me to debug itself.

    To be more specific

    When I run application on VM I get error. Now, In same running instance when I attach debugger it does not reproduce and as soon as I detach debugger it reproduces again.

    I guess this could be due to two reasons

    1. Some garbage values/uninitialized variables, which is taken care by debugger when it runs under its control

    2. Or Some sort of timing issue, as in controlled environment application tends to run slow, making a room out for race condition.

    Correct me if I am in wrong direction.

    To overcome these problem I am forcing application to crash by intentionally introducing (divide by zero) error in problem function. And trying to use postmortem debugging technique, But no luck till now.

    Any suggestion would be helpful.

    Regards

    Ahmer

    Monday, September 2, 2013 1:30 PM