LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

strncmp error

In that case, you probably have a memory-trashing bug to track down.  Refer to my post right above MVR's. A good way to track down this kind of bug is to create a watch expression for the trashed variables, then set the debugger to break when the value changes.  Specifically:

With the cursor on query_request, hit Ctrl+F7 to create a watch expression.
Select your new watch expression in the Watch window, and hit Enter to edit it.
Change the 'Variable/Expression' to query_request[0].
Check 'Break when value changes', select the proper scope of the variable and hit the Replace button.
Repeat the process, but leave the expression as query_request.

Now when you debug your program, it should break at the precise time either query_request or query_request[0] changes. Since both of these should be constant throughout your program's execution, the change should indicate a bug.

Let me know how it goes.

Mert A.
National Instruments
0 Kudos
Message 11 of 17
(1,560 Views)
Still trying to track down this error!  I have another related issue.  I have a for loop where the increment variable seems to go to far:

for(i=0; i<4; i++)
{

Assert (i<4);
//stuff
Assert(i<4);
Delay(.01);
Assert(i<4);
//stuff
}

It will assert intermittently but always on the 3rd assert.  Under the watch expressions debugging tool, it can break when the var changes, but I want it to break when i==4 or something other than 0-3.  But it wont allow me to do this right?  It says "Variables/Expressions" but when you put in a expression such as i==4.  It complains.  Anybody have any idea on how to find out who and where the t is getting stepped on.  I am running a multithreaded program, but no threads will be running during this, and I am not using i in any other thread anyway.  This piece of code is in a asynchonous timer function.  If i just try to step through the code the assert never happens. The memory debugging window seems to be unuseful  too.  Is there any documentation on how to use the memory/variables debugging tools that Labwindows gives you.  I can seem to find any documentation related to this stuff.  What is in the help stuff is pretty minimal.  Any help is appreciated.

Thanks
eddie
0 Kudos
Message 12 of 17
(1,493 Views)
It sounds again like you're trashing memory by writing beyond the bounds of some other variable.  You should be able to use the variable watch window to break exectution when the value changes.  For details, press the Help button on the Edit Watch Expression dialog.  If CVI is complaining about 'i' being undeclared, then you need to check the context (Scope, Executable, File, and Function) that is set for the watch expression.  For example, if you declared 'i' inside a function, then you need to set the Scope to 'Local' and make sure Function is set to the name of the function you declared it in.  If this is not your problem, then please follow up with more detail on "It complains."

The async timer callback is called in a separate thread from the thread that registered the callback, so though you say that no other threads are running at the time, I'm sure your main thread is running, and it may be responsible for the trashed memory.

Let me know what you find.

Mert A.
National Instruments
0 Kudos
Message 13 of 17
(1,490 Views)
Ok, thanks for your quick response by complains i mean:  If is put the Variable/Expression to say "if(t==4)" or "if(t=4)" or "if(t>3)" it complains and says:
Illegal Expression. 
Expression invalid in DLL/EXE: LTS_dbg.exe.

If i change it back to just "t" it is ok.  But it is unhelpful to just put in "t" and break when changes becuase t always changes due to the fact that it is part of the for loop.

Thanks
0 Kudos
Message 14 of 17
(1,490 Views)
Hi Eddie.

Try "t==4" or "t>3" instead of "if(t==4)" or "if(t>3)". Either of these expressions will evaluate to 0 (false) or 1 (true).

"if(t==4)" is not an expression.

I would not try to assign a value to "t" (as in "t=4") in your watch expression.

Regards,
Colin.
0 Kudos
Message 15 of 17
(1,482 Views)
Thanks, but those expressions don't work either.  It complains that those are Illegal Expressions as well.  I guess the Variable/Expression parameter really only means Variables!? 
More clues to my problems but no source of what the root of the problem is:  I have it to where if i break the code at a certain point and then step through the section of code where there is the for loop, I am able to see the increment value change as I go, but yet the variable has nothing to do with that piece of code. For example:

for(i=0; i<4; i++)
{

Assert (i<4);
//stuff
Assert(i<4);
a=1;
b=1;  //While stepping through this code i can see the i change through the variable watch.
...etc;

Delay(.01);
Assert(i<4);
//stuff
}


But I am trying to see who or what is changing the i, so this really isnt telling me anything new.  But I have tried commenting out all other code and still the problem persists. 

Also i get GPF errors every once in a while too (i assume the same root problem).  When the GPF problem happens it says " Unknown source position thread id 0x00000E88 (or some other id).  Now after this happens I go to Run-Threads I am able to see this thread but it says under the 'current function' column "Source not available".  So I am not able to View the thread info.  So my question is who/what/why/where is this thread from?  There are other Unknown sourced threads as well; where are these coming from?  I see the threads I create and then I see these other suspicious unkown threads.  Thanks


0 Kudos
Message 16 of 17
(1,478 Views)
I'm not sure why you would be able to use an expression like "i", but not "i==4".  What version of CVI are you using?  If you write and debug a simple program with just a for loop, do you still have problems with expressions like "i==4"?  In previous posts there were references to both 'i' and 't'; double check that your watch variable matches the one in your program.

One thing I would suggest is breaking into the debugger right after your second Assert statement and looking at any other threads that may be running.  Selecting Run>>Threads... brings up a dialog showing all live threads and lets you view what the other threads are doing.  This may help you find the problem.

Mert A.
National Instruments
0 Kudos
Message 17 of 17
(1,451 Views)