Stack size for RUNINSTALL, RUNREMOVE programs

Context_log runs as a system application (calling iEikonEnv->SetSystem(ETrue)). This means that the installer can’t shut it down (which could be considered more a bug than a feature, but nevermind). Instead, we run a small program at installation and removal time that shuts it (as well as the watchdog process) down.

I wrote that shutter program and was happily using it for a couple of weeks on an N70 (2nd edition FP3) until the time came to test it on earlier phones, firstly on a 6600 (2nd edition, no FP). Here the shutter crashed with a KERN-EXEC 3.

After a bit of head-scratching – since my debug messages via RFileLogger never appeared anywhere – I realized the shutter was running out of stack. Which was weird, since I was specifying EPOCSTACKSIZE 16384 in my MMP file, and if I launched the same exe from FExplorer, it worked fine.

It looks like the earlier Nokia installers don’t respect the EPOCSTACKSIZE (they must be doing their own process launching code, since the normal RProcess::Create does respect that). So I had to pare down my stack usage.

I removed the debug code, moved objects to the heap, but still it was crashing with KERN-EXEC 3. After much debugging, I realized I’d left a TFullName on the stack, taking up some 500-odd bytes out of the 8k. In the end I had almost nothing on the stack – it does seem that either the installer launching code or some other platform code takes up most of that 8k…

In the process I also noticed that the installer itself leaks memory: it doesn’t close the handle it has on the processes it launches… and since the installer is actually most often embedded in the Messaging app, these handles (and the corresponding process objects) will stay around until you close the Messaging app – probably until the phone is rebooted.

This entry was posted in Symbian. Bookmark the permalink.

Comments are closed.