#4 Segmentation fault after game intro (before menu) fixed

closed
nobody
None
5
2007-03-04
2007-02-26
No

Hello,

FreeRA segfaults after game intro (before displaying the game menu) :

$ ./freera
src/vfs/filesystem/externalvfs.cpp line 80: open file ./freera.log
Binpath = .
open /dev/sequencer: No such file or directory
Succes at opening mission.ini
Succes at opening mission.ini
ListBox class initialized
Loading pallete: SNOW
Segmentation fault

Here is a patch which works at least for me on svn rev 219, after studying pcximage code I hope this the right way to fix this issue :)

Discussion

  • Joris_M

    Joris_M - 2007-03-03

    Logged In: YES
    user_id=1680991
    Originator: NO

    Hi,

    Sorry for my late reply, I have had a holliday :)

    about your patch,

    I'm not sure this fix is the correct thing. On my .mix files the game doesn't crash with or without your patch. Could you please explain why you game crashes and why you are using xmax and ymax??

    greetz Joris

     
  • Loic Pefferkorn

    Loic Pefferkorn - 2007-03-04

    Logged In: YES
    user_id=880569
    Originator: YES

    Hi Joris,

    First, md5sums of mix files I'm using :
    main.mix 6cec1b5f0860b425684de74d50c3933d
    redalert.mix af6078d8c16e9ab2fb4ce46f268f563a

    Running rev 219:
    $ ./freera
    src/vfs/filesystem/externalvfs.cpp line 80: open file ./freera.log
    Binpath = .
    open /dev/sequencer: No such file or directory
    Succes at opening mission.ini
    Succes at opening mission.ini
    ListBox class initialized
    Loading pallete: SNOW
    Segmentation fault

    The backtrace generated by gdb :
    (gdb) bt
    #0 0xb7e9e623 in SDL_AddTimer () from /usr/lib/libSDL-1.2.so.0
    #1 0xb7e9d3d9 in SDL_AddTimer () from /usr/lib/libSDL-1.2.so.0
    #2 0xb7eb5794 in SDL_LowerBlit () from /usr/lib/libSDL-1.2.so.0
    #3 0xb7eb6273 in SDL_ConvertSurface () from /usr/lib/libSDL-1.2.so.0
    #4 0xb7eb813d in SDL_DisplayFormat () from /usr/lib/libSDL-1.2.so.0
    #5 0x08065fbe in PCXImage::loadImage (this=0x82162b8)
    at src/video/pcximage.cpp:198
    #6 0x08066021 in PCXImage::getImage (this=0x82162b8)
    at src/video/pcximage.cpp:138
    #7 0x080efeb8 in MenuClass (this=0xbfe0e188) at src/ui/menu.cpp:54
    #8 0x08086122 in Game::HandleGameMenu (this=0xbfe0eff0)
    at src/game/game.cpp:57
    #9 0x0808629c in Game::play (this=0xbfe0eff0) at src/game/game.cpp:260
    #10 0x0804c46a in main (argc=1, argv=0xbfe0f5d4) at src/freera.cpp:170

    Running step by step shows that image = SDL_DisplayFormat(imgtmp) in pcximage.cpp:198 causes the segmentation fault.

    I recompiled freera with "#define DEBUG_PCX" in src/video/pcximage.cpp, to have more information
    about the used pcx image in the menu.

    Segmentation fault as expected, here is freera.log
    src/video/pcximage.cpp line 77: PRINTING pcx header for file: title.pcx
    src/video/pcximage.cpp line 78: Signature = 10
    src/video/pcximage.cpp line 79: Version = 5
    src/video/pcximage.cpp line 80: Encoding = 1
    src/video/pcximage.cpp line 81: BitsPixel = 8
    src/video/pcximage.cpp line 82: XMin = 0
    src/video/pcximage.cpp line 83: YMin = 0
    src/video/pcximage.cpp line 84: XMax = 639
    src/video/pcximage.cpp line 85: YMax = 399
    src/video/pcximage.cpp line 86: HRes = 480
    src/video/pcximage.cpp line 87: VRes = 480
    src/video/pcximage.cpp line 88: NumPlanes = 1
    src/video/pcximage.cpp line 89: BytesLine = 640
    src/video/pcximage.cpp line 90: PalType = 1
    src/video/pcximage.cpp line 91: HscreenSize = 0
    src/video/pcximage.cpp line 92: VscreenSize = 0
    src/video/pcximage.cpp line 116: Vga palette indicator = 12 (should be 12 if it contains a 256 color palette)

    Now I try to find title.pcx in mix files, found it in redalert.mix/hires.mix/title.pcx then extracted using mixshell tool,
    I try to collect infos using file :

    $file TITLE.PCX
    TITLE.PCX: PCX ver. 3.0 image data bounding box [0, 0] - [639, 399], 8-bit colour, 480 x 480 dpi, RLE compressed

    Ok, the informations between debug and file output are similar (639x399 pixels, width stored in XMax and height in YMax)

    In src/video/pcximage.cpp, imgtmp is created in line 186
    imgtmp = SDL_CreateRGBSurfaceFrom( imgdst, header.HRes, header.VRes, header.BitsPixel, header.BytesLine, 0, 0, 0, 0 );

    This function expects image width and height as second and third parameter, here the x (VRes) and y (HRes) resolution are used (480x480)
    instead of width and height stored in XMax and YMax, for me the problem is here, so my patch replace HRes by XMax and VRes by YMax, to have
    the image size.

    It's my analysis :)

     
  • Joris_M

    Joris_M - 2007-03-04

    Logged In: YES
    user_id=1680991
    Originator: NO

    Hi,

    I'm not quite sure jet but I have commited this as it doesn't seem to do any harm and it does seem to fix a crash :)

    greetz Joris

     
  • Joris_M

    Joris_M - 2007-03-04
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks