[Scummvm-tracker] [ScummVM :: Bugs] #13416: MOHAWK: Riven: Cannot create a Switch command from data
ScummVM :: Bugs
trac at scummvm.org
Fri Apr 15 19:52:58 UTC 2022
#13416: MOHAWK: Riven: Cannot create a Switch command from data
------------------------+-----------------------------
Reporter: marcvinyals | Owner: (none)
Type: defect | Status: new
Priority: normal | Component: Engine: Mohawk
Version: | Resolution:
Keywords: | Game: Riven
------------------------+-----------------------------
Comment (by marcvinyals):
I was able to find (what I believe to be) the source of the problem using
valgrind, this is what I get:
{{{
==639379== Conditional jump or move depends on uninitialised value(s)
==639379== at 0x40336E:
Mohawk::RivenScriptManager::createScriptFromData(unsigned int, ...)
(riven_scripts.cpp:162)
==639379== by 0x412E15:
Mohawk::RivenStacks::JSpit::xvga1300_carriage(Common::Array<unsigned
short> const&) (jspit.cpp:309)
==639379== by 0x4143D4: Common::Functor1Mem<Common::Array<unsigned
short> const&, void,
Mohawk::RivenStacks::JSpit>::operator()(Common::Array<unsigned short>
const&) const (func.h:460)
==639379== by 0x408822: Mohawk::RivenStack::runCommand(unsigned short,
Common::Array<unsigned short> const&) (riven_stack.cpp:186)
==639379== by 0x402367:
Mohawk::RivenSimpleCommand::runExternalCommand(unsigned short,
Common::Array<unsigned short> const&) (riven_scripts.cpp:616)
==639379== by 0x4016DD: Mohawk::RivenSimpleCommand::execute()
(riven_scripts.cpp:826)
==639379== by 0x400D77:
Mohawk::RivenScript::run(Mohawk::RivenScriptManager*)
(riven_scripts.cpp:226)
==639379== by 0x400DE2: Mohawk::RivenScriptManager::runQueuedScripts()
(riven_scripts.cpp:141)
==639379== by 0x3EF383: Mohawk::MohawkEngine_Riven::doFrame()
(riven.cpp:227)
==639379== by 0x3EFBED: Mohawk::MohawkEngine_Riven::run()
(riven.cpp:202)
==639379== by 0x3D2544: runGame(Plugin const*, Plugin const*, OSystem&,
Common::String const&) (main.cpp:318)
==639379== by 0x3D52C2: scummvm_main (main.cpp:627)
}}}
Looking around I noticed that in line 170 variable commandCount is used as
the end condition for the loop, but it would make more sense to use
variable argumentCount instead. So I tried that and now valgrind is happy
and I do not hit the bug anymore. I submitted a pull request as
https://github.com/scummvm/scummvm/pull/3811.
There is only one other call to createScriptFromData() where commandCount
is different from argumentCount, namely
engines/mohawk/riven_stacks/aspit.cpp:377, so it is not that surprising
that this is the only place where the problem occurs.
By the way, there is some commented out code in
engines/mohawk/riven_stacks/jspit.cpp:312 that perhaps would work after
the fix.
--
Ticket URL: <https://bugs.scummvm.org/ticket/13416#comment:7>
ScummVM :: Bugs <https://bugs.scummvm.org>
ScummVM
More information about the Scummvm-tracker
mailing list