LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

No error in native code, stack overflow in DLL

In a DLL created with LabWindows/CVI a callback function associated with a 3rd party driver causes a Stack overflow error after some calls. It increases the stack size by 16bytes in each cycle when the callback is called.

When I use the same code as native C code, the function does not increase the stack size at all and my application runs just fine.Is there any known issue, that can cause this "feature"? (Calling convention, compiler settings etc.)

Increasing the stack size does not solve the problem, because the callback is called once in every ms.

 

best regards,

 

Peter

0 Kudos
Message 1 of 2
(2,871 Views)

It sounds like your callback function may be processing events.  Does the callback function in the driver call ProcessSystemEvents, ProcessTCPEvents, or something similar?  If so, it's possible that this call results in another call to the callback routine before the first one exits, eventually leading to a stack overflow.  A callback fuction being called once every millisecond is very fast on a windows machine, and could certainly lead to this situation if the callback function were processing events.

 

If you're able to debug the dll, you should let it briefly run and then break into it with the CVI debugger.  Then show the variables window and examine the stack frames - this should allow you to determine why things are stacking up.


NickB

National Instruments

0 Kudos
Message 2 of 2
(2,863 Views)