LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

General Protection Fault related to event handling

edit: Sorry about this formatting. The NI board is refusing to load correct on any device I use. I can't clean this up at all... So this one is probably impossible to debug since I can't share the code that's relevant, but I'd still like to get some other opinions on the situation. From what I can tell, CVI's UI queues events sequentially. Pressing a button 3 times will generate 3 back-to-back calls to the control's callback. I created a test project that confirms this. A simple button that calls "Delay(1)" with a printout to a Text Box behaves this way. The button can be spammed a 12 times and 12 print statements will appear, one at a time, over the course of 12 Delay cycles. Now for the weird behavior. We have a few applications/libraries internally. One of these libraries seems to 'break' the behavior above. Adding a new button to my test project, instead of calling Delay directly, I call one of our library functions. The library function I call will eventually perform the same action, it will Delay(1) and return. However, the UI behavior is different - if I spam the button 12 times, all sorts of undefined behavior occurs. Sometimes the print statement occurs, but never all, usually only 1. However, the events themselves are still being queued. If I continue to spam the button, I get a General Protection Fault at an address well outside of my main program's address space. Now to lay out how our programs are actually running, it's something akin to this: [Main Program] [Instrument Server] (LaunchExecutableEx) [User Program] (Invoked from Main Program) [Library Calls] (TCP Write/Read to Instrument Server) My original theory was that somewhere in the call stack for the library was a call to ProcessSystemEvents(), which would cause the User Program events to run earlier. Since they should only be executed serially, this would definitely cause issues. However, reading through the source code of all the Library Calls, I don't see any references to ProcessSystemEvents(). Trying to isolate where this might be coming from, I tried using a thread pool to separate the execution of various pieces from each other. If I run the [User Program] in a thread, the issue still exists. If I run the [Library Calls] in a thread, they still exist. However - running BOTH in separate threads seems to stop the issue and the 'expected' behavior seen. Now I know that not being able to see source code for this greatly hinders any concrete help. But what I'm really looking for is ideas and information that might be missing. Maybe a CVI call invokes ProcessSystemEvents and I can't see that source, or maybe there is an assumption somewhere we've gotten wrong.
0 Kudos
Message 1 of 2
(870 Views)
My first guess after reading 'I call one of our library functions' would be a calling convention mismatch.
-----------------------
/* Nothing past this point should fail if the code is working as intended */
Message 2 of 2
(814 Views)