[CRiTICAL!!!] Segfault (details in post)

So I’ve played with gravity and wanted to add nice big (1600x1200) space-related backgrounds that would scroll in background (different layer & camera). Unfortunately upon previewing scene with such background, GD gets segfault with bad alloc message.

Log:

[code] Start\ Game\ Develop
Game Develop initialization started:

  • Config file set.

  • Language loaded

  • Image Handlers loaded

  • Single instance checked

  • GDL checked

  • Help file set

  • Crash management ended

  • Splash Screen created

  • Displaying Game Develop version information :
    Game Develop - 2.0.10543.53183 Release
    Built 01/01/2012
    Target system : GNU/Linux, 32-bits

  • Initializing LLVM/Clang…

  • Loading required dynamic libraries…

  • Setting up events compiler…

  • Loading extensions:
    New extension added to manager : BuiltinObject
    New extension added to manager : Sprite
    New extension added to manager : BuiltinCommonInstructions
    New extension added to manager : BuiltinCommonConversions
    New extension added to manager : BuiltinVariables
    New extension added to manager : BuiltinMouse
    New extension added to manager : BuiltinKeyboard
    New extension added to manager : BuiltinJoystick
    New extension added to manager : BuiltinScene
    New extension added to manager : BuiltinTime
    New extension added to manager : BuiltinMathematicalTools
    New extension added to manager : BuiltinCamera
    New extension added to manager : BuiltinAudio
    New extension added to manager : BuiltinFile
    New extension added to manager : BuiltinNetwork
    New extension added to manager : BuiltinWindow
    New extension added to manager : BuiltinStringInstructions
    New extension added to manager : BuiltinAdvanced
    New extension added to manager : TextObject
    New extension added to manager : AES
    New extension added to manager : Light
    New extension added to manager : LinkedObjects
    New extension added to manager : TimedEvent
    New extension added to manager : PhysicsAutomatism
    New extension added to manager : PrimitiveDrawing
    New extension added to manager : Network
    New extension added to manager : ParticleSystem
    New extension added to manager : Box3DObject
    New extension added to manager : AStarAutomatism
    New extension added to manager : TextEntryObject
    New extension added to manager : Function
    New extension added to manager : PathAutomatism
    New extension added to manager : CommonDialogs
    New extension added to manager : VideoObject

  • Extensions loading ended.

  • Creating main window

  • Connecting shortcuts

  • Loading events editor configuration

  • Loading events code compiler configuration

  • Initialization ended.
    13:27:07: Debug: Unrecognized accel key ‘inser’, accel string ignored.
    13:27:07: Debug: Unrecognized accel key ‘inser’, accel string ignored.

(GDEditor:22992): Gtk-CRITICAL **: gtk_widget_set_size_request: assertion `width >= -1’ failed

(GDEditor:22992): Gtk-CRITICAL **: gtk_widget_set_size_request: assertion `width >= -1’ failed

(GDEditor:22992): Gtk-CRITICAL **: gtk_widget_set_size_request: assertion `height >= -1’ failed
ReloadFirstPart:
New worker launched
Compilation: Worker started compilation task(s).
Game and scene copy made, executionEngine shared_ptr ok.
Generating C++ code…

(GDEditor:22992): Gtk-CRITICAL **: gtk_widget_set_size_request: assertion `width >= -1’ failed
ReloadSecondPart
ImageManager: Load dirtball.png
ImageManager: Load BlackSphere.png
ImageManager: Load cannon.png
ImageManager: Load space1.png
OnPreviewBtClick:
StartReload:
ReloadFirstPart:
terminate called after throwing an instance of ‘std::bad_alloc’
what(): std::bad_alloc[/code]

Now cause may be probably one of the two:

  • Big sprite image used for background (1600x1200)
  • Something in background scrolling code (either mine or in core).

In best case, I did something wrong in scrolling code and it’s fixable without recompiling GD. In worst case hotfix will be needed since without it, I can’t continue working on this lil’ project (have to rest from my main one).

//edit: forgot to add game which causes troubles. Here it is: www8.zippyshare.com/v/53780856/file.html

//edit #2: And this aren’t any RAM troubles, because I’ve tried to run it when I had literally nothing opened (except window manager, which in my case is IceWM and it’s pretty lightweight, under 50MB) and xterm to check log. With same result.

4ian has said that it’s better if we use images with size < 1024px (width and height).
Note : the images are stored in the graphic card, not in RAM.

Yeah, but even if they are stored in GPU, I still have 512 MB on it (GeForce 9600GT) and I don’t believe other images that are on screen at scene start are problem. And space1.png (image that is used for bg) has only 1,9 MB. And even if we take into account that images are uncompressed in memory, BMP version of said image still has far less than my GPU can handle (5,8 MB).

And if there is 1024px limitation, maybe GD engine should cut up images that are bigger than 1024MB internally and then tile them so they’ll look like one image, but will be separate ones?

Non, I’ve found the bug, there is a link to background_scroll event sheet in itself : it made a infinity of inclusions.

Yeah, I’ve found it now too.

IDIOT IDIOT IDIOT!!!

//edit: You have full rights to put here link to “You are an idiot” song or any of remixes.

Please don’t try to get me to do a heart attack :laughing:

In fact, I’ve already tried to add a mechanism to prevent these kind of circular references, but it is not as easy as it seems.

When I made this topic, I didn’t know it was circular reference :wink:. Though the simplest mechanism to prevent it would be to check current scene/External event name and prevent adding links using that name.

Circular references can be really deep ( Scene1 → Scene2 → Scene3 → Scene1 → … ), and it is not as easy as it seems as events are agnostic concerning the others events. And I don’t want to implement something that would correct only some kind of circular references and not deeper one.

Hm, you’re right. How about stopping limiting number of references you can have to one scene/external event? The limit should be forgiving (like 10 000 references) but it should help until you’ll find proper solution. And I don’t believe you really need 10 000 links to one scene/external event in single game anyway (and if you for some reason do need, you simply clone this ext. event/scene)