Opened 3 years ago

Closed 3 years ago

#12593 closed defect (fixed)

AGS: Guard Duty: crash during the intro

Reported by: lolbot-iichan Owned by: dreammaster
Priority: normal Component: Engine: AGS
Version: Keywords:
Cc: Game:

Description (last modified by lolbot-iichan)

Game tested: GOG version of Guard Duty 1.2.0

TESTCASE:

  1. Get https://www.gog.com/game/guard_duty
  2. Start a new game
  3. Look the intro scene starting with "Initiating sequence initiated" line

EXPETED RESULT:
Something is shown and the game is playable

ACTUAL RESULT:
Suddenly assertion is raised at common/rect.h:161

NOTE:

	Rect(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) {
		assert(isValidRect());
	}

I'm running self-built version of master branch, so I collected backtrace:

Thread 1 received signal SIGTRAP, Trace/breakpoint trap.
0x00007ff941679143 in KERNELBASE!DebugBreak ()
   from C:\WINDOWS\System32\KernelBase.dll
(gdb) bt
#0  0x00007ff941679143 in KERNELBASE!DebugBreak ()
   from C:\WINDOWS\System32\KernelBase.dll
#1  0x00007ff94301bb49 in msvcrt!_assert ()
   from C:\WINDOWS\System32\msvcrt.dll
#2  0x0000000140612a34 in Common::Rect::Rect (this=0x5facf8, x1=0, y1=0,
    x2=-31072, y2=15) at ./common/rect.h:161
#3  0x0000000140719e6c in Graphics::ManagedSurface::getBounds (
    this=0x1671d7c0) at ./graphics/managed_surface.h:298
#4  0x000000014043cc54 in Graphics::ManagedSurface::clear (this=0x1671d7c0,
    color=0) at graphics/managed_surface.cpp:729
#5  0x000000014043a817 in Graphics::ManagedSurface::create (this=0x1671d7c0,
    width=34464, height=15, pixelFormat=...)
    at graphics/managed_surface.cpp:158
#6  0x000000014043a138 in Graphics::ManagedSurface::ManagedSurface (
    this=0x1671d7c0, width=100000, height=15, pixelFormat=...)
    at graphics/managed_surface.cpp:60
#7  0x00000001405d1969 in AGS3::Surface::Surface (this=0x1671d7c0,
    width=100000, height=15, pixelFormat=...)
    at ./engines/ags/lib/allegro/surface.h:276
#8  0x000000014004c550 in AGS3::create_bitmap_ex (color_depth=32,
    width=100000, height=15) at engines/ags/lib/allegro/surface.cpp:450
#9  0x000000014005f6dd in AGS3::AGS::Shared::Bitmap::Create (this=0x137ad770,
    width=100000, height=15, color_depth=32)
    at engines/ags/shared/gfx/allegrobitmap.cpp:71
#10 0x000000014005f747 in AGS3::AGS::Shared::Bitmap::CreateTransparent (
    this=0x137ad770, width=100000, height=15, color_depth=32)
    at engines/ags/shared/gfx/allegrobitmap.cpp:80
#11 0x0000000140060cf5 in AGS3::AGS::Shared::BitmapHelper::CreateTransparentBitmap (width=100000, height=15, color_depth=32)
    at engines/ags/shared/gfx/bitmap.cpp:44
#12 0x000000014007677f in AGS3::_display_main (xx=-99685, yy=5, wii=100000,
    text=0x15ad6b13 "When will this suffering end...", disp_type=0,
    usingfont=1, asspch=65535, isThought=0, allowShrink=0,
    overlayPositionFixed=false) at engines/ags/engine/ac/display.cpp:161
#13 0x000000014007737b in AGS3::_display_at (xx=-50002, yy=5, wii=100000,
    text=0x15ad6b13 "When will this suffering end...", disp_type=0,
    asspch=65535, isThought=0, allowShrink=0, overlayPositionFixed=false)
    at engines/ags/engine/ac/display.cpp:342
#14 0x00000001401687f4 in AGS3::_displayspeech (
    texx=0x15ad6b13 "When will this suffering end...", aschar=1, xx=0, yy=0,
    widd=100000, isThought=0) at engines/ags/engine/ac/character.cpp:2674
#15 0x00000001400a488a in AGS3::DisplaySpeechAt (xx=0, yy=0, wii=100000,
    aschar=1, spch=0x15ad6b10 "&1 When will this suffering end...")
    at engines/ags/engine/ac/global_character.cpp:532
#16 0x00000001401622f7 in AGS3::Character_SayAt (chaa=0x11908c6c, x=0, y=0,
    width=100000, texx=0x15ad6b10 "&1 When will this suffering end...")
    at engines/ags/engine/ac/character.cpp:703
