3

I have an issue with a few Windows CE 5.0 devices which are crashing virtually as soon as they resume from standby (suspend). I have condensed the issue down to about 15 lines of C++ to simply get wxWidgets to display a message box, and the problem will hit if I:

  1. Start the app
  2. Suspend the device (by this I mean pressing the red power button briefly)
  3. Resume the device
  4. Pressing the OK button in the message box title.
  5. BOOM

This problem manifested itself in many other ways before I condensed it down - on loading a bitmap, on scanning a barcode, all once it has been suspended, then resumed.

I am using the following:

  1. Windows CE 5.0 Professional (Motorola MC3090 device) (also WM 6.5 (MC55), CE 6.0 (MC3190))
  2. Visual Studio 2005 SP2
  3. wxWidgets 2.8.10
  4. Microsoft Windows CE 5.0 Standard SDK

The actual error that is displayed is sporadic and wide ranging, but mostly an access violation, typically near the start address of a function call (discovered this by suspending the device, resuming then attaching VS debugger on the device). Having done extensive homework on this, I've read some suggestions it may be some kind of heap corruption occurring. As long as the app doesn't suspend, it always works correctly across all correct combinations of SDKs and devices.

I have also tried the following SDKs:

  1. MS Pocket PC 2003 SDK
  2. Symbol Platform SDK for MC3000c50a
  3. Symbol Platform SDK for MC3000c50b
  4. Windows Mobile 5.0 SDK
  5. Windows Mobile 6.0 SDK

I have tested the following devices:

  1. MC3090 (Windows CE 5.0) - Same Problem
  2. MC55 (Windows Mobile 6.5) - Same Problem
  3. MC3190 (Windows CE 6.0) - Problem does not occur on this device with StandardSDK build

I have played excessively with the setup of wxWidgets, always making sure that I link the app with the correct corresponding SDK.

Here is the code that causes this problem:

#include "wx/wxprec.h"
class Application : public wxApp {
public:
    virtual bool OnInit();
};

bool Application::OnInit() {
    wxMessageBox(L"Test");
    return true;
}

IMPLEMENT_APP(Application)

Anyone with some advice out there, I would be eternally grateful! Please also let me know if I have left out any important details.

1 Answers1

2

Are you running the application from an SD card? The MC3090, at least, and I think also the MC55, conform by default to the Windows CE standard for add-on buses (defined originally for PCMCIA cards): that when you suspend and resume the device, all buses are reset. This causes the card to momentarily disappear, and all handles to files opened on the card to be invalidated. This is actually so that the device can deal with the user changing the card while the device is suspended.

Windows CE is a demand-paged operating system. Your program is not all loaded into RAM when started: instead, pages are only loaded from the executable and DLLs as they are referenced by the program. Any read-only or unmodified pages can be discarded by the OS at any time, because it can re-read them from the original program file (this is why your program file can't be overwritten if the program is running). If the handle to the EXE or DLL is invalidated, and you reference a page that hasn't been loaded (or has been discarded), the OS page fault handler can't read the page and it generates an Access Violation exception.

For the MC3090, you can configure the SD card driver not to 'remove' the card on resuming from sleep. See Symbol's KB article MC30xx CE5.0 - Application aborting randomly when using SD Card for details. I can't find details of how to do this on the MC55. On the MC70, there was an 'SDSwitch' applet in the System control panel, whose main function was to switch between memory card and SDIO mode, but which also had a checkbox to control this option. Some other devices have had a 'sealed SD slot' CAB file in the \Windows folder - I seem to recall this on the MC65 or ES400.

Mike Dimmick
  • 9,662
  • 2
  • 23
  • 48