I very much doubt the L vs Lt thing is the cause, but then again, I don't have any good explanation so why not 
Ha. I have a thousand explanations. Unfortunately all of them are wrong (so far).
My theory (one of them) is that the bug is triggered by an interrupt that occurs while the Lua code is executing a function that isn't thread safe, possibly garbage collection. The bug seems to be triggered by variations in shutter time, which I assume is generating an extra interrupt without incrementing the tick count.
If that's true, it might be possible to add a delay function call right before lua resume() that adds a varying delay from 0 to 10 msec. That way the next tick count incrementing interrupt would occur at a different time after the start of each call to lua resume().
The idea is to try to trigger the bug with a CHDK patch, and simple Lua script:
repeat sleep(10) until false
Then you guys could figure it out in no time, I bet.
I don't use ptpCamGui; but chdkptp works fine with this change.
Thanks for that info. This may be my incentive to learn chdkptp batch mode, which I'm sure works much better once you learn it.
I still wonder why ptpCamGui won't init, though. This may be related to why CHDK starts a second Lt thread. ptpCamGui runs a Lua program on the camera, so maybe this program starts a new Lua thread? Is the Lt thread necessary to do that? As Phil said initially, "there must be some reason."
Also, did anyone look at the LUAASRT.DMP file I posted here?
http://chdk.setepontos.com/index.php?topic=8997.msg99161#msg99161I'm wondering why it was generated when there was no Lua error?
I'll see if I can trigger the bug again with the 2 thread CHDK and post the new log files from reyalp's new patch.