#17 0x000000014016ac15 in AGS3::Sc_Character_SayAt (self=0x11908c6c,
    params=0x5fc1a0, param_count=4)
    at engines/ags/engine/ac/character.cpp:3006
#18 0x000000014010ecf9 in AGS3::ccInstance::Run (this=0x12413ce0, curpc=14505)
    at engines/ags/engine/script/cc_instance.cpp:1020
#19 0x000000014010e953 in AGS3::ccInstance::Run (this=0x12413ce0, curpc=407)
    at engines/ags/engine/script/cc_instance.cpp:963
#20 0x000000014010e953 in AGS3::ccInstance::Run (this=0x12413ce0, curpc=796)
    at engines/ags/engine/script/cc_instance.cpp:963
#21 0x000000014010c905 in AGS3::ccInstance::CallScriptFunction (
    this=0x12413ce0,
    funcname=0x140ea2840 <AGS3::scfunctionname> "room_AfterFadeIn",
    numargs=0, params=0x0) at engines/ags/engine/script/cc_instance.cpp:340
#22 0x00000001401148ad in AGS3::RunScriptFunctionIfExists (sci=0x12413ce0,
    tsname=0x140ea2840 <AGS3::scfunctionname> "room_AfterFadeIn", numParam=0,
    params=0x0) at engines/ags/engine/script/script.cpp:360
#23 0x0000000140114af8 in AGS3::RunTextScript (sci=0x12413ce0,
    tsname=0x12ab27e0 "room_AfterFadeIn")
    at engines/ags/engine/script/script.cpp:409
#24 0x000000014011436c in AGS3::RunScriptFunction (sc_inst=AGS3::kScInstRoom,
    fn_name=0x12ab27e0 "room_AfterFadeIn", param_count=0, p1=..., p2=...)
    at engines/ags/engine/script/script.cpp:269
#25 0x00000001401142dd in AGS3::QueueScriptFunction (
    sc_inst=AGS3::kScInstRoom, fn_name=0x12ab27e0 "room_AfterFadeIn",
    param_count=0, p1=..., p2=...) at engines/ags/engine/script/script.cpp:258
#26 0x0000000140113d7b in AGS3::run_interaction_script (nint=0x130300b0,
    evnt=7, chkAny=-1, isInv=0) at engines/ags/engine/script/script.cpp:187
#27 0x000000014017a0ec in AGS3::process_event (evp=0x5fe064)
    at engines/ags/engine/ac/event.cpp:177
#28 0x000000014017af36 in AGS3::processallevents (numev=5, evlist=0x310cf30)
    at engines/ags/engine/ac/event.cpp:363
#29 0x000000014017afc8 in AGS3::update_events ()
    at engines/ags/engine/ac/event.cpp:373
#30 0x00000001400ffb07 in AGS3::game_loop_update_events ()
    at engines/ags/engine/main/game_run.cpp:626
#31 0x00000001401001c6 in AGS3::UpdateGameOnce (checkControls=true,
    extraBitmap=0x0, extraX=0, extraY=0)
    at engines/ags/engine/main/game_run.cpp:750
#32 0x0000000140100753 in AGS3::GameTick ()
    at engines/ags/engine/main/game_run.cpp:872
#33 0x0000000140100a82 in AGS3::RunGameUntilAborted ()
    at engines/ags/engine/main/game_run.cpp:963
#34 0x0000000140100e89 in AGS3::initialize_start_and_play_game (
    override_start_room=0, loadSaveOnStartup=-1)
    at engines/ags/engine/main/game_start.cpp:142
#35 0x00000001400fbb58 in AGS3::initialize_engine (startup_opts=...)
    at engines/ags/engine/main/engine.cpp:1225
#36 0x00000001400429c1 in AGS::AGSEngine::run (this=0x32077c0)
    at engines/ags/ags.cpp:179
#37 0x000000014002b9bf in runGame (plugin=0x279acd0, enginePlugin=0x279ac80,
    system=..., edebuglevels=...) at base/main.cpp:309
#38 0x000000014002d067 in scummvm_main (argc=1, argv=0x2772ca0)
    at base/main.cpp:608
#39 0x00000001400290f9 in SDL_main (argc=1, argv=0x2772ca0)
    at backends/platform/sdl/win32/win32-main.cpp:71
#40 0x0000000140029037 in WinMain ()
    at backends/platform/sdl/win32/win32-main.cpp:54
#41 0x00000001407ad4e2 in main (flags=<optimized out>,
    cmdline=<optimized out>, inst=<optimized out>)
    at D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18
#42 0x00000001400013c1 in __tmainCRTStartup ()
    at D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:335
#43 0x00000001400014d6 in WinMainCRTStartup ()
    at D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:192

Change History (5)

