> LabView crashes exactly at the moment of exiting from sub VI. If I set
> "Suspend when called" property for this sub VI, no crash occures. If I
> toggle off "deallocate memory as soon as possible" from the preferences,
> then the crash will occur only when the window is closed. In the latter
> configuration, the program will run repeatedly without crashing as long as
> the window is not closed. Any ideas?
>
> I have LabVIEW 5.1.1
> The offending subVI contains only a few simple icons and 2 subsubVI's with
> simple icons (array size(s), case structure, logic operators) and a Call
> Library Function calling C code from a dll. The C code runs alone quite
> nicely, and those subsubVI's don't crash.
>
I've seen this numerous times. If thi
s were Las Vegas, I'd give you
odds of about 500 to 1 that it is the C code. The C code is writing
past the end of a string or array, and corrupting other data in the VI.
It is pretty common for the corruption to go unnoticed until LV tears
down the data of the VI and tries to access what was once a pointer or
handle and now has data written on it.
If the strings are being resized as handles from within the C code, then
make sure the size is big enough to hold the data and the four byte size
in the front. Also make sure to write the size into the string.
If the C code is just writing into the buffer, and the diagram is sizing
the string in advance, make the values a bit larger. If the C code
assumes that it has 2200 bytes and you only allocate 2100, then nothing
bad happens on calls that only write 1000 bytes or 2000 bytes. But when
the C code writes a full amount of data, the extra hundred bytes just
corrupted other data in the VI.
These are the two most common bu
gs with C code incorporated into a LV VI.
Greg McKaskle