online icon indicating copy to clipboard operation
online copied to clipboard

Check maps don't change underneath us ...

Open mmeeks opened this issue 1 year ago • 0 comments

Perhaps this is only something a developer would ever see - but I just had a loop crash where the kit would immediately crash as the forkit process forked; it seemed to crash in the seg-fault handler - which is/was interesting in itself.

Sadly I was distracted before I could get to see what was causing that - but I suspect that DOSs changing underneath us can cause a SIGBUS that in turn will prolly cause backtrace() to have problems.

As a thought we already have some degree of paranoia about checking our Jail has not been deleted underneath us; I expect it would be useful to add more of this in the forkit.

I would suggest:

  • after the first LOK initialize and pre-init that we:
  • read /proc/self/maps - and extract all of the DSO filenames - ending that contain ".so" - and executable
  • we stat all of these - and store their size and (I guess) inode number if we can get it
  • when a KIT process crashes, we do a sanity check to see if the system underneath us changed in some unpredictable way
  • and if so exit the forkit - which should trigger coolwsd to re-start it with a new forkit process

Hopefully that would catch some of the more esoteric problems we seem to have on upgrades =)

Of course, hopefully packaging systems do large, atomic updates of everything, and our mmaps will continue to map the previous files which will be released when we exit but ... =)

mmeeks avatar Sep 25 '24 14:09 mmeeks