comment:1 by lolbot-iichan, 3 years ago

Description: modified (diff)
Summary: AGS: Guard Duty: crash withAGS: Guard Duty: crash with an assertion at common/rect.h:161

comment:2 by dreammaster, 3 years ago

Seems the game is a bit bonkers, and creates surface 100,000 x 15.. and the ScummVM Surface class currently has a 16,383 (16 bit signed) limit.

comment:3 by dreammaster, 3 years ago

Owner: set to dreammaster
Resolution: fixed
Status: newclosed

comment:4 by lolbot-iichan, 3 years ago

Resolution: fixed
Status: closednew
Summary: AGS: Guard Duty: crash with an assertion at common/rect.h:161AGS: Guard Duty: crash during the intro

Unfortunately, it's not fixed.
Now I get SIGSEGV instead of SIGTRAP:

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00000001406bc8cd in Graphics::ManagedSurface::fillRect (this=0x135c1700,
    r=..., color=0) at ./graphics/managed_surface.h:583
583                     addDirtyRect(r);
(gdb) bt
#0  0x00000001406bc8cd in Graphics::ManagedSurface::fillRect (
    this=0x135c1700, r=..., color=0) at ./graphics/managed_surface.h:583
#1  0x0000000140430131 in Graphics::ManagedSurface::clear (this=0x135c1700,
    color=0) at graphics/managed_surface.cpp:729
#2  0x000000014042ddd1 in Graphics::ManagedSurface::create (this=0x135c1700,
    width=10000, height=15, pixelFormat=...)
    at graphics/managed_surface.cpp:158
#3  0x000000014042d6f4 in Graphics::ManagedSurface::ManagedSurface (
    this=0x135c1700, width=10000, height=15, pixelFormat=...)
    at graphics/managed_surface.cpp:60
#4  0x00000001405ca579 in AGS3::Surface::Surface (this=0x135c1700,
    width=10000, height=15, pixelFormat=...)
    at ./engines/ags/lib/allegro/surface.h:284
#5  0x0000000140050478 in AGS3::create_bitmap_ex (color_depth=32,
    width=10000, height=15) at engines/ags/lib/allegro/surface.cpp:450
#6  0x0000000140063b1d in AGS3::AGS::Shared::Bitmap::Create (this=0xf913ea0,
    width=10000, height=15, color_depth=32)
    at engines/ags/shared/gfx/allegro_bitmap.cpp:71
#7  0x0000000140063b87 in AGS3::AGS::Shared::Bitmap::CreateTransparent (
    this=0xf913ea0, width=10000, height=15, color_depth=32)
    at engines/ags/shared/gfx/allegro_bitmap.cpp:80
#8  0x00000001400650a5 in AGS3::AGS::Shared::BitmapHelper::CreateTransparentBitmap (width=10000, height=15, color_depth=32)
    at engines/ags/shared/gfx/bitmap.cpp:44
#9  0x0000000140075b65 in AGS3::_display_main (xx=-9685, yy=5, wii=10000,
    text=0x10fb8943 "When will this suffering end...", disp_type=0,
    usingfont=1, asspch=65535, isThought=0, allowShrink=0,
    overlayPositionFixed=false) at engines/ags/engine/ac/display.cpp:180
#10 0x0000000140076759 in AGS3::_display_at (xx=-50002, yy=5, wii=100000,
    text=0x10fb8943 "When will this suffering end...", disp_type=0,
    asspch=65535, isThought=0, allowShrink=0, overlayPositionFixed=false)
    at engines/ags/engine/ac/display.cpp:364
#11 0x0000000140161b45 in AGS3::_displayspeech (
    texx=0x10fb8943 "When will this suffering end...", aschar=1, xx=0, yy=0,
    widd=100000, isThought=0) at engines/ags/engine/ac/character.cpp:2675
#12 0x000000014019592e in AGS3::DisplaySpeechAt (xx=0, yy=0, wii=100000,
    aschar=1, spch=0x10fb8940 "&1 When will this suffering end...")
    at engines/ags/engine/ac/global_character.cpp:546
#13 0x000000014015b64f in AGS3::Character_SayAt (chaa=0xeeec70c, x=0, y=0,
    width=100000, texx=0x10fb8940 "&1 When will this suffering end...")
    at engines/ags/engine/ac/character.cpp:701
#14 0x0000000140163f4d in AGS3::Sc_Character_SayAt (self=0xeeec70c,
    params=0x5fc170, param_count=4)
    at engines/ags/engine/ac/character.cpp:3005
#15 0x0000000140106a89 in AGS3::ccInstance::Run (this=0x1333b0b0, curpc=14505)
    at engines/ags/engine/script/cc_instance.cpp:1009
