brson / rust-sdl

SDL bindings for Rust
MIT License
179 stars 52 forks source link

Segfault on OSX when closing a window through the window close button #20

Closed AngryLawyer closed 11 years ago

AngryLawyer commented 11 years ago

When closing an SDL application that has surfaces allocated using the window close button, the application segfaults. I believe this is due to the Drop block being called on all surfaces as they fall out of scope, even though OSX has gone and cleared up the memory itself.

To reproduce:

It might be as simple as checking to see if SDL is initialized before trying to release a surface. I'll provide code to reproduce when I next have a chance.

AngryLawyer commented 11 years ago

Turns out it was an error in my logic. Who'd have thought?!

brson commented 11 years ago

Thanks, @AngryLawyer.

AngryLawyer commented 11 years ago

No problem.

For anyone curious, I had a match statement that tested for the successful creation of an Engine struct, which called sdl::quit at the end of it. As quit was called within the match, Engine never fell out of scope and destroyed its Surfaces until after quit was called, causing the segfault.