mntmn / scummvm-amigaos3

ScummVM fork for AmigaOS 3
GNU General Public License v2.0
8 stars 8 forks source link

phantasmagoria-demo fails in release builds #2

Open bebbo opened 2 years ago

bebbo commented 2 years ago

in seq_manager.cpp:

offending code:

                if (isReleaseBuild || (offset <= scr->getBufSize() && offset >= (uint)-SCRIPT_OBJECT_MAGIC_OFFSET &&
                                   scr->offsetIsObject(offset))) {

if you'd add an else with some warning, you'll note that it attempts to use several invalid offsets for SEG_TYPE_SCRIPT. if isReleaseBuild is set to true (via -DNDEBUG) it simply crashes.

=> keep that sanity check even if isReleaseBuild is set to true:

                if (offset <= scr->getBufSize() && offset >= (uint)-SCRIPT_OBJECT_MAGIC_OFFSET &&
                                   scr->offsetIsObject(offset)) {
mheyer32 commented 2 years ago

I wrote the offending code, but you're in the wrong repository :-D

I'll fix it in https://github.com/mheyer32/scummvm-amigaos3

I introduced isReleaseBuild to short-circuit some runtime checks I thought were not needed. But I guess some of them are...

mheyer32 commented 2 years ago

I'm curious how you found this bug. I'm always struggling debugging scummvm, even with bgdbserver...

bebbo commented 2 years ago

I wrote the offending code, but you're in the wrong repository :-D

I'll fix it in https://github.com/mheyer32/scummvm-amigaos3

I introduced isReleaseBuild to short-circuit some runtime checks I thought were not needed. But I guess some of them are...

Your repo has issues disabled... ^^

bebbo commented 2 years ago

I'm curious how you found this bug. I'm always struggling debugging scummvm, even with bgdbserver...

it's all done via bisection. You need a working version, build it and

find -name '*.o' -exec cp --parents {} ../ok \;

and a bad version. Build that too and

find -name '*.o' -exec cp --parents {} ../bad \;

depending of the current state, copy good files to fix it or bad files to kill it and run

find -name '*.a' -delete; make -j12; cp scummvm /mnt/f/amiga/test/svm

once you hunted down a single file, compare the asm of these versions, try building a bad and a good file with as less option differences as possible. If necessary bisect these asms into a new asm file manually and apply it until you find the function... ... debug it. I'm using my bgdbserver and DBug from O.M.A. 2.0

and then the fun starts: why does it go wrong in gcc... debug gcc... FIX IT. YEAH!!!