#14431 closed patch (fixed)

XEEN: crash at showCloudsEnding2 and 3

Reported by: yarolig Owned by: yarolig
Priority: normal Component: Engine: MM: Xeen
Version: Keywords:
Cc: Game: Might and Magic: World of Xeen

Description

I finished the clouds side and get a crash at cutscene...

This patch will fix it for branch 2-7 (need different path for master):

diff --git a/engines/xeen/worldofxeen/clouds_cutscenes.cpp b/engines/xeen/worldofxeen/clouds_cutscenes.cpp
index 4f1657fd5af..85815588602 100644
--- a/engines/xeen/worldofxeen/clouds_cutscenes.cpp
+++ b/engines/xeen/worldofxeen/clouds_cutscenes.cpp
@@ -688,6 +688,7 @@ bool CloudsCutscenes::showCloudsEnding2() {
        WAIT(5);

        Graphics::ManagedSurface savedBg;
+       savedBg.create(screen.w, screen.h, screen.format);
        savedBg.blitFrom(screen);

        // Close up of King Roland
@@ -767,6 +768,7 @@ bool CloudsCutscenes::showCloudsEnding3() {

        // Zooming into the mirror
        screen.freePages();
+       savedBg.create(screen.w, screen.h, screen.format);
        savedBg.blitFrom(screen);

        const int XLIST3[9] = { 0, -5, -10, -15, -24, -30, -39, -50, -59 };

Backtrace I got:

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff6a2d859 in __GI_abort () at abort.c:79
#2  0x00007ffff6a2d729 in __assert_fail_base
    (fmt=0x7ffff6bc3588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555555ee9b28 "destFormat.bytesPerPixel == 1 || destFormat.bytesPerPixel == 2 || destFormat.bytesPerPixel == 3 || destFormat.bytesPerPixel == 4", file=0x555555ee9b08 "graphics/managed_surface.cpp", line=293, function=<optimized out>) at assert.c:92
#3  0x00007ffff6a3efd6 in __GI___assert_fail
    (assertion=0x555555ee9b28 "destFormat.bytesPerPixel == 1 || destFormat.bytesPerPixel == 2 || destFormat.bytesPerPixel == 3 || destFormat.bytesPerPixel == 4", file=0x555555ee9b08 "graphics/managed_surface.cpp", line=293, function=0x555555ee9a88 "void Graphics::ManagedSurface::blitFromInner(const Graphics::Surface&, const Common::Rect&, const Common::Rect&, const uint32*)") at assert.c:101
#4  0x0000555555b246f1 in Graphics::ManagedSurface::blitFromInner(Graphics::Surface const&, Common::Rect const&, Common::Rect const&, unsigned int const*) (this=0x7fffffffc790, src=..., srcRect=..., destRect=..., srcPalette=0x0)
    at graphics/managed_surface.cpp:293
#5  0x0000555555b244c5 in Graphics::ManagedSurface::blitFrom(Graphics::ManagedSurface const&, Common::Rect const&, Common::Point const&) (this=0x7fffffffc790, src=..., srcRect=..., destPos=...) at graphics/managed_surface.cpp:261
#6  0x0000555555b2430e in Graphics::ManagedSurface::blitFrom(Graphics::ManagedSurface const&) (this=0x7fffffffc790, src=...) at graphics/managed_surface.cpp:249
#7  0x000055555591a655 in Xeen::WorldOfXeen::CloudsCutscenes::showCloudsEnding2() (this=0x5555574c3d40) at engines/xeen/worldofxeen/clouds_cutscenes.cpp:691
#8  0x0000555555918e2c in Xeen::WorldOfXeen::CloudsCutscenes::showCloudsEnding(unsigned int) (this=0x5555574c3d40, finalScore=63401048) at engines/xeen/worldofxeen/clouds_cutscenes.cpp:395
#9  0x000055555589d8d1 in Xeen::WorldOfXeen::WorldOfXeenEngine::showCutscene(Common::String const&, int, unsigned int) (this=0x5555574c3c00, name=..., status=0, score=63401048) at engines/xeen/worldofxeen/worldofxeen.cpp:165
#10 0x0000555555905e2d in Xeen::Scripts::doEnding(Common::String const&) (this=0x5555574c4fe0, endStr=...) at engines/xeen/scripts.cpp:1555
#11 0x0000555555905be2 in Xeen::Scripts::doCloudsEnding() (this=0x5555574c4fe0) at engines/xeen/scripts.cpp:1518
#12 0x000055555590456c in Xeen::Scripts::cmdCutsceneEndClouds(Xeen::EventParameters::Iterator&) (this=0x5555574c4fe0, params=...) at engines/xeen/scripts.cpp:1132
#13 0x0000555555901e92 in Xeen::Scripts::doOpcode(Xeen::MazeEvent&) (this=0x5555574c4fe0, event=...) at engines/xeen/scripts.cpp:387
#14 0x00005555559012fe in Xeen::Scripts::checkEvents() (this=0x5555574c4fe0) at engines/xeen/scripts.cpp:190
#15 0x00005555558b5c75 in Xeen::Interface::perform() (this=0x5555576bfab0) at engines/xeen/interface.cpp:357
#16 0x000055555589b263 in Xeen::XeenEngine::gameLoop() (this=0x5555574c3c00) at engines/xeen/xeen.cpp:284
#17 0x000055555589b090 in Xeen::XeenEngine::play() (this=0x5555574c3c00) at engines/xeen/xeen.cpp:253
#18 0x000055555589adbb in Xeen::XeenEngine::playGame() (this=0x5555574c3c00) at engines/xeen/xeen.cpp:209
#19 0x000055555589ab5a in Xeen::XeenEngine::outerGameLoop() (this=0x5555574c3c00) at engines/xeen/xeen.cpp:164
#20 0x000055555589aa3e in Xeen::XeenEngine::run() (this=0x5555574c3c00) at engines/xeen/xeen.cpp:139
#21 0x00005555558799ef in runGame(Plugin const*, Plugin const*, OSystem&, Common::String const&) (plugin=0x5555567285a0, enginePlugin=0x555556736ae0, system=..., debugLevels=...) at base/main.cpp:318
#22 0x000055555587ba25 in scummvm_main(int, char const* const*) (argc=1, argv=0x7fffffffdf08) at base/main.cpp:752
#23 0x0000555555876aa8 in main(int, char**) (argc=1, argv=0x7fffffffdf08) at backends/platform/sdl/posix/posix-main.cpp:44

Change History (4)

comment:1 by dreammaster, 19 months ago

Thanks for the report and fix. Is there any chance of doing it as a PR? That would allow us to properly give you credit as the one who fixed the problem. In either case, I'll test and apply the fix in a week's time (or so) when I'm back from an overseas trip.

comment:2 by yarolig, 19 months ago

I sended PR for branch 2-7. https://github.com/scummvm/scummvm/pull/4992

I tried the same thing in master. It works but I got a new crash during monster animations.
Something wrong with flying hand attack.

PR for master https://github.com/scummvm/scummvm/pull/4993

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff6a2d859 in __GI_abort () at abort.c:79
#2  0x00007ffff6a2d729 in __assert_fail_base (fmt=0x7ffff6bc3588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555555f7b1a8 "_pos <= _size", file=0x555555f7b105 "common/stream.cpp", line=132, function=<optimized out>)
    at assert.c:92
#3  0x00007ffff6a3efd6 in __GI___assert_fail (assertion=0x555555f7b1a8 "_pos <= _size", file=0x555555f7b105 "common/stream.cpp", line=132, function=0x555555f7b170 "virtual bool Common::MemoryReadStream::seek(int64, int)")
    at assert.c:101
#4  0x0000555555d05c5e in Common::MemoryReadStream::seek(long, int) (this=0x7fffffffb2f0, offs=8480, whence=0) at common/stream.cpp:132
#5  0x0000555555927524 in MM::Shared::Xeen::SpriteDrawer::draw(MM::Shared::Xeen::XSurface&, unsigned short, Common::Point const&, Common::Rect const&, unsigned int, int) (this=0x55555763fd40,
    dest=..., offset=8480, pt=..., clipRect=..., flags=0, scale=0) at engines/mm/shared/xeen/sprites.cpp:218
#6  0x0000555555926f5c in MM::Shared::Xeen::SpriteResource::draw(MM::Shared::Xeen::XSurface&, int, Common::Point const&, Common::Rect const&, unsigned int, int) const
    (this=0x7fffffffc4e0, dest=..., frame=0, destPos=..., bounds=..., flags=0, scale=0) at engines/mm/shared/xeen/sprites.cpp:153
#7  0x000055555591a8bd in MM::Xeen::SpriteResource::draw(MM::Xeen::Window&, int, Common::Point const&, unsigned int, int) (this=0x7fffffffc4e0, dest=..., frame=0, destPos=..., flags=0, scale=0) at engines/mm/xeen/sprites.cpp:41
#8  0x000055555591a92d in MM::Xeen::SpriteResource::draw(int, int, Common::Point const&, unsigned int, int) (this=0x7fffffffc4e0, windowIndex=0, frame=0, destPos=..., flags=0, scale=0) at engines/mm/xeen/sprites.cpp:47
#9  0x000055555592e464 in MM::Xeen::WorldOfXeen::CloudsCutscenes::showCloudsEnding3() (this=0x555557e01168) at engines/mm/xeen/worldofxeen/clouds_cutscenes.cpp:839
#10 0x000055555592b814 in MM::Xeen::WorldOfXeen::CloudsCutscenes::showCloudsEnding(unsigned int) (this=0x555557e01168, finalScore=0) at engines/mm/xeen/worldofxeen/clouds_cutscenes.cpp:397
#11 0x00005555558ce627 in MM::Xeen::WorldOfXeen::WorldOfXeenEngine::showCutscene(Common::String const&, int, unsigned int) (this=0x555557e00ff0, name=..., status=0, score=0) at engines/mm/xeen/worldofxeen/worldofxeen.cpp:166
#12 0x0000555555918bd9 in MM::Xeen::Scripts::doEnding(Common::String const&) (this=0x555557664da0, endStr=...) at engines/mm/xeen/scripts.cpp:1556
#13 0x000055555591898e in MM::Xeen::Scripts::doCloudsEnding() (this=0x555557664da0) at engines/mm/xeen/scripts.cpp:1519
#14 0x0000555555916bac in MM::Xeen::Scripts::cmdConfirmWord(MM::Xeen::EventParameters::Iterator&) (this=0x555557664da0, params=...) at engines/mm/xeen/scripts.cpp:991
#15 0x0000555555914c48 in MM::Xeen::Scripts::doOpcode(MM::Xeen::MazeEvent&) (this=0x555557664da0, event=...) at engines/mm/xeen/scripts.cpp:388
#16 0x00005555559140b4 in MM::Xeen::Scripts::checkEvents() (this=0x555557664da0) at engines/mm/xeen/scripts.cpp:191
#17 0x00005555558d8589 in MM::Xeen::Interface::perform() (this=0x555557d1c050) at engines/mm/xeen/interface.cpp:318
#18 0x000055555591f685 in MM::Xeen::XeenEngine::gameLoop() (this=0x555557e00ff0) at engines/mm/xeen/xeen.cpp:284
#19 0x000055555591f4b2 in MM::Xeen::XeenEngine::play() (this=0x555557e00ff0) at engines/mm/xeen/xeen.cpp:253
#20 0x000055555591f1dd in MM::Xeen::XeenEngine::playGame() (this=0x555557e00ff0) at engines/mm/xeen/xeen.cpp:209
#21 0x000055555591ef7c in MM::Xeen::XeenEngine::outerGameLoop() (this=0x555557e00ff0) at engines/mm/xeen/xeen.cpp:164
#22 0x000055555591ee60 in MM::Xeen::XeenEngine::run() (this=0x555557e00ff0) at engines/mm/xeen/xeen.cpp:139
#23 0x00005555558af821 in runGame(Plugin const*, Plugin const*, OSystem&, Common::String const&) (plugin=0x555556899390, enginePlugin=0x5555567f5b20, system=..., debugLevels=...) at base/main.cpp:318
#24 0x00005555558b19bd in scummvm_main(int, char const* const*) (argc=1, argv=0x7fffffffdec8) at base/main.cpp:758
#25 0x00005555558ac8da in main(int, char**) (argc=1, argv=0x7fffffffdec8) at backends/platform/sdl/posix/posix-main.cpp:44

(gdb) f 9
(gdb) p frameCtr
$1 = 0

(gdb) p monsterCtr
$5 = 47

(gdb) p -pretty on -- attackSprites
$6 = {
  <MM::Shared::Xeen::SpriteResource> = {
    _vptr.SpriteResource = 0x5555566c5930 <vtable for MM::Xeen::SpriteResource+16>,
    _index = {
      _capacity = 7777,
      _size = 7777,
      _storage = 0x555556df2e20
    },
    _filesize = 5526,
    _data = 0x555557aef800 "a\036 !\232SV",
    _filename = {
      <Common::BaseString<char>> = {
        static npos = 4294967295,
        static _builtinCapacity = 20,
        _size = 7,
        _str = 0x7fffffffc518 "049.att",
        {
          _storage = "049.att", '\000' <repeats 12 times>,
          _extern = {
            _refCount = 0x7474612e393430,
            _capacity = 0
          }
        }
      }, <No data fields>},
    static _clippedBottom = 140
  }, <No data fields>}

Last edited 19 months ago by yarolig (previous) (diff)

comment:3 by bluegr, 18 months ago

Quite a straightforward fix, thanks!

The PR has been merged, so this can be closed now

comment:4 by bluegr, 18 months ago

Owner: set to yarolig
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.