Segfault upon exiting sdl_falcon

Bug #668652 reported by Tommy Ettinger
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Falcon
Fix Committed
Undecided
Unassigned

Bug Description

I am running Falcon from Git-head on a 64-bit (Mac OS X Snow Leopard) Intel MacBook, and I have the framework versions of the various SDL libraries installed and set up so that ccmake was aware of them at compile-time for Falcon. The "Use OpenGL" option was also checked, if that matters. When I run the example "Hello, World" application given at http://falconpl.org/project_docs/sdl/ , a window pops up with the title bar correctly set, but I get a "beach-ball" cursor when I am running the application until I give input to sdl_falcon. At that point, I get the following messages in the terminal:

$ sdl_falcon sdlTest.fal
Success! - press enter

2010-10-26 22:18:13.624 sdl_falcon[67259:4403] *** __NSAutoreleaseNoPool(): Object 0x1004863d0 of class NSCFArray autoreleased with no pool in place - just leaking
2010-10-26 22:18:13.627 sdl_falcon[67259:4403] *** __NSAutoreleaseNoPool(): Object 0x100414fd0 of class NSCFNumber autoreleased with no pool in place - just leaking
2010-10-26 22:18:13.627 sdl_falcon[67259:4403] *** __NSAutoreleaseNoPool(): Object 0x10043e380 of class NSCFDictionary autoreleased with no pool in place - just leaking
2010-10-26 22:18:13.648 sdl_falcon[67259:4403] *** __NSAutoreleaseNoPool(): Object 0x10181f050 of class NSCFString autoreleased with no pool in place - just leaking
2010-10-26 22:18:13.649 sdl_falcon[67259:4403] *** __NSAutoreleaseNoPool(): Object 0x1004160d0 of class NSCFNumber autoreleased with no pool in place - just leaking
2010-10-26 22:18:13.649 sdl_falcon[67259:4403] *** __NSAutoreleaseNoPool(): Object 0x100489f00 of class NSCFDictionary autoreleased with no pool in place - just leaking
2010-10-26 22:18:13.656 sdl_falcon[67259:4403] *** __NSAutoreleaseNoPool(): Object 0x1018c9180 of class NSCFArray autoreleased with no pool in place - just leaking
2010-10-26 22:18:13.658 sdl_falcon[67259:4403] *** __NSAutoreleaseNoPool(): Object 0x1018c99b0 of class SDL_QuartzWindow autoreleased with no pool in place - just leaking
Segmentation fault

$

The contents of sdlTest.fal are:

load sdl

try
   a = SDL.InitAuto( SDL.INIT_VIDEO )
   SDL.WM_SetCaption( "Falcon SDL window", "Falcon and SDL" )
   screen = SDL.SetVideoMode( 640, 480 )

   > "Success! - press enter"
   input()
catch SDLError in e
   > "Test failed: "
   > e
end

//EoF

I'm not sure if there is an error in this code (it is the example given for the most basic SDL application copied verbatim, so I doubt that), or if there is some other issue at work. I won't be using Falcon for an end-user application (my intended purpose) if my program segfaults, so I am hoping this is a fixable bug.

Revision history for this message
Sebastian Lai (user17) wrote :

Do you have a debugger (gdb) installed? If so, try these steps:

    gdb falcon sdlTest.fal

Then, in gdb, type "run", then "bt", and post a reply with the data.

Revision history for this message
Tommy Ettinger (thomas-ettinger) wrote :
Download full text (5.8 KiB)

OK, I tried both your suggestion and `gdb sdl_falcon sdlTest.fal` . When I run this with plain falcon, I get:

