Page 1 of 1

Segfault on Ubuntu 16.04 x86

Posted: Fri Jan 25, 2019 10:43 am
by rudolfninja
Hi guys, trying to run my project on ubuntu 16.04 x86 and see strange segmentation fault. I don't know the reason, but according to valgrind's output the problem comes from wxWidgets:
Process terminating with default action of signal 11 (SIGSEGV): dumping core
==7729== Access not within mapped region at address 0xFFFF
==7729== at 0x4B19A92: g_type_check_instance_cast (in /usr/lib/i386-linux-gnu/libgobject-2.0.so.0.4800.2)
==7729== by 0x868D308: wxPizza::put(_GtkWidget*, int, int, int, int) (in /home/sd/code/rtv-make/bin/ReadyTechHyperViewServer)
==7729== by 0x868E27A: wxWindow::AddChildGTK(wxWindow*) (in /home/sd/code/rtv-make/bin/ReadyTechHyperViewServer)
==7729== by 0x8693191: wxWindow::GTKApplyWidgetStyle(bool) (in /home/sd/code/rtv-make/bin/ReadyTechHyperViewServer)
==7729== by 0x869C567: wxWindow::SetBackgroundColour(wxColour const&) (in /home/sd/code/rtv-make/bin/ReadyTechHyperViewServer)
==7729== by 0x84060B5: ImagePage::ImagePage(wxWizard*, wxBitmap const&, wxString const&, wxString const&) (ImagePage.cpp:25)
==7729== by 0x83F7F3B: ConfiguratorWizard::CreateImagePage(wxString const&, wxString const&) (ConfiguratorWizard.cpp:182)
==7729== by 0x83F8E9A: ConfiguratorWizard::CreateWelcomePage() (ConfiguratorWizard.cpp:123)
==7729== by 0x83FD42C: ConfiguratorWizard::CreatePages() (ConfiguratorWizard.cpp:98)
==7729== by 0x83FD65D: ConfiguratorWizard::ConfiguratorWizard(std::shared_ptr<ConfiguratorSettings> const&, wxWindow*, int, wxString const&, wxBitmap const&, wxPoint const&, long) (ConfiguratorWizard.cpp:27)
Everything works fine on x64 system.
wxWidgets 3.1.1 (x86 version).

ImagePage.cpp:25:

Code: Select all

SetBackgroundColour(*wxWHITE);
Could you please advise next steps to find the reason?

Thanks.

Re: Segfault on Ubuntu 16.04 x86

Posted: Fri Jan 25, 2019 11:30 am
by DavidHart
Hi,
Everything works fine on x64 system.
Meaning, with the same wx version, same gtk+ version, same ubuntu version?
according to valgrind's output
Valgrind isn't usually the best way to debug such things, especially as it is very prone to false alarms.
What happens if you run your program inside gdb? Does a backtrace help?
the problem comes from wxWidgets
It's unlikely to be a wx bug; not impossible of course, but unlikely. It could be that something in the 32bit build hasn't had time to be fully initialised when you try to use it, while in the 64bit build it does.
Can you reproduce the issue in one of the wx samples, or in a patch to e.g. 'minimal'?

Regards,

David

Re: Segfault on Ubuntu 16.04 x86

Posted: Fri Jan 25, 2019 1:59 pm
by rudolfninja
Actually no. I tested 18.04 x64 and 16.04 x86. I'll test it on 18.04 x86 and update the topic with results.
gdb backtrace shows
(gdb) bt
#0 0xb74dda92 in g_type_check_instance_cast () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#1 0x0868d309 in ?? ()
#2 0x206fffff in ?? ()
#3 0x098d6318 in ?? ()
May be it is because wxWidgets was built without symbols, but I think the result will be the same as in valgrind.
For now I don't even have any ideas about the reason. I'll check it on Ubuntu 18.04 x86

Re: Segfault on Ubuntu 16.04 x86

Posted: Fri Jan 25, 2019 3:21 pm
by ONEEYEMAN
Hi,
To get a meaningful gdb output you should rebuild the library with '--enable-debug' option and then rebuild your own software with '-g' option (this will include debug information).

As David said, in case of segfault it is better to use gdb and not a valgrind.

Rebuild and post a backtrace at the time of segfault.

Thank you.

Re: Segfault on Ubuntu 16.04 x86

Posted: Mon Jan 28, 2019 9:07 am
by rudolfninja
Looks like my wxWigets library was build in incorrect way. I rebuilt wxWidgets as described here and now everything is OK. But I now the question is how to use 3rd party libs for jpeg and png libs? As I understand I just need to specify them in ./configure --with-libpng=/path/to/libpng.so --with-libjpeg=/path/to/libjpg.so, but where to specify headers of this libs?

Re: Segfault on Ubuntu 16.04 x86

Posted: Mon Jan 28, 2019 10:08 am
by DavidHart
But I now the question is how to use 3rd party libs for jpeg and png libs?
The 2 standard ways to build wx are:
1) use the distro's libs. For this you need to do nothing special, except to ensure their -dev packages are installed.
2) use the wx builtin libs, which means passing e.g. --with-libpng=builtin to configure.

If for some reason (what?) you don't want to use either, I don't know of any official way to do that. If there is, you should be able to find it by looking inside configure.in and the wx m4 macros, but I suspect it would be easier for you to hack your environment or install dirs so that the headers are found automatically.

Re: Segfault on Ubuntu 16.04 x86

Posted: Mon Jan 28, 2019 3:51 pm
by ONEEYEMAN
David,
The only other option is to turn them off. ;-)

Thank you.