Bug 222822 - devel/sdl20: Fix bugs in SDL_FreeSurface function after 2.0.6 update
Summary: devel/sdl20: Fix bugs in SDL_FreeSurface function after 2.0.6 update
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Jan Beich
URL:
Keywords: patch
Depends on:
Blocks: 222823
  Show dependency treegraph
 
Reported: 2017-10-06 11:03 UTC by lightside
Modified: 2017-10-06 13:15 UTC (History)
1 user (show)

See Also:
jbeich: merge-quarterly+


Attachments
Proposed patch (since 450461 revision) (1.49 KB, patch)
2017-10-06 11:03 UTC, lightside
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description lightside 2017-10-06 11:03:42 UTC
Created attachment 186945 [details]
Proposed patch (since 450461 revision)

The devel/sdl20 was updated to 2.0.6 version in ports r450461, but it has bugs in SDL_FreeSurface function:
- SDL_FreeSurface deallocates surface->map even if the surface is not yet freed
https://bugzilla.libsdl.org/show_bug.cgi?id=3852
https://hg.libsdl.org/SDL/rev/a09c3f87a12f
- Memory leak in SDL_FreeSurface
https://bugzilla.libsdl.org/show_bug.cgi?id=3855
https://hg.libsdl.org/SDL/rev/3a23ca106752

Attached patch for devel/sdl20 port with upstream patches.
As a side effect, this fixes startup issue for games/pioneer for current 20170304 and latest 20171001 release versions:
https://github.com/pioneerspacesim/pioneer/issues/4174
Comment 1 commit-hook freebsd_committer freebsd_triage 2017-10-06 13:06:22 UTC
A commit references this bug:

Author: jbeich
Date: Fri Oct  6 13:05:21 UTC 2017
New revision: 451381
URL: https://svnweb.freebsd.org/changeset/ports/451381

Log:
  devel/sdl20: crashfix for some consumers after r450461

    $ pkg install pioneer
    $ pioneer
    [...]
    ShipType::Init()
    Lua::Init()
    Server agent disabled

    Thread 1 received signal SIGSEGV, Segmentation fault.
    0x0000000800cd5d20 in SDL_ConvertSurface_REAL (surface=0x80b374fc0,
        format=0xb4c7e8 <Graphics::pixelFormatRGBA>, flags=0)
        at /usr/ports/devel/sdl20/work/SDL2-2.0.6/src/video/SDL_surface.c:936
    936         copy_flags = surface->map->info.flags;
    (gdb) p surface->map
    $1 = (struct SDL_BlitMap *) 0x0
    (gdb) bt
    #0  0x0000000800cd5d20 in SDL_ConvertSurface_REAL (surface=0x80b374fc0,
        format=0xb4c7e8 <Graphics::pixelFormatRGBA>, flags=0)
        at /usr/ports/devel/sdl20/work/SDL2-2.0.6/src/video/SDL_surface.c:936
    #1  0x0000000800c099d2 in SDL_ConvertSurface (a=0x80b374fc0,
        b=0xb4c7e8 <Graphics::pixelFormatRGBA>, c=0)
        at /usr/ports/devel/sdl20/work/SDL2-2.0.6/src/dynapi/SDL_dynapi_procs.h:492
    #2  0x000000000081cfbb in Graphics::TextureBuilder::PrepareSurface (this=0x7fffffffac50)
        at TextureBuilder.cpp:117
    #3  0x00000000003a0699 in Graphics::TextureBuilder::GetDescriptor (this=0x7fffffffac50)
        at ./graphics/TextureBuilder.h:48
    [...]

  PR:		222822
  Obtained from:	upstream
  Submitted by:	lightside@gmx.com

Changes:
  head/devel/sdl20/Makefile
  head/devel/sdl20/files/patch-src_video_SDL__surface.c
Comment 2 commit-hook freebsd_committer freebsd_triage 2017-10-06 13:13:30 UTC
A commit references this bug:

Author: jbeich
Date: Fri Oct  6 13:12:41 UTC 2017
New revision: 451383
URL: https://svnweb.freebsd.org/changeset/ports/451383

Log:
  MFH: r451381

  devel/sdl20: crashfix for some consumers after r450461

    $ pkg install pioneer
    $ pioneer
    [...]
    ShipType::Init()
    Lua::Init()
    Server agent disabled

    Thread 1 received signal SIGSEGV, Segmentation fault.
    0x0000000800cd5d20 in SDL_ConvertSurface_REAL (surface=0x80b374fc0,
        format=0xb4c7e8 <Graphics::pixelFormatRGBA>, flags=0)
        at /usr/ports/devel/sdl20/work/SDL2-2.0.6/src/video/SDL_surface.c:936
    936         copy_flags = surface->map->info.flags;
    (gdb) p surface->map
    $1 = (struct SDL_BlitMap *) 0x0
    (gdb) bt
    #0  0x0000000800cd5d20 in SDL_ConvertSurface_REAL (surface=0x80b374fc0,
        format=0xb4c7e8 <Graphics::pixelFormatRGBA>, flags=0)
        at /usr/ports/devel/sdl20/work/SDL2-2.0.6/src/video/SDL_surface.c:936
    #1  0x0000000800c099d2 in SDL_ConvertSurface (a=0x80b374fc0,
        b=0xb4c7e8 <Graphics::pixelFormatRGBA>, c=0)
        at /usr/ports/devel/sdl20/work/SDL2-2.0.6/src/dynapi/SDL_dynapi_procs.h:492
    #2  0x000000000081cfbb in Graphics::TextureBuilder::PrepareSurface (this=0x7fffffffac50)
        at TextureBuilder.cpp:117
    #3  0x00000000003a0699 in Graphics::TextureBuilder::GetDescriptor (this=0x7fffffffac50)
        at ./graphics/TextureBuilder.h:48
    [...]

  PR:		222822
  Obtained from:	upstream
  Submitted by:	lightside@gmx.com
  Approved by:	ports-secteam blanket

Changes:
_U  branches/2017Q4/
  branches/2017Q4/devel/sdl20/Makefile
  branches/2017Q4/devel/sdl20/files/patch-src_video_SDL__surface.c
Comment 3 Jan Beich freebsd_committer freebsd_triage 2017-10-06 13:15:47 UTC
Thanks. Landed. I've reformatted patch header to improve readability.