LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

General Protection Fault

i have this error, "General Protection Fault occuring at 6849D436" and has occured on various system. Mainly win 98 and win NT. Currently i am using Labwindows/CVI v7.0.

this is the first time i'm using threads and not too sure if this is the main cause of the problem.

in the main thread, i call another thread to do certain tasks while flag is low, when user clicks on the stop button, the main thread will go to the stop callback and and set the flag too high and popup a msg saying program is terminated. after clicking on the ok button, the above error appears. the error appears more frequently in win98 then in win NT. (appears more often in debug mode)

During debugging, the popup msg seems to be the cause. Can the program be written as above?

thanks

Regards
AL
0 Kudos
Message 1 of 14
(4,872 Views)
i have attached a simple project which is almost a replicate of my project. i have also included the error message seen in the attachment.

To regenerate the error, try to switch execution between the debug .exe and release executable quite a few times. It's like kinda random. This is not so for my actual project as there are more files and source code. Seems to appears more frequently in win98 then in win NT.

Regards
AL
0 Kudos
Message 2 of 14
(4,870 Views)
I modified slightly your source. Please just tell me if it helps
0 Kudos
Message 3 of 14
(4,858 Views)
Hi the above error is also seen in windows XP but less frequent.
0 Kudos
Message 4 of 14
(4,834 Views)
Hi dilution,

Thanks for the replying.

So far it seems to have help but i'm not too sure coz using my simple project, i also had to try a few times before getting the error. I can't seem to find a pattern on how this error occurs.

Another thing, in my actual program, i actually do need to use the thread advance rather then calling a function after the message popup.

If there is really no solution to this problem, i guess i have no choice but to do that.

Regards
AL
0 Kudos
Message 5 of 14
(4,834 Views)
Dear AL,
The (small) concern I have with your code is that when you call the EndThreadFunction1 callback in the thread, you can not be sure that the thread still exists. See source attached to call the EndThreadFunction1 in the main thread.
Best regards,
0 Kudos
Message 6 of 14
(4,832 Views)
Dear Dilution,

yes i know i can call the EndThreadFunction1 in either the main thread or the execution thread. It's just that this simple project is to simulate my actual program.

Let me explain and see if i am going about the correct way for this multi-threading.

Originally in my program, i use

CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE, ExecutionThread, NULL, &ExeThreadID);
CmtWaitForThreadPoolFunctionCompletion (DEFAULT_THREAD_POOL_HANDLE, ExeThreadID, OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
CmtReleaseThreadPoolFunctionID (DEFAULT_THREAD_POOL_HANDLE, ExeThreadID);
"updates stuff"

after i press stop, i realise that it takes quite some time before the program actually reacts and the msg appeared.

Stop Callback ()
{
message popup ("Program Terminated")
do some other stuff //sets flags etc
}

So i thought maybe it has something to with RunUserInterface, so i change it to

CmtScheduleThreadPoolFunctionAdv (DEFAULT_THREAD_POOL_HANDLE, ExecutionThread, NULL, THREAD_PRIORITY_NORMAL, EndExeThread, EVENT_TP_THREAD_FUNCTION_END, NULL, CmtGetCurrentThreadID(), NULL));
// Where EndExeThread "Updates Stuff'

can't remember why i changed it later to RUN_IN_SCHEDULED_THREAD.....
By the way, if it is run in the main thread, which will be process first? the stop callback or the EndExeThread

After i did all this, when i execute the program on a win98 pc then the problem first occured.
This was developed on a winNT system.

By the way, on winNT, i notice that when i press the stop button in my program, it appears to take some time before i see a slow reaction in the stop button being depressed then the popup appears. But this is not so for the win98 or winxp system. Any ideas why?

Thanks

Regards
AL

Message Edited by AL on 05-11-2005 02:32 AM

0 Kudos
Message 7 of 14
(4,824 Views)
Dear AL,
1) Concerning the difference in behaviour between win98, winNT and winXP, I can't help you. That's really code ones debug everywhere, thanks to MS.
2) To me, it is clear that the first thing to be process is the stop callback. In your example, put Delay(10) instead of Delay(0.5) and move the popup panel with the mouse to see what happens to the main panel. More generally: if the stop callback calls the end of the thread (in your example: changes the gExiting value) the stop callback is always called before the end of thread function.
Regards,
Message 8 of 14
(4,819 Views)
Dear Dilution,

Thanks so much for your help.

i have reverted the whole program back to :

CmtScheduleThreadPoolFunction
CmtWaitForThreadPoolFunctionCompletion - OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
CmtReleaseThreadPoolFunctionID

But i still think that LabWindows maybe has some bug there creating the error to appear.

Anyway thank you once again. 😃

Cheers
AL
0 Kudos
Message 9 of 14
(4,793 Views)
Does anybody know why this problem occurs and what is it about??
0 Kudos
Message 10 of 14
(4,772 Views)