Crash on FreeBSD

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
csniper
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Mar 13, 2017 8:27 am

Crash on FreeBSD

Post by csniper » Fri Apr 19, 2019 5:43 am

I met an issue with wxWidgets 3.1.2 on GhostBSD 19.04 which is a FreeBSD with GNOME desktop. The build of my App looks OK but it crashed on
initializing globals. The same apps works OK on other Linux dists.

I've no idea so I tried the minimal example of wxWidgets. It crashed at the same point. I tried truss which is the equivalent of strace of F
reeBSD. Has anyone solved the same issue?

I used g++(g++ (FreeBSD Ports Collection) 8.3.0) to build wxWidgets. And it can not be debugged by gdb because it crashed at global init. Below is the call stack. Line 205 is the last line of minimal.cpp.

Core was generated by `./minimal'.
Program terminated with signal SIGSEGV, Segmentation fault.

Code: Select all

#0  0x0000000802a98a38 in vtable for __cxxabiv1::__si_class_type_info () from /lib/libcxxrt.so.1
(gdb) bt
#0  0x0000000802a98a38 in vtable for __cxxabiv1::__si_class_type_info () at /lib/libcxxrt.so.1
#1  0x0000000801a52006 in __dynamic_cast () at /usr/local/lib/gcc8/libstdc++.so.6
#2  0x0000000801ad0620 in bool std::has_facet<std::ctype<char> >(std::locale const&) () at /usr/local/lib/gcc8/libstdc++.so.6
#3  0x0000000801ac3cb4 in std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&) ()
    at /usr/local/lib/gcc8/libstdc++.so.6
#4  0x0000000801ac4130 in std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*) ()
    at /usr/local/lib/gcc8/libstdc++.so.6
#5  0x0000000801a65a33 in std::ios_base::Init::Init() () at /usr/local/lib/gcc8/libstdc++.so.6
#6  0x000000000046ec5f in __static_initialization_and_destruction_0(int, int) (__initialize_p=1, __priority=65535)
    at /usr/local/lib/gcc8/include/c++/iostream:74
#7  0x000000000046ee86 in _GLOBAL__sub_I_minimal.cpp(void) () at ./minimal.cpp:205
#8  0x0000000800aec3bd in  () at /libexec/ld-elf.so.1
#9  0x0000000800b050b0 in  () at /libexec/ld-elf.so.1
#10 0x0000000800b09000 in  ()
#11 0x00007fffffffe710 in  ()
#12 0x00007fffffffeaa2 in  ()
#13 0x00007fffffffd830 in  ()
#14 0x0000000800af7049 in  () at /libexec/ld-elf.so.1
#15 0x00007fffffffd850 in  ()
#16 0x0000000800aebf12 in  () at /libexec/ld-elf.so.1
#17 0x0000000800b18a20 in  ()
#18 0x00007fffffffe710 in  ()
#19 0x0000000802ab0ce0 in  ()
#20 0x0000000800b1fc00 in  ()
#21 0x0000000800b18200 in  ()
#22 0x00007fffffffe710 in  ()
#23 0x00007fffffffd890 in  ()
#24 0x0000000800af06ed in  () at /libexec/ld-elf.so.1
#25 0x0000000800b181e0 in  ()
#26 0x00007fffffffe710 in  ()
Last edited by csniper on Fri Apr 19, 2019 10:02 am, edited 2 times in total.

csniper
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Mar 13, 2017 8:27 am

Re: Crash on GhostBSD

Post by csniper » Fri Apr 19, 2019 5:46 am

SIGNAL 11 (SIGSEGV) code=SEGV_ACCERR trapno=12 by truss

csniper
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Mar 13, 2017 8:27 am

Re: Crash on GhostBSD

Post by csniper » Fri Apr 19, 2019 9:51 am

I tried a FreeBSD 12.0 with XFCE(I installed XFCE from scratch for GTK). The crash dump of minimal is almost the same.

csniper
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Mar 13, 2017 8:27 am

Re: Crash on GhostBSD

Post by csniper » Fri Apr 19, 2019 10:07 am

Code: Select all

#0  0x0000000802fc59e8 in vtable for __cxxabiv1::__si_class_type_info () at /lib/libcxxrt.so.1
#1  0x0000000801d62006 in __dynamic_cast () at /usr/local/lib/gcc8/libstdc++.so.6
#2  0x0000000801de0620 in bool std::has_facet<std::ctype<char> >(std::locale const&) () at /usr/local/lib/gcc8/libstdc++.so.6
#3  0x0000000801dd3cb4 in std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&) ()
    at /usr/local/lib/gcc8/libstdc++.so.6
#4  0x0000000801dd4130 in std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*) () at /usr/local/lib/gcc8/libstdc++.so.6
#5  0x0000000801d75a33 in std::ios_base::Init::Init() () at /usr/local/lib/gcc8/libstdc++.so.6
#6  0x0000000000457c3f in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ./minimal.cpp:205
#7  0x0000000000457c3f in _GLOBAL__sub_I__ZN7MyFrame13sm_eventTableE() () at ./minimal.cpp:205
#8  0x0000000800b2e0fb in objlist_call_init (list=<optimized out>, lockstate=<optimized out>)
    at /usr/src/libexec/rtld-elf/rtld.c:2678
#9  0x0000000800b2cf4c in _rtld (sp=<optimized out>, exit_proc=0x7fffffffe920, objp=0x7fffffffe928)
    at /usr/src/libexec/rtld-elf/rtld.c:745
#10 0x0000000800b2b019 in .rtld_start () at /usr/src/libexec/rtld-elf/amd64/rtld_start.S:39
#11 0x0000000000000000 in  ()
Under FreeBSD 12.0 + XFCE
Last edited by csniper on Fri Apr 19, 2019 12:44 pm, edited 1 time in total.

User avatar
doublemax
Moderator
Moderator
Posts: 13909
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Crash on FreeBSD

Post by doublemax » Fri Apr 19, 2019 11:21 am

Can you try with the latest version from GIT?

Also, which command line did you use for configure and which one for make?
Use the source, Luke!

csniper
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Mar 13, 2017 8:27 am

Re: Crash on FreeBSD

Post by csniper » Fri Apr 19, 2019 12:40 pm

Will try git next Monday.

The command for config is as below:
./configure --enable-unicode --disable-shared --with-libpng=builtin --with-zlib=builtin --with-expat=builtin --with-gtk=3 --with-libiconv=no
make

And I met the issue "Define WX_WEB_EXTENSIONS_DIRECTORY in static builds too" too. Glad to know this has been fixed in git.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3366
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Crash on FreeBSD

Post by ONEEYEMAN » Fri Apr 19, 2019 2:38 pm

Hi,
We don't know if it was fixed or not. That's why doublemax asked YOU TO TRY it.

On the kind of unrelated note:

1. --enable-unicode is the default option since 3.0 and you don't need it to be explicitly set.
2. --disable-shared is weird choice. Could you try to build without it?

It is possible the static build on FreeBSD is broken.

Thank you.

csniper
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Mar 13, 2017 8:27 am

Re: Crash on FreeBSD

Post by csniper » Sat Apr 20, 2019 1:22 am

Will try enable shared first. I used to do static link for all platforms.

BTW, does anyone know if the official wxGTK by FreeBSD is built by c++ the default compiler or g++? I met issues to static link my App by c++ with wxWidgets by g++.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3366
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Crash on FreeBSD

Post by ONEEYEMAN » Sat Apr 20, 2019 2:28 am

Hi,
The standard way of building on *nix is by using dynamic linking.

When you do static linking you essentially push wxWidgets, GTK+, GDK, Cairo, Pango and all other GTK+ dependencies to the binary.

This might be conflicting with the one that is installed by default on the system.

To answer you second question - it is built with g++. Just look at what command is generated on the Terminal when you use "make".

Thank you.

csniper
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Mar 13, 2017 8:27 am

Re: Crash on FreeBSD

Post by csniper » Sun Apr 21, 2019 6:02 am

Sounds like building app based on wxWidgets source code is not a good idea because the target Linux like OS may not have the same wxWidgets version----this is the reason I choose to use static link.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3366
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Crash on FreeBSD

Post by ONEEYEMAN » Sun Apr 21, 2019 2:28 pm

Hi,
Yes, that is exactly why static linking i *nix in general is frown upon.

Every *nix has its own repository for system binaries/libraries and some other packages. And if you link statically it is a possibility that the libraries you link to on you distribution will conflict with the libraries on some other distribution on someone else platform.

More over, I think that does not have an option to link CRT and system libraries statically, whereas Windows does.

And finally - if there will be another C++ ABI incompatibility, you program will simply crash, if its not rebuild against newer gcc.

So all in all - while its still supported, it is not a good idea.

Thank you.

csniper
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Mar 13, 2017 8:27 am

Re: Crash on FreeBSD

Post by csniper » Mon Apr 22, 2019 4:08 am

@ONEEYEMAN

Just for clarify:
it is built with g++.
I was asking the wxGTK released by FreeBSD. Based on FreeBSD 12.0, it's built by cc and c++, the default compiler of FreeBSD.

I met the same issue while mixing build my app with c++ and statically linking with wxWidgets built by g++.

csniper
Knows some wx things
Knows some wx things
Posts: 25
Joined: Mon Mar 13, 2017 8:27 am

Re: Crash on FreeBSD

Post by csniper » Mon Apr 22, 2019 5:30 am

Solved with compiling my app without static link to wxWidgets. And I used the shared library from FreeBSD official. And built my app with c++ instead of g++.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3366
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Crash on FreeBSD

Post by ONEEYEMAN » Mon Apr 22, 2019 1:45 pm

Hi,
Well I don't know anything about FreeBSD. I thought it was using gcc just like regular Linux.

Anyway it is good that this is fixed.

For future references - the library and your software has to be built with the same exact compiler and the same exact set of options.
Otherwise yes - you will have all kinds of different issues.

Thank you.

Post Reply