LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Variable not active

I seem to have a dynamic memory problem within an application I am working on at the moment.

Unfortunately I cannot look at the variables because CVI claims them to be "not active".

I have looked into several places what this means, but I did not even find a hint on this term. Anyone can help me and explain what this term tells me?

Thanx.
0 Kudos
Message 1 of 15
(4,651 Views)
I suspect that you are trying to look at variables that have been set up in a watch window...

The not active indicates that the variable exists in a thread that is not currently active.
You can set it such that the program halts when the variable changes value.

If you are not looking at these in the watch, then I am barking up the wrong tree, and it should be I that be labled as not active.

Chris
Message 2 of 15
(4,647 Views)
Since I did not create any additional threads...
I specify what I am trying to find out.

Actually my application causes a General Protection Fault and stops there. Unfortunately I am not able to predict under which conditions exactly it crashes, so it would be nice to see the last values of the variables/pointers.

Most local variables are visible. But the global ones are not. Oh well, I will try to conserve the global values in that fun with locals. Wonder whether that helps. But the problem/question is still valid anyway.
0 Kudos
Message 3 of 15
(4,650 Views)
Most GPF's are caused by making reference to pointers that are no longer valid or not owned by the calling process, which may or may not bear some resemblance to your problem of not being able to view a Global.

Since the GPF has occurred, the Debugger may have already released references to your variables, hence it is not active any more.

For example:

1. Load an external module (say TCP / IP or similar)
2. a = Ptr to some external function within that external module.
3. Use the function pointed to by a.
4. Release the external module.
5. Use the function pointed to by a.

Step 5 will cause the GPF since it will be trying to access memory outside of the scope of your application. The module that was loaded existed within its own memory space, and 'a' merely contained a reference to it. Since the GPF has occurred, you cannot see what 'a' contains, since it is no longer active (halted by the GPF).

Now, it may not be apparent straight away by looking at the GPF, and it may or may not be related to an external module.

I used TCP as an example, since it is pretty easy to simulate the same fault as you are showing. For example, if I open a TCP session, CVI will use an external library call (one of the Windows DLL's), to handle the TCP calls at a lower level. One of the functions allows me to register a callback function within my code, which gets called by the windows DLL upon certain conditions (such as data ready?). If I close my code without telling the external process, or my code terminates abnormally for some reason, when the trigger event occurs that will call the registered callback function, it will cause a GPF within that module, since it will be accessing memory not valid anymore.

There are many what seem harmless function calls within CVI that will cause an external module to be loaded, (such as VISA, or GPIB, or TCP). Race conditions can occur during the loading unloading of these, which can also create GPF�s.

Also, just a plain old bad memory reference ptr can cause the same.

Ptr = malloc (lots of space)

Causes a ptr to memory within the memory space of the executable that created it, or, it belongs to the executable (controlled by windows).

Setting Ptr = NULL, and using that Ptr will in some cases be trapped and return a known error. But bad ptr arithmetic for example, will still be a valid reference in terms of memory, but could cause GPF�s if that memory is protected or not owned by the process that tried to access it�

There are tools around that will allow you to see what process is using what memory areas. So when the GPF occurs, you can see what process was using that memory location. You can then verify whether its within your code, or in an external module (called previously by your code).

This is a question I should have asked before typing the above, but what sort of GPF is it ? And what error message do you get?

So basically, its either a bad ptr or a bad function call, and those are where I would look first.

I will have a look for the names of those debug applications if that will be of any help to you.

Regards

Chris
0 Kudos
Message 10 of 15
(4,656 Views)
Route66 schrieb:

> I seem to have a dynamic memory problem within an application I am
> working on at the moment.
>
> Unfortunately I cannot look at the variables because CVI claims them
> to be "not active".
>
> I have looked into several places what this means, but I did not even
> find a hint on this term. Anyone can help me and explain what this
> term tells me?
>
> Thanx.

You are able to look at variables which are used in a certain *.c or
where they are included with *.h files or with EXTERN.
The *.c where the variable is defined has to be included as such to the
project.If you use this file in the compiled way (marked as compile to
object) this does not work, and that is where I got this error message.

Best Regards
Urs
0 Kudos
Message 4 of 15
(4,652 Views)
I have had the same problem as 'Route66'. At a breakpoint in a certain file, I try to look at a global variable (struct), which is linked via an extern declaration. The file in which the variable is defined is included in the project. In the "Variables" window, the variable is listed as "Not active" in the column where a value should be. The variable is still accessible by the program, it's just not displayed in the Variables window while debugging. This condition is not consistent for me, though it may be for Route66. So for me, it appears to be a problem with the debugger, not the compiler.
0 Kudos
Message 5 of 15
(4,656 Views)
Something else to consider is if the variable exists within a seperate thread to the main execution thread of your program. (Say for example within a CallBack ?).
The variable will still be displayed within the debug window, but marked as "Not Active" when the thread is not executing. Only by setting the "Break on Value change" will you see the variable contents, or by placing a breakpoint in the same thread.

By setting the "Break on Value Change" you will confirm whether or not the debugger has access to the variable, or if indeed it is a problem.

Hope this helps,

Chris
0 Kudos
Message 6 of 15
(4,656 Views)
Excuse the double answer... Thats what happens when you take 3 weeks vacation at Christmas, come back, see the original post and send a reply without reading why I got the message in the first place. At least I said the same in the second reply as I did in the first... That would have been embarressing... Sorry for the double answer... I think I need more vacation 😞

Chris
0 Kudos
Message 7 of 15
(4,656 Views)
Actually your second reply included a little detail I missed the first time. So I am happy you answered a second time. Thank you 🙂
0 Kudos
Message 8 of 15
(4,654 Views)
Today when I was trying to debug, I was watching a certain global variable in the Variables window. It was "Active" in one function, but then in a function that one called, it was "Not active". When it returned to the first function, it was still "Not active". Both functions are in the same source file, which also happens to be the file the global variable is defined in. While neither function are Callbacks, the first is called by a function called by a function called by a callback. I do not explicitly use threads so how do I know if they're in separate threads?
0 Kudos
Message 9 of 15
(4,654 Views)