#16 0x00000001401066e3 in AGS3::ccInstance::Run (this=0x1333b0b0, curpc=407)
    at engines/ags/engine/script/cc_instance.cpp:952
#17 0x00000001401066e3 in AGS3::ccInstance::Run (this=0x1333b0b0, curpc=796)
    at engines/ags/engine/script/cc_instance.cpp:952
#18 0x0000000140104710 in AGS3::ccInstance::CallScriptFunction (
    this=0x1333b0b0,
    funcname=0x140f1fda0 <AGS3::scfunctionname> "room_AfterFadeIn",
    numargs=0, params=0x0) at engines/ags/engine/script/cc_instance.cpp:342
#19 0x000000014010c47f in AGS3::RunScriptFunctionIfExists (sci=0x1333b0b0,
    tsname=0x140f1fda0 <AGS3::scfunctionname> "room_AfterFadeIn", numParam=0,
    params=0x0) at engines/ags/engine/script/script.cpp:365
#20 0x000000014010c6ca in AGS3::RunTextScript (sci=0x1333b0b0,
    tsname=0x1094e980 "room_AfterFadeIn")
    at engines/ags/engine/script/script.cpp:414
#21 0x000000014010bf51 in AGS3::RunScriptFunction (sc_inst=AGS3::kScInstRoom,
    fn_name=0x1094e980 "room_AfterFadeIn", param_count=0, p1=..., p2=...)
    at engines/ags/engine/script/script.cpp:271
#22 0x000000014010bec2 in AGS3::QueueScriptFunction (
    sc_inst=AGS3::kScInstRoom, fn_name=0x1094e980 "room_AfterFadeIn",
    param_count=0, p1=..., p2=...) at engines/ags/engine/script/script.cpp:260
#23 0x000000014010b960 in AGS3::run_interaction_script (nint=0x10fbab70,
    evnt=7, chkAny=-1, isInv=0) at engines/ags/engine/script/script.cpp:189
#24 0x000000014017962a in AGS3::process_event (evp=0x5fe034)
    at engines/ags/engine/ac/event.cpp:177
#25 0x000000014017a45b in AGS3::processallevents (numev=5, evlist=0x4c2b9a0)
    at engines/ags/engine/ac/event.cpp:362
#26 0x000000014017a4ed in AGS3::update_events ()
    at engines/ags/engine/ac/event.cpp:372
#27 0x00000001400f8521 in AGS3::game_loop_update_events ()
    at engines/ags/engine/main/game_run.cpp:634
#28 0x00000001400f8bfe in AGS3::UpdateGameOnce (checkControls=true,
    extraBitmap=0x0, extraX=0, extraY=0)
    at engines/ags/engine/main/game_run.cpp:762
#29 0x00000001400f9194 in AGS3::GameTick ()
    at engines/ags/engine/main/game_run.cpp:885
#30 0x00000001400f94cf in AGS3::RunGameUntilAborted ()
    at engines/ags/engine/main/game_run.cpp:979
#31 0x00000001400f98ab in AGS3::initialize_start_and_play_game (
    override_start_room=0, loadSaveGameOnStartup=-1)
    at engines/ags/engine/main/game_start.cpp:126
#32 0x00000001400f4605 in AGS3::initialize_engine (startup_opts=...)
    at engines/ags/engine/main/engine.cpp:1246
#33 0x0000000140044219 in AGS::AGSEngine::run (this=0x4edb160)
    at engines/ags/ags.cpp:177
#34 0x000000014002be62 in runGame (plugin=0x2ff7e30, enginePlugin=0x2ff7de0,
    system=..., debugLevels=...) at base/main.cpp:307
#35 0x000000014002d5d1 in scummvm_main (argc=1, argv=0x2682d30)
    at base/main.cpp:604
#36 0x00000001400294c9 in SDL_main (argc=1, argv=0x2682d30)
    at backends/platform/sdl/win32/win32-main.cpp:76
#37 0x0000000140029407 in WinMain ()
    at backends/platform/sdl/win32/win32-main.cpp:55
#38 0x00000001407a67e2 in main (flags=<optimized out>,
    cmdline=<optimized out>, inst=<optimized out>)
    at D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18
#39 0x00000001400013c1 in __tmainCRTStartup ()
    at D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:335
#40 0x00000001400014d6 in WinMainCRTStartup ()
    at D:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:192

comment:5 by dreammaster, 3 years ago

Resolution: fixed
Status: newclosed

Apologies in the delay replying. It seems my recent change to the Surface class to have signed rather than unsigned fields is to blame. Because now pitch has to be < 32768, which means the maximum width the surface can be is 8000. By changing the hack for Guard Duty from 10,000 down to 8,000, the intro now finishes successfully again.

Note: See TracTickets for help on using tickets.