I've been trying to use the MemSetDebugMode with memDebugModeScrambleOnChange to pin down *my* bugs but I'm not sure the crash I see here is my doing.
When I run the program below on a real device (T|T or T3) or on a simulator with Palm OS lower than 5.3 (T|T, Z|71, T|C, T|T3, PalmSource 5.2 or PalmSource "dr12"), it crashes inside EvtGetEvent. But if I run it on PalmSource's 5.3 simulator, it runs ok.
If I add some SysTaskDelay calls around the EvtGetEvent call, it has a greater chance of success, so it seems to be some kind of thread race condition.
Sometimes I get a "NULL dbH passed" error, but more often the simulator crashes with a Windows crash. When I run it on a real device, it will sometimes require a hard reset since the device will start resetting itself when rebooting.
The first of my problems is of course that I can't debug using the very useful MemSetDebugMode call, but the more frightening thought is that the problem may indicate a serious bug in all pre OS 5.3 Palms.
Anybody know anything about this?
Also note that the app I'm developing (MMPlayer), makes very heavy use of the audio callback thread, so if there is a race condition between different threads, I'm sure MMPlayer will provoce it now and then.
Regards,
Magnus
-------------------------------------------- code ---------------------------------------- MemDebugTest.c ================== #include <PalmOS.h> #include <PalmTypes.h> #include "MemDebugTestRes.h"
UInt16 StartApp(void) { MemSetDebugMode(memDebugModeScrambleOnChange); FrmGotoForm(formID_Main);
return errNone; }
void StopApp()
{
FrmCloseAllForms();
MemSetDebugMode(0);
}static Boolean MainFormHandleEvent(EventPtr eventP)
{
Boolean handled = false;
FormType *form;
int status; switch (eventP->eType)
{
case frmOpenEvent:
form = FrmGetActiveForm();
FrmDrawForm (form);
handled = true;
break;
}return handled; }
static Boolean AppHandleEvent(EventType *event) { UInt16 formId; FormType *form;
if (event->eType == frmLoadEvent)
{
formId = event->data.frmLoad.formID;
form = FrmInitForm(formId);
FrmSetActiveForm(form); switch (formId)
{
case formID_Main:
FrmSetEventHandler(form, MainFormHandleEvent);
break;
}return true; }
return false; }
void EventLoop() { UInt16 error; EventType event;
do
{
WinDrawChars("GetEvent", 8, 0, 0);
//SysTaskDelay(10);
EvtGetEvent(&event, evtWaitForever);
WinDrawChars("GotEvent", 8, 0, 0);
//SysTaskDelay(10); if (!SysHandleEvent(&event))
if (!MenuHandleEvent((void*)0, &event, &error))
if (!AppHandleEvent(&event))
FrmDispatchEvent(&event);} while (event.eType != appStopEvent); }
UInt32 PilotMain(UInt16 cmd, void *cmdPBP, UInt16 lauchFlags)
{
UInt16 error; if (cmd==sysAppLaunchCmdNormalLaunch)
{
if (error=StartApp())
return error; EventLoop();
StopApp();
}return 0; }
MemDebugTestRes.h ================== #define formID_Main 1900
#define menuID_Main 1900
#define ctlID_Quit 1000
MemDebugTest.rcp ================== #include "MemDebugTestRes.h"
MENU ID menuID_Main
BEGIN
PULLDOWN "Help"
BEGIN
MENUITEM "Testing" AUTOID
END
ENDFORM ID formID_Main AT (0 0 160 160) USABLE MENUID menuID_Main BEGIN TITLE "MemDebugTest" END
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
