Author Topic: Segmentation fault in code::blocks generated code  (Read 8338 times)

Offline fenixk19

  • Multiple posting newcomer
  • *
  • Posts: 15
Segmentation fault in code::blocks generated code
« on: August 26, 2007, 09:08:05 pm »
Hello. I've already written to nightly builds forum, but nobody answered me. I'm experiencing the following problem. My program fails with segmentation fault while constructing main wxFrame on Create function.
Code
   //(*Initialize(RSWorldEditorFrame)
   // ... menu declarations
    Create(parent, id, _("name"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, _T("id"));
   // ... other initialization

Here is the call stack:
#0 0x2b73fd0a0c82   _int_malloc() (/lib/libc.so.6:??)
#1 0x2b73fd0a2636   calloc() (/lib/libc.so.6:??)
#2 0x2b73feac5892   IA__g_malloc0(n_bytes=16) (gmem.c:150)
#3 0x2b73fe8755db   type_add_flags_W(node=0x7240a0, flags=G_TYPE_FLAG_ABSTRACT) (gtype.c:2912)
#4 0x2b73fe879330   IA__g_type_register_static(parent_type=<value optimized out>, type_name=0x2b73ff22b99d "GtkObject", info=0x2b73ff4b6be0, flags=G_TYPE_FLAG_ABSTRACT) (gtype.c:2263)
#5 0x2b73ff090ef6   IA__gtk_object_get_type() (gtkobject.c:99)
#6 0x2b73ff17108c   IA__gtk_widget_get_type() (gtkwidget.c:293)
#7 0x2b73fefea01f   IA__gtk_container_get_type() (gtkcontainer.c:137)
#8 0x2b73fefb1470   IA__gtk_bin_get_type() (gtkbin.c:43)
#9 0x2b73ff17d7e0   IA__gtk_window_get_type() (gtkwindow.c:311)
#10 0x2b73ff18258d   IA__gtk_window_new(type=GTK_WINDOW_TOPLEVEL) (gtkwindow.c:1071)
#11 0x2b73fb95290a   wxTopLevelWindowGTK::Create(this=0x722dd0, parent=0x0, id=-1, title=@0x7fffb0332620, pos=@0x69e468, sizeOrig=@0x6a0bc8, style=541072960, name=@0x7fffb0332610) (../src/gtk/toplevel.cpp:501)
#12 0x2b73fb9b7783   wxFrame::Create(this=0x722dd0, parent=0x0, id=-1, title=@0x7fffb0332620, pos=@0x69e468, sizeOrig=@0x6a0bc8, style=541072960, name=@0x7fffb0332610) (../src/gtk/frame.cpp:198)
#13 0x41427e   RSWorldEditorFrame(this=0x722dd0, parent=0x0, app_dir=@0x7fffb0332b20, id=-1) (/media/d/Documents and Settings/Phoenix/Мои документы/My_app/RSWorldEditor/RSWorldEditorMain.cpp:122)
#14 0x411cb2   RSWorldEditorApp::OnInit(this=0x6d8420) (/media/d/Documents and Settings/Phoenix/Мои документы/My_app/RSWorldEditor/RSWorldEditorApp.cpp:36)
#15 0x411dfe   wxAppConsole::CallOnInit(this=0x6d8420) (/usr/include/wx-2.8/wx/app.h:76)
#16 0x2b73fc361687   wxEntry(argc=@0x2b73fc67c410, argv=0x6c5d90) (../src/common/init.cpp:433)
#17 0x2b73fc361786   wxEntry(argc=@0x7fffb0332c3c, argv=0x7fffb0332d28) (../src/common/init.cpp:461)
#18 0x411d64   main(argc=1, argv=0x7fffb0332d28) (/media/d/Documents and Settings/Phoenix/Мои документы/My_app/RSWorldEditor/RSWorldEditorApp.cpp:17)

P.S. My system is Xubuntu 7.04. wxGtk is 2.8.4. Code::Blocks is 4410(build from svn)
« Last Edit: August 26, 2007, 09:11:08 pm by fenixk19 »

Offline dje

  • Lives here!
  • ****
  • Posts: 682
Re: Segmentation fault in code::blocks generated code
« Reply #1 on: August 26, 2007, 09:42:57 pm »
Hi !

Are you sure you build a frame in a wxAppConsole ?

Maybe you should check your application type with a right click on project, Properties, Build targets tab and ensure type is a GUI application and not a Console application.

Dje

Offline fenixk19

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Segmentation fault in code::blocks generated code
« Reply #2 on: August 26, 2007, 10:03:03 pm »
Yes, this app is GUI application, not console.

Offline dje

  • Lives here!
  • ****
  • Posts: 682
Re: Segmentation fault in code::blocks generated code
« Reply #3 on: August 26, 2007, 10:22:42 pm »
Sorry, no other idea.
I don't know if the provided code/stack are sufficient to solve the problem...

Dje

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 836
Re: Segmentation fault in code::blocks generated code
« Reply #4 on: August 26, 2007, 11:03:30 pm »
Hello. I've already written to nightly builds forum, but nobody answered me.

Hmm, I've sent you a private message, so you'd better check "My messages" ;).

This problem looks really strange. First, there's not much that should cause crash on calloc function and second: it looks like internal gtk's problem rather than wrong generated code.

One thing that probably should also be taken into consideration - try to copy this project into other path, into some local directory in /home - avoid any spaces and non-english characters. Not standard paths can really cause some annoying bugs (although it looks like they shouldn't affect anything). And also try to fully rebuild project. If that won't help, maybe reinstalling wxGTK would help.

Regards
   BYO


Offline fenixk19

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Segmentation fault in code::blocks generated code
« Reply #5 on: August 26, 2007, 11:53:40 pm »
Hmm, I've sent you a private message, so you'd better check "My messages" ;).
Sorry, i didn't noticed the message  :)

I've done everything you said, but it didn't helped. Then i remembered that this strange error appear just after i plugged new version of my settings load/save library. I've commented all code that uses this library and ran app. It works!!! The library was build using code::blocks too. I will keep experimenting to find out where error does come from.