$ gdb falcon sdlTest.fal
GNU gdb 6.3.50-20050815 (Apple version gdb-1472) (Wed Jul 21 10:53:12 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ..... done

"/Users/me/Falcon/sdlTest.fal" is not a core dump: File format not recognized
(gdb) run
Starting program: /usr/local/bin/falcon
Reading symbols for shared libraries ++++.. done
^Z
Program received signal SIGTSTP, Stopped (user).
0x00007fff81b188e4 in read ()
(gdb) bt
#0 0x00007fff81b188e4 in read ()
#1 0x00000001001ab589 in Falcon::BaseFileStream::read ()
#2 0x00000001000c061b in Falcon::StreamBuffer::refill ()
#3 0x00000001000c105b in Falcon::StreamBuffer::read ()
#4 0x00000001000de9ce in Falcon::TranscoderISO_CP::get ()
#5 0x00000001000bcb7a in Falcon::SrcLexer::lex_normal ()
#6 0x00000001000bf2d2 in Falcon::SrcLexer::lex ()
#7 0x00000001001107a0 in Falcon::SrcLexer::doLex ()
#8 0x00000001001107c7 in flc_src_lex ()
#9 0x0000000100104528 in flc_src_parse ()
#10 0x0000000100025a05 in Falcon::Compiler::compile ()
#11 0x0000000100026126 in Falcon::Compiler::compile ()
#12 0x00000001000a1a5c in Falcon::ModuleLoader::loadSource ()
#13 0x00000001000052ba in Falcon::AppFalcon::loadInput ()
#14 0x00000001000054eb in Falcon::AppFalcon::runModule ()
#15 0x0000000100006841 in Falcon::AppFalcon::run ()
#16 0x00000001000070b6 in main ()
(gdb)

I pressed Ctrl-Z after about 10 seconds when nothing was happening.

When I try `gdb sdl_falcon sdlTest.fal` the SDL window never appears, but the application icon appears in the dock, focus switches to the new (empty) application, and I get the beach-ball cursor (blocking input to the application, but not to gdb). Unlike when I just run `sdl_falcon sdlTest.fal` , this time I don't see any output (such as "Success!"), and the only input I can make (that it responds to) is an escape sequence (I used Ctrl-Z).

$ gdb sdl_falcon sdlTest.fal
GNU gdb 6.3.50-20050815 (Apple version gdb-1472) (Wed Jul 21 10:53:12 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...
warning: Unable to read symbols for "@executable_path/../Frameworks/SDL.framework/Versions/A/SDL" (file not found).

warning: Unable to read symbols from "SDL" (not yet mapped into memory).
Reading symbols for shared libraries .......... done

"/Users/me/Falcon/sdlTest.fal" is not a core dump: File format not recognized
(gdb) run
Starting program: /usr/local/bin/sdl_falcon
Reading symbols for shared l...

Read more...

Revision history for this message
gniccolai (gc-niccolai) wrote : Re: [Bug 668652] Re: Segfault upon exiting sdl_falcon
Download full text (6.5 KiB)

On 31/10/2010 05:08, Thomas Ettinger wrote:
> OK, I tried both your suggestion and `gdb sdl_falcon sdlTest.fal` .
> When I run this with plain falcon, I get:
>
> $ gdb falcon sdlTest.fal
> GNU gdb 6.3.50-20050815 (Apple version gdb-1472) (Wed Jul 21 10:53:12 UTC 2010)
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for details.
> This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ..... done
>
> "/Users/me/Falcon/sdlTest.fal" is not a core dump: File format not recognized
> (gdb) run
> Starting program: /usr/local/bin/falcon
> Reading symbols for shared libraries ++++.. done
> ^Z
> Program received signal SIGTSTP, Stopped (user).
> 0x00007fff81b188e4 in read ()
> (gdb) bt
> #0 0x00007fff81b188e4 in read ()
> #1 0x00000001001ab589 in Falcon::BaseFileStream::read ()
> #2 0x00000001000c061b in Falcon::StreamBuffer::refill ()
> #3 0x00000001000c105b in Falcon::StreamBuffer::read ()
> #4 0x00000001000de9ce in Falcon::TranscoderISO_CP::get ()
> #5 0x00000001000bcb7a in Falcon::SrcLexer::lex_normal ()
> #6 0x00000001000bf2d2 in Falcon::SrcLexer::lex ()
> #7 0x00000001001107a0 in Falcon::SrcLexer::doLex ()
> #8 0x00000001001107c7 in flc_src_lex ()
> #9 0x0000000100104528 in flc_src_parse ()
> #10 0x0000000100025a05 in Falcon::Compiler::compile ()
> #11 0x0000000100026126 in Falcon::Compiler::compile ()
> #12 0x00000001000a1a5c in Falcon::ModuleLoader::loadSource ()
> #13 0x00000001000052ba in Falcon::AppFalcon::loadInput ()
> #14 0x00000001000054eb in Falcon::AppFalcon::runModule ()
> #15 0x0000000100006841 in Falcon::AppFalcon::run ()
> #16 0x00000001000070b6 in main ()
> (gdb)
>
> I pressed Ctrl-Z after about 10 seconds when nothing was happening.
>
> When I try `gdb sdl_falcon sdlTest.fal` the SDL window never appears,
> but the application icon appears in the dock, focus switches to the new
> (empty) application, and I get the beach-ball cursor (blocking input to
> the application, but not to gdb). Unlike when I just run `sdl_falcon
> sdlTest.fal` , this time I don't see any output (such as "Success!"),
> and the only input I can make (that it responds to) is an escape
> sequence (I used Ctrl-Z).
>
> $ gdb sdl_falcon sdlTest.fal
> GNU gdb 6.3.50-20050815 (Apple version gdb-1472) (Wed Jul 21 10:53:12 UTC 2010)
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for details.
> This GDB was configured as "x86_64-apple-darwin"...
> warning: Unable to read symbols for "@executable_path/../Frameworks/SDL.framework/Versions/A/SDL" (file not found).
>
> warning: Unable to read symbols from "SDL" (not yet mapped into memory).
> Reading symbols for shared libraries .......... done
>
>...

Read more...

Revision history for this message
Tommy Ettinger (thomas-ettinger) wrote :

OK, yes, it was a library configuration issue. The SDL_LIBRARY setting in ccmake needed some different flags than the default ones (although now I don't remember what the defaults were, I figured out what to do by adding everything printed by `sdl-config --libs` and weeding out the incompatible flags by trial and error). The correct setting for SDL_LIBRARY on my machine is `/Library/Frameworks/SDL.framework;-lSDLmain -Wl,-framework,Cocoa ` ; this stops the segfault issue (because now it can find Cocoa), and while I am not certain if -lSDLmain is necessary, I am pretty sure it can't hurt.

Revision history for this message
Tommy Ettinger (thomas-ettinger) wrote :

OK, it turns out it is still leaking, and it only stopped segfaulting because I was calling SDL.Init() instead of SDL.InitAuto() , which I am told does not perform memory management. I can use SDL.Quit() , but this results in a segfault every time I call it (though it does not print any memory leak errors, just "Segmentation Fault" ). So it looks like I can leak memory and have no visible errors, or manage memory and get a segfault...

Revision history for this message
gniccolai (gc-niccolai) wrote :

On 03/11/2010 22:46, Thomas Ettinger wrote:
> OK, it turns out it is still leaking, and it only stopped segfaulting
> because I was calling SDL.Init() instead of SDL.InitAuto() , which I am
> told does not perform memory management. I can use SDL.Quit() , but
> this results in a segfault every time I call it (though it does not
> print any memory leak errors, just "Segmentation Fault" ). So it looks
> like I can leak memory and have no visible errors, or manage memory and
> get a segfault...
>
>
can you post a stacktrace? -- we experience nothing like that on any
test (MacOSX 10.5, latest build).

Gian.

Revision history for this message
Tommy Ettinger (thomas-ettinger) wrote :
Download full text (4.4 KiB)

OK, based on advice from the nice people in the Falcon IRC chatroom, I ran a stacktrace on sdl_events.fal in the tests/samples/ directory of the sdl module. Here's what I got:

$ gdb /usr/local/bin/sdl_falcon
GNU gdb 6.3.50-20050815 (Apple version gdb-1472) (Wed Jul 21 10:53:12 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...
warning: Unable to read symbols for "@executable_path/../Frameworks/SDL.framework/Versions/A/SDL" (file not found).

warning: Unable to read symbols from "SDL" (not yet mapped into memory).
Reading symbols for shared libraries .......... done

(gdb) run sdl_events.fal
Starting program: /usr/local/bin/sdl_falcon sdl_events.fal
Reading symbols for shared libraries .+.++++++++....................................................................................... done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
Success! - Now start moving the mouse.
Click the X on the bar to quit the app.
Reset...
Reset...
Reset...

== Quit! ==
I am quit
Complete.
2010-11-06 03:06:01.820 sdl_falcon[3008:4403] *** __NSAutoreleaseNoPool(): Object 0x1148153d0 of class NSCFArray autoreleased with no pool in place - just leaking
2010-11-06 03:06:01.823 sdl_falcon[3008:4403] *** __NSAutoreleaseNoPool(): Object 0x100600af0 of class NSCFNumber autoreleased with no pool in place - just leaking
2010-11-06 03:06:01.823 sdl_falcon[3008:4403] *** __NSAutoreleaseNoPool(): Object 0x100634800 of class NSCFDictionary autoreleased with no pool in place - just leaking
2010-11-06 03:06:01.824 sdl_falcon[3008:4403] *** __NSAutoreleaseNoPool(): Object 0x100638a10 of class NSCFString autoreleased with no pool in place - just leaking
2010-11-06 03:06:01.824 sdl_falcon[3008:4403] *** __NSAutoreleaseNoPool(): Object 0x1005159e0 of class NSCFNumber autoreleased with no pool in place - just leaking
2010-11-06 03:06:01.825 sdl_falcon[3008:4403] *** __NSAutoreleaseNoPool(): Object 0x10063c580 of class NSCFDictionary autoreleased with no pool in place - just leaking
2010-11-06 03:06:01.826 sdl_falcon[3008:4403] *** __NSAutoreleaseNoPool(): Object 0x100648530 of class NSCFArray autoreleased with no pool in place - just leaking
2010-11-06 03:06:01.827 sdl_falcon[3008:4403] *** __NSAutoreleaseNoPool(): Object 0x100633160 of class SDL_QuartzWindow autoreleased with no pool in place - just leaking

Program received signal EXC_BAD_ACCESS...

Read more...

Revision history for this message
gniccolai (gc-niccolai) wrote :

We discovered that SDL_FreeSurface can be called on screen surfaces, but on some platform this causes a sudden crash.

So, we solved the bug increasing the initial refcount of screen surfaces so that they cannot be freed.

I suppose that SDL 1.3 and following may solve this problem; we'll be back at that point.

Changed in falconpl:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.