Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Crashes on thread exit in shared library built with libc++

When an external shared library's thread exits, it crashes the engine with a signal 11 error from Fmalloc. But only if that library was compiled with libc++, ones made with libstdc++ are fine. Which would fix my problem, except that beacause UE uses libc++, in order for any function that takes a string as an input (or a vector or any other standard type) to be callable, the other library has to be compiled with libc++. The library works fine on it's own - it's something about how it connects to UE that causes the issue.

Full instructions and code to reproduce this is at https://github.com/thesilencelies/UEThreadBugMWE.git

Any ideas of a fix/workaround?


Product Version: UE 4.14
more ▼

asked Dec 14 '16 at 01:16 PM in C++ Programming

avatar image

48 2 6 9

avatar image HolyBob Feb 01 '17 at 10:20 PM

Your question actually turns out to be my answer. Linking libc++ instead of libstdc++ actually avoid segfault for me and it's running smoothly. I was having a hard time integrating third-party library on linux until I read this post. Thanks for the help although I didn't know the exact answer you have. It maybe helpful for others who is having problems.

This is what I used for cmake

cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++ -I/usr/include/libcxxabi"

The idea behind is to compiles using libc++ not libstdc++ depends on your third party library. In my case was AWS SDK.

avatar image thesilencelies Feb 02 '17 at 09:39 AM

Glad to hear this helped. I haven't actually got a fix for this: the nature of my project has changed slightly so the code that this was relevant for wasn't needed any more. May I ask where your segfault was?

avatar image zompi2 Feb 10 '17 at 09:51 AM

Any news in this field? I have a simillar problem. I'm writing a static library for iOS and when I'm building and linking it with libstdc++ everything works fine, but when with libc++ I have crashes in std::strings and std::vectors, in really strange places.

libstdc++ is currently deprecated on iOS, so I don't want to use it, but at this moment I have no choice :(

When I'm running my library with iOS app it works fine, but strange things happens after linking it to the engine.

What's more - crashes occurs only on shipping builds. Development builds works fine (but it is probably because of less restricted memory management).

Any clues what can be wrong with it?

avatar image sytelus Jul 17 '17 at 05:46 PM

I'm getting exact same issue. The thread exit in library causes segfault. I'm also seeing segfaults in strange places such as fstream and stringstream. It would be great if Unreal folks can specify the best way to compile libraries that works with their engine.

avatar image nsubiron Jul 20 '17 at 06:02 PM

Same here, I am having segfaults in the destructors of std::string and std::future on an externally linked library

avatar image shaneliu Nov 05 '18 at 01:39 PM

I am using windows Visual Studio Community 2017 ver.15.7.6 + UE 4.19.2. One of my .dll work fine outside UE; However while it is used in UE project as plugin, it crashes every time in destruction of std::thread, which is very, very despairing. Is there any way to fix this?

avatar image zompi2 Nov 05 '18 at 01:48 PM

This probably won't help. but I noticed that using different libraries to support threads is usually a bad idea which can lead to crashes.

This is why I'm using WinAPI threads for Windows and pthread for other unix related platforms in my own sdk.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question