Simulator crashing when exiting a thread | developer.brewmp.com Simulator crashing when exiting a thread | developer.brewmp.com

Developer

Simulator crashing when exiting a thread

Forums:

Hi,
I have a question about exiting a thread, in my application I'm getting a crash when looping through creating and destroying a thread after a period.
The loop runs successfully a couple of times then the crash occurs.
Sequence;
Thread1: Create Thread2
Thread2: Check list for destroy
Thread1: Post Destroy Thread2
Thread2: Exit
Crash!!
First-chance exception at 0x00501d3e in BREW_Simulator.exe: 0xC0000005: Access violation writing location 0x00000010.
Unhandled exception at 0x00501d3e in BREW_Simulator.exe: 0xC0000005: Access violation writing location 0x00000010.
So I'm accessing and illegal address, but why only after a couple of iterations?

Does any specific clean up need to be carried out on exiting a thread?
Must I call IThread_Exit
Any suggestions as to why this might happening would help alot.

OK,
After some futher investigation, as a test I wanted to suspend the thread, before it exits, so I did the following,
pcb = ITHREAD_GetResumeCBK(pITme);
ISHELL_SetTimerEx(pIShell,dwMilliseconds,pcb);
ITHREAD_Suspend(pITme);
and i could see that on the first iteration, which is successful, the pcb list has only one element, on the second iteration it has two and the crash occurs in ITHREAD_Suspend.
Does this mean anything to anyone?

OK,
After some futher investigation, as a test I wanted to suspend the thread, before it exits, so I did the following,
pcb = ITHREAD_GetResumeCBK(pITme);
ISHELL_SetTimerEx(pIShell,dwMilliseconds,pcb);
ITHREAD_Suspend(pITme);
and i could see that on the first iteration, which is successful, the pcb list has only one element, on the second iteration it has two and the crash occurs in ITHREAD_Suspend.
Does this mean anything to anyone?

ronan wrote:OK,
After some futher investigation, as a test I wanted to suspend the thread, before it exits, so I did the following,
pcb = ITHREAD_GetResumeCBK(pITme);
ISHELL_SetTimerEx(pIShell,dwMilliseconds,pcb);
ITHREAD_Suspend(pITme);
and i could see that on the first iteration, which is successful, the pcb list has only one element, on the second iteration it has two and the crash occurs in ITHREAD_Suspend.
Does this mean anything to anyone?
It's far from clear what your application does without the code! Clearly it has a bug, and your debug output is only telling us what you think the application is doing, not what it's actually doing. You need to post at least the relevant bits of code from each thread, preferably cut down into a test application that still crashes.
At a minimum, add some debug to spit out the value of pITme, at every point where it is referenced. It looks like you're suspending the same thread twice.
Yes, you do need to call ITHREAD_Exit.

ronan wrote:OK,
After some futher investigation, as a test I wanted to suspend the thread, before it exits, so I did the following,
pcb = ITHREAD_GetResumeCBK(pITme);
ISHELL_SetTimerEx(pIShell,dwMilliseconds,pcb);
ITHREAD_Suspend(pITme);
and i could see that on the first iteration, which is successful, the pcb list has only one element, on the second iteration it has two and the crash occurs in ITHREAD_Suspend.
Does this mean anything to anyone?
It's far from clear what your application does without the code! Clearly it has a bug, and your debug output is only telling us what you think the application is doing, not what it's actually doing. You need to post at least the relevant bits of code from each thread, preferably cut down into a test application that still crashes.
At a minimum, add some debug to spit out the value of pITme, at every point where it is referenced. It looks like you're suspending the same thread twice.
Yes, you do need to call ITHREAD_Exit.

Thanks Ben,
The reason why I didn't post code was that the threads are 150 or so lines each,
with two mutexes and semaphores taken from the sample code with the sdk.
I try an reproduce the error with a stripped down version
Ronan

Thanks Ben,
The reason why I didn't post code was that the threads are 150 or so lines each,
with two mutexes and semaphores taken from the sample code with the sdk.
I try an reproduce the error with a stripped down version
Ronan

Hi Ben,
I got to the root of the problem, I was checking for an incorrect return code and consequently freeing memory that was being used elsewhere.
Thanks for the help.
Ronan
P.S.
Is IPV6 fully supported with the 3.1.4 release? I want to join a multicast group with SetSockOpt for IPV6, but the api doc has no reference for ipv6 only ipv4.
R

Hi Ben,
I got to the root of the problem, I was checking for an incorrect return code and consequently freeing memory that was being used elsewhere.
Thanks for the help.
Ronan
P.S.
Is IPV6 fully supported with the 3.1.4 release? I want to join a multicast group with SetSockOpt for IPV6, but the api doc has no reference for ipv6 only ipv4.
R

ronan wrote:Hi Ben,
I got to the root of the problem, I was checking for an incorrect return code and consequently freeing memory that was being used elsewhere.
Great.
ronan wrote:
P.S.
Is IPV6 fully supported with the 3.1.4 release? I want to join a multicast group with SetSockOpt for IPV6, but the api doc has no reference for ipv6 only ipv4.
R
No idea. If the ReleaseNotes don't help then I guess you need to ask someone at Qualcomm - maybe developer support.

ronan wrote:Hi Ben,
I got to the root of the problem, I was checking for an incorrect return code and consequently freeing memory that was being used elsewhere.
Great.
ronan wrote:
P.S.
Is IPV6 fully supported with the 3.1.4 release? I want to join a multicast group with SetSockOpt for IPV6, but the api doc has no reference for ipv6 only ipv4.
R
No idea. If the ReleaseNotes don't help then I guess you need to ask someone at Qualcomm - maybe developer support.