I have a very odd problem going on. I can replicate the problem by the following small sample code:
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <iostream>
void printSSLErrors()
{
int l_err = ERR_get_error();
while(l_err!=0)
{
std::cout << "SSL ERROR: " << ERR_error_string(l_err, NULL) << std::endl;
l_err = ERR_get_error();
}
}
int main(int argc, char* argv[]) {
SSL_library_init();
SSL_load_error_strings();
// context
SSL_CTX* mp_ctx;
if(!(mp_ctx = SSL_CTX_new(SSLv23_server_method())))
{
printSSLErrors();
return 0;
}
std::cout << "CTX created OK" << std::endl;
// set certificate and private key
if(SSL_CTX_use_certificate_file(mp_ctx, argv[1], SSL_FILETYPE_PEM)!=1)
{
printSSLErrors();
return 0;
}
std::cout << "Certificate intialised OK" << std::endl;
if(SSL_CTX_use_PrivateKey_file(mp_ctx, argv[2], SSL_FILETYPE_PEM)!=1)
{
printSSLErrors();
return 0;
}
std::cout << "Key intialised OK" << std::endl;
SSL_CTX_free(mp_ctx);
ERR_free_strings();
}
This program works as expected when I compile it and link it using -lssl. The problem however is that the openssl routines are part of an application that also links in the mysqlclient libraries. I now recompile the above code with -lssl -lmysqlclient (note that I don't include or use anything from that library here). If I execute the program again I get a segmentation fault in the open ssl library. The most I can pull out of gdb is:
[Thread debugging using libthread_db enabled]
[New Thread -1208158528 (LWP 32359)]
CTX created OK
Certificate intialised OK
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208158528 (LWP 32359)]
0x001b1213 in X509_get_pubkey () from /lib/libcrypto.so.4
(gdb) backtrace
#0 0x001b1213 in X509_get_pubkey () from /lib/libcrypto.so.4
#1 0x00de8a6c in SSL_rstate_string () from /lib/libssl.so.4
#2 0x086f2258 in ?? ()
#3 0xbffceb64 in ?? ()
#4 0x086f1130 in ?? ()
#5 0xbffceaa8 in ?? ()
#6 0x086f2258 in ?? ()
#7 0x086f0d90 in ?? ()
#8 0x00df4858 in ?? () from /lib/libssl.so.4
#9 0x086f2258 in ?? ()
#10 0x086f1130 in ?? ()
#11 0xbffceaa8 in ?? ()
#12 0x00de9d50 in SSL_CTX_use_PrivateKey_file () from /lib/libssl.so.4
Previous frame inner to this frame (corrupt stack?)
(gdb) frame 0
#0 0x001b1213 in X509_get_pubkey () from /lib/libcrypto.so.4
For some reason this only happens when I use mysqlclient v 15 and not with mysqlclient v 16. This is probably too obscure for anyone to solve, but some comments on how linking against a dynamic library that the code itself doesn't even use can cause these errors would be very helpful.
The system is:
RHEL ES4, gcc 3.4.6, openssl-0.9.7a, MySQL-5.11
Any thoughts?
Edit: Here is the output to possibly clarify things a little more:
[Lieuwe ~]$ c++ openssl_test.cpp -lssl -o ssltest
[Lieuwe ~]$ ./ssltest /etc/httpd/conf/certs/test.crt /etc/httpd/conf/certs/test.key
CTX created OK
Certificate intialised OK
Key intialised OK
[Lieuwe ~]$ c++ openssl_test.cpp -lmysqlclient -lssl -o ssltest
[Lieuwe ~]$ ./ssltest /etc/httpd/conf/certs/test.crt /etc/httpd/conf/certs/test.key
CTX created OK
Certificate intialised OK
Segmentation fault (core dumped)
[Lieuwe ~]$
Note that for this purpose I use the crt and key file that the apache server also uses (and work)
Edit 2: Here is the (relevant?) output of valgrind for the program
CTX created OK
--5429-- REDIR: 0x5F6C80 (memchr) redirected to 0x4006184 (memchr)
Certificate intialised OK
==5429== Invalid read of size 4
==5429== at 0xCF4205: X509_get_pubkey (in /lib/libcrypto.so.0.9.7a)
==5429== by 0xDE8A6B: (within /lib/libssl.so.0.9.7a)
==5429== by 0xDE9D4F: SSL_CTX_use_PrivateKey_file (in /lib/libssl.so.0.9.7a)
==5429== by 0x8048C77: main (in /home/liwu/ssltest)
==5429== Address 0x4219940 is 0 bytes inside a block of size 84 free'd
==5429== at 0x4004EFA: free (vg_replace_malloc.c:235)
==5429== by 0xC7FD00: CRYPTO_free (in /lib/libcrypto.so.0.9.7a)
==5429== by 0xCE53A7: (within /lib/libcrypto.so.0.9.7a)
==5429== by 0xCE5562: ASN1_item_free (in /lib/libcrypto.so.0.9.7a)
==5429== by 0xCE0560: X509_free (in /lib/libcrypto.so.0.9.7a)
==5429== by 0xDE979E: SSL_CTX_use_certificate_file (in /lib/libssl.so.0.9.7a)
==5429== by 0x8048C23: main (in /home/liwu/ssltest)
==5429==
==5429== Invalid read of size 4
==5429== at 0xCD4A5F: EVP_PKEY_copy_parameters (in /lib/libcrypto.so.0.9.7a)
==5429== by 0xDE8A7C: (within /lib/libssl.so.0.9.7a)
==5429== by 0xDE9D4F: SSL_CTX_use_PrivateKey_file (in /lib/libssl.so.0.9.7a)
==5429== by 0x8048C77: main (in /home/liwu/ssltest)
==5429== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==5429==
==5429== Process terminating with default action of signal 11 (SIGSEGV)
==5429== Access not within mapped region at address 0x0
==5429== at 0xCD4A5F: EVP_PKEY_copy_parameters (in /lib/libcrypto.so.0.9.7a)
==5429== by 0xDE8A7C: (within /lib/libssl.so.0.9.7a)
==5429== by 0xDE9D4F: SSL_CTX_use_PrivateKey_file (in /lib/libssl.so.0.9.7a)
==5429== by 0x8048C77: main (in /home/liwu/ssltest)
==5429==
I would suggest running your program under Valgrind. Valgrind is intended to provide help with exactly this kind of problem and it is generally much easier to use than a debugger.
If I were to hazard a guess, I would first suspect a memory error in your application (or, less likely, in one of the shared libraries) that is sensitive to the memory layout of the resulting executable. Adding a new shared library or, say, enabling debugging options could very well make the problem appear or disappear for no apparent reason.
The only logical explanation may be that the public key, which is needed for X509_get_pubkey(), can not be located.
Can you please verify that the public key requested by the function is available?
I'd think that the mysql client library is linked against another version of libssl. If you are on linux: are both libraries installed via your distro's official repositories? Are you linking against the static (.a) or dynamic (.so) versions of those libraries?
You can play around with the nm command to find out more (read the manpage).
You can try to rebuild the mysql client library yourself to make sure the same libssl version is used and see whether the problem disappears.
Related
My compiled code is faulty and I decided to use address sanitizer to find its problem with g++ and options -Og -g3 -fsanitize=address -fno-omit-frame-pointer.
I used llvm-symbolizer
export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-9
$ ASAN_OPTIONS=symbolize=1 ./a.out
AddressSanitizer:DEADLYSIGNAL
=================================================================
==7296==ERROR: AddressSanitizer: SEGV on unknown address 0x000200000039 (pc 0x000200000039 bp 0x000000000001 sp 0x7ffd2b566c48 T0)
==7296==The signal is caused by a READ memory access.
==7296==Hint: PC is at a non-executable region. Maybe a wild jump?
AddressSanitizer:DEADLYSIGNAL
AddressSanitizer: nested bug in the same thread, aborting.
It has no meaningful information that helps me finding the source of the problem in my code
It does not dump the stack trace. What does it mean and how can I find the stack-trace or the location of the dumped addresses?
update: Using gdb does not give much more info too
(gdb) run
Starting program: /media/bin/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Full compilation was performed in 0.005376 seconds.
Code has an error.
No input file is given
==8965==LeakSanitizer has encountered a fatal error.
==8965==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==8965==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
Program received signal SIGABRT, Aborted.
0x00007ffff1eac438 in __GI_raise (sig=sig#entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff1eac438 in __GI_raise (sig=sig#entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff1eae03a in __GI_abort () at abort.c:89
#2 0x00007ffff72d14be in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.5
#3 0x00007ffff72dbe78 in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.5
#4 0x00007ffff72e0ecf in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.5
#5 0x00007ffff72e0f05 in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.5
#6 0x00007ffff1eb137a in __cxa_finalize (d=0x7ffff752e4a0) at cxa_finalize.c:56
#7 0x00007ffff71ca793 in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.5
#8 0x00007fffffffdc50 in ?? ()
#9 0x00007ffff7de7e27 in _dl_fini () at dl-fini.c:235
Backtrace stopped: frame did not save the PC
I am trying to create a C++ standalone app based on ArmNN that operates on ONNX models. To start with I have downloaded a few standard models for testing, and while trying to load the model I see a crash saying "Tensor numDimensions must be greater than 0".
The strange thing is, the function that I am invoking to load the model takes just one parameter which is the model name. There is no place for me to specify the dimensions and whatnot. Probably I am doing something wrong here? Or this is not the way to load the model?
I have compiled armnn with support for ONNX as detailed down here. The build and include folders have been copied to a ARM linux machine where I am trying to run the code. I am using a Makefile to compile and run it.
The model I am currently using is download from here.
Initially I was on ArmNN master branch, and while searching for this error message I came across the ArmNN release notes where it was mentioned that the very same error has been fixed in release 19.05. So I switched to tag v19.05 and rebuild everything from scratch and tried to run the application again, but the same error kept popping up.
Here is the C++ code -
#include "armnn/ArmNN.hpp"
#include "armnn/Exceptions.hpp"
#include "armnn/Tensor.hpp"
#include "armnn/INetwork.hpp"
#include "armnnOnnxParser/IOnnxParser.hpp"
int main(int argc, char** argv)
{
armnnOnnxParser::IOnnxParserPtr parser = armnnOnnxParser::IOnnxParser::Create();
std::cout << "\nmodel load start";
armnn::INetworkPtr network = parser->CreateNetworkFromBinaryFile("model.onnx");
std::cout << "\nmodel load end";
std::cout << "\nmain end";
return 0;
}
The Makefile looks like this -
ARMNN_LIB = /home/root/Rahul/armnn_onnx/build
ARMNN_INC = /home/root/Rahul/armnn_onnx/include
all: onnx_test
onnx_test: onnx_test.cpp
g++ -O3 -std=c++14 -I$(ARMNN_INC) onnx_test.cpp -I.-I/usr/include -L/usr/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui -o onnx_test -L$(ARMNN_LIB) -larmnn -lpthread -larmnnOnnxParser
clean:
-rm -f onnx_test
test: onnx_test
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$(ARMNN_LIB) ./onnx_test
Expected output -
The code should load the model as expected and do a clean exit.
Actual error message -
terminate called after throwing an instance of 'armnn::InvalidArgumentException'
what(): Tensor numDimensions must be greater than 0
model load startAborted (core dumped)
A gdb backtrace is provided below -
(gdb) r
Starting program: /home/root/Rahul/sample_onnx/onnx_test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
terminate called after throwing an instance of 'armnn::InvalidArgumentException'
what(): Tensor numDimensions must be greater than 0
model load start
Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig#entry=6) at /usr/src/debug/glibc/2.26-r0/git/sysdeps/unix/sysv/linux/raise.c:51
51 }
(gdb) bt
#0 __GI_raise (sig=sig#entry=6) at /usr/src/debug/glibc/2.26-r0/git/sysdeps/unix/sysv/linux/raise.c:51
#1 0x0000ffffbe97ff00 in __GI_abort () at /usr/src/debug/glibc/2.26-r0/git/stdlib/abort.c:90
#2 0x0000ffffbec0c0f8 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#3 0x0000ffffbec09afc in ?? () from /usr/lib/libstdc++.so.6
#4 0x0000ffffbec09b50 in std::terminate() () from /usr/lib/libstdc++.so.6
#5 0x0000ffffbec09e20 in __cxa_throw () from /usr/lib/libstdc++.so.6
#6 0x0000ffffbefdad84 in armnn::TensorShape::TensorShape(unsigned int, unsigned int const*) () from /home/root/Rahul/armnn_onnx/build/libarmnn.so
#7 0x0000ffffbed454d8 in armnnOnnxParser::(anonymous namespace)::ToTensorInfo(onnx::ValueInfoProto const&) [clone .constprop.493] () from /home/root/Rahul/armnn_onnx/build/libarmnnOnnxParser.so
#8 0x0000ffffbed46080 in armnnOnnxParser::OnnxParser::SetupInfo(google::protobuf::RepeatedPtrField<onnx::ValueInfoProto> const*) () from /home/root/Rahul/armnn_onnx/build/libarmnnOnnxParser.so
#9 0x0000ffffbed461ac in armnnOnnxParser::OnnxParser::LoadGraph() () from /home/root/Rahul/armnn_onnx/build/libarmnnOnnxParser.so
#10 0x0000ffffbed46760 in armnnOnnxParser::OnnxParser::CreateNetworkFromModel(onnx::ModelProto&) () from /home/root/Rahul/armnn_onnx/build/libarmnnOnnxParser.so
#11 0x0000ffffbed469b0 in armnnOnnxParser::OnnxParser::CreateNetworkFromBinaryFile(char const*) () from /home/root/Rahul/armnn_onnx/build/libarmnnOnnxParser.so
#12 0x0000000000400a48 in main ()
It looks like a scalar in ONNX is represented as a tensor with no dimensions. So the problem here is that armnnOnnxParser is not correctly handling ONNX scalars. I would suggest raising an issue on the armnn Github.
I think you should try with at least one input layer and output layer.
// Helper function to make input tensors
armnn::InputTensors MakeInputTensors(const std::pair<armnn::LayerBindingId,
armnn::TensorInfo>& input,
const void* inputTensorData)
{
return { { input.first, armnn::ConstTensor(input.second, inputTensorData) } };
}
For reference visit: https://developer.arm.com/solutions/machine-learning-on-arm/developer-material/how-to-guides/configuring-the-arm-nn-sdk-build-environment-for-onnx
I'm trying to use protobufs v 3.3.2 with Qt 5.9.1. This works with some Qt applications, but only if they are command line programs. Once I create a GUI application with Qt and protobufs, I get this error:
[libprotobuf FATAL
/home/mkraus/Documents/dev/star385/build/linux-desktop-debug-libs/protobuf/src/src/google/protobuf/stubs/common.cc:78]
This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed
version (3.3.2). Contact the program author for an update. If you
compiled the program yourself, make sure that your headers are from
the same version of Protocol Buffers as your link-time library.
(Version verification failed in
"/build/mir-ui6vjS/mir-0.26.3+16.04.20170605/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc".)
I should clarify that my part of the code is certainly using version 3.3.2 (I'm downloading and compiling protobufs from the git sources and statically linking). Look at the stack trace below to see that something that Qt is referencing is causing a protobuf version mismatch.
I'm developing on Ubuntu 16.04 and using the default desktop environment (Unity).
Work-Arounds
My troubleshooting has revealed these symptoms and work-arounds:
Use KDE / KUbuntu. Changing the desktop environment when logging in completely avoids the version mismatch issue.
Run the Qt application with -platform eglfs. This runs the application in full-screen mode using OpenGL. The program runs, but the window size is incorrect. When using the -platform eglfs option, it works even in Unity, but without this option, it gives me the above error.
Any Qt application that is a command-line only application (using QCoreApplication instead of QGuiApplication) can use protobufs 3.3.2. Changing the same app to use a GUI causes the version mismatch issue.
Questions
How can I use protobufs 3.3.2 with Qt GUI applications, and also not be dependent on what desktop environment is in use? Is it Qt that is using the version 2.6.1 of protobufs, and if so, is it feasible to compile Qt to use protobufs 3.3.2?
Debug Info
Here is a stack trace (the program crashes almost immediately upon starting):
terminate called after throwing an instance of 'google::protobuf::FatalException'
what(): This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.3.2). Contact the program author for an update. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "/build/mir-ui6vjS/mir-0.26.3+16.04.20170605/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc".)
Thread 1 "scan" received signal SIGABRT, Aborted.
0x00007ffff4dff428 in __GI_raise (sig=sig#entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff4dff428 in __GI_raise (sig=sig#entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff4e0102a in __GI_abort () at abort.c:89
#2 0x00007ffff543984d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff54376b6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff5437701 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff5437919 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x0000000000603e0a in google::protobuf::internal::LogMessage::Finish (this=0x7fffffffc250)
at /home/mkraus/Documents/dev/star385/build/linux-desktop-debug-libs/protobuf/src/src/google/protobuf/stubs/common.cc:268
#7 0x0000000000603e5a in google::protobuf::internal::LogFinisher::operator= (this=0x7fffffffc20f, other=...)
at /home/mkraus/Documents/dev/star385/build/linux-desktop-debug-libs/protobuf/src/src/google/protobuf/stubs/common.cc:276
#8 0x0000000000603171 in google::protobuf::internal::VerifyVersion (headerVersion=2006001, minLibraryVersion=2006000,
filename=0x7fffde80aec0 "/build/mir-ui6vjS/mir-0.26.3+16.04.20170605/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc")
at /home/mkraus/Documents/dev/star385/build/linux-desktop-debug-libs/protobuf/src/src/google/protobuf/stubs/common.cc:86
#9 0x00007fffde7d490b in mir::protobuf::protobuf_AddDesc_mir_5fprotobuf_2eproto() ()
from /usr/lib/x86_64-linux-gnu/libmirprotobuf.so.3
#10 0x00007fffde7d2409 in ?? () from /usr/lib/x86_64-linux-gnu/libmirprotobuf.so.3
#11 0x00007ffff7de76ba in call_init (l=<optimized out>, argc=argc#entry=1, argv=argv#entry=0x7fffffffd5d8,
env=env#entry=0x7fffffffd5e8) at dl-init.c:72
#12 0x00007ffff7de77cb in call_init (env=0x7fffffffd5e8, argv=0x7fffffffd5d8, argc=1, l=<optimized out>) at dl-init.c:30
#13 _dl_init (main_map=main_map#entry=0xa2f450, argc=1, argv=0x7fffffffd5d8, env=0x7fffffffd5e8) at dl-init.c:120
#14 0x00007ffff7dec8e2 in dl_open_worker (a=a#entry=0x7fffffffc6e0) at dl-open.c:575
#15 0x00007ffff7de7564 in _dl_catch_error (objname=objname#entry=0x7fffffffc6d0, errstring=errstring#entry=0x7fffffffc6d8,
mallocedp=mallocedp#entry=0x7fffffffc6cf, operate=operate#entry=0x7ffff7dec4d0 <dl_open_worker>, args=args#entry=0x7fffffffc6e0)
at dl-error.c:187
#16 0x00007ffff7debda9 in _dl_open (file=0xa2f048 "/opt/Qt5.8.0/5.8/gcc_64/plugins/platformthemes/libqgtk3.so", mode=-2147479551,
caller_dlopen=0x7ffff599b7a8, nsid=-2, argc=<optimized out>, argv=<optimized out>, env=0x7fffffffd5e8) at dl-open.c:660
#17 0x00007ffff1806f09 in dlopen_doit (a=a#entry=0x7fffffffc910) at dlopen.c:66
#18 0x00007ffff7de7564 in _dl_catch_error (objname=0xa02b80, errstring=0xa02b88, mallocedp=0xa02b78,
operate=0x7ffff1806eb0 <dlopen_doit>, args=0x7fffffffc910) at dl-error.c:187
#19 0x00007ffff1807571 in _dlerror_run (operate=operate#entry=0x7ffff1806eb0 <dlopen_doit>, args=args#entry=0x7fffffffc910)
at dlerror.c:163
#20 0x00007ffff1806fa1 in __dlopen (file=<optimized out>, mode=<optimized out>) at dlopen.c:87
#21 0x00007ffff599b7a8 in ?? () from /opt/Qt5.8.0/5.8/gcc_64/lib/libQt5Core.so.5
#22 0x00007ffff5994fd5 in ?? () from /opt/Qt5.8.0/5.8/gcc_64/lib/libQt5Core.so.5
#23 0x00007ffff598a647 in QFactoryLoader::instance(int) const () from /opt/Qt5.8.0/5.8/gcc_64/lib/libQt5Core.so.5
#24 0x00007ffff6b392f1 in ?? () from /opt/Qt5.8.0/5.8/gcc_64/lib/libQt5Gui.so.5
#25 0x00007ffff6b43538 in QGuiApplicationPrivate::createPlatformIntegration() () from /opt/Qt5.8.0/5.8/gcc_64/lib/libQt5Gui.so.5
#26 0x00007ffff6b43edd in QGuiApplicationPrivate::createEventDispatcher() () from /opt/Qt5.8.0/5.8/gcc_64/lib/libQt5Gui.so.5
#27 0x00007ffff59a57d6 in QCoreApplicationPrivate::init() () from /opt/Qt5.8.0/5.8/gcc_64/lib/libQt5Core.so.5
#28 0x00007ffff6b456ab in QGuiApplicationPrivate::init() () from /opt/Qt5.8.0/5.8/gcc_64/lib/libQt5Gui.so.5
#29 0x00007ffff6b46364 in QGuiApplication::QGuiApplication(int&, char**, int) () from /opt/Qt5.8.0/5.8/gcc_64/lib/libQt5Gui.so.5
#30 0x00000000005c55bd in main (argc=1, argv=0x7fffffffd5d8) at /home/mkraus/Documents/dev/star385/src/linux/ui/scan/main.cpp:35
You can find here a discussion about the same issue and they talk about an interesting workaround.
It seems that this error is caused by the library libqgtk3.so located in /opt/Qt/5.9/gcc_64/plugins/platformthemes. If you don't need it in your project you can rename/remove it to make the error go away.
If you are using CMake as a build system you also need to comment all the lines in the file /opt/Qt/5.9/gcc_64/lib/cmake/Qt5Gui/Qt5Gui_QGtk3ThemePlugin.cmake to avoid configure issues.
To add on, the real problem comes from the library libmir which depends on the the libprotobuf. You may run on this problem whenever you try to use recent tensorflow with libgtk3.0 because of this hard dependency. As libmir depends on the system libprotobuf which is normally behind the version in use by tensorflow (which downloads its own version from the repository).
The good news, this BUG on libgtk was reported and fixed however, to use the fixed version you have to move to libgtk3.0 3.22 (see BUG report).
If you are using Qt from the Ubuntu package repository, you can remove the offending library by uninstalling qt5-gtk-platformtheme. This will remove libqgtk3.so and the corresponding CMake file without having to resort to hacks that might have unintended consequences.
As Blabdouze said, this error is caused by the libqgtk3 plugin which is used to set the GUI style. libqgtk3 uses the libmir system library, which uses protobuf 2.6.1. This leads to conflicts when the application starts.
I found a workaround that allows you to avoid editing of Qt files:
You need to copy the "plugins" folder from ".../Qt/5.хх.хх/gcc_64/" to some other location (for example, next to the project build folder).
Then you must remove "platformthemes/libqgtk3.so" and "platformthemes/libqgtk3.so.debug" from the copied folder.
In main(), before creating a QApplication instance, call the static function "QApplication::setLibraryPaths("path/to/copied/plugins/folder")".
Finally, you must add variable "LD_LIBRARY_PATH" with the value ".../Qt/5.хх.хх/gcc_64/lib" (correct path will depend on your Qt version) in a project's "environment settings" in Qt Creator. You also may add a "QT_DEBUG_PLUGINS" variable with a value of "1". It will allow you to check which plugins are used by your project and remove unnecessary plugins from the release version.
In conclusion I would like to note that this error occurred when running the project in Ubuntu 16.04, but it disappeared when I switched to version 18.04. It seems that in version 18.04 app uses the default Qt style instead of the GTK style.
Currently I have a C++ program which crashed every now and then when running. I run it in Dr. Memory, but when it doesn't crash there is no obvious error reported, and when it does drmemory doesn't report anything at all (it just ends). So I debugged it with the shipped GDB in the corresponding MinGW package.
The program is compiled & linked with MinGW gcc 32bit (dwarf2 & sjlj produce similar results), under 64bit Windows 7. The GDB debugger caught a SIGSEGV that caused the program to crash. I made a complete backtrace, but I don't know how to analyze it, for I haven't done it before.
This is where the debugger stopped when the program crashed:
Thread 539 (Thread 5904.0x11b4):
#0 0x00000000 in ?? ()
No symbol table info available.
#1 0x00433f1b in pthread_create_wrapper ()
No symbol table info available.
#2 0x763d1287 in msvcrt!_itow_s () from C:\Windows\syswow64\msvcrt.dll
No symbol table info available.
#3 0x763d1328 in msvcrt!_endthreadex () from C:\Windows\syswow64\msvcrt.dll
No symbol table info available.
#4 0x74e5336a in KERNEL32!BaseThreadInitThunk () from C:\Windows\syswow64\kernel32.dll
No symbol table info available.
#5 0x77069f72 in ntdll!RtlInitializeExceptionChain () from C:\Windows\system32\ntdll.dll
No symbol table info available.
#6 0x77069f45 in ntdll!RtlInitializeExceptionChain () from C:\Windows\system32\ntdll.dll
No symbol table info available.
#7 0x00000000 in ?? ()
No symbol table info available.
I don't know if I should post other parts of the backtrace; it's very long, because the program is a multi-threaded Qt Gui program.
I guess the #0 00000000 in ?? () is where the program crashed, because in other threads there is always a new thread started after ... -> msvcrt!_endthreadex () -> msvcrt!_itow_s () -> pthread_create_wrapper ().
I've been debugging this for days...it's driving me up the wall. Any help will be greatly appreciated!!
P.S. Please let me know if I should post other parts of the backtrace too. I don't know whether the point GDB stopped is just the point problems popped in a multithreaded program.
I have an Ubuntu 13.04 system with the latest SVN version of the Boost C++ libraries installed. The Boost installation was built using the system's native gcc version, v4.7.3. I use Boost pretty extensively, and it works very well when I compile using gcc; I have used many of them, including Boost.Thread (which I will talk about more below), without any issues.
My problem occurs if I try to build a program using the Intel C++ compiler (I've personally used a few different versions in the v13.x series) that link with the installed Boost libraries. When I do so, I get a segmentation fault immediately after program startup; it appears to occur during static initialization of the Boost.Thread library. Here's a simple example program:
#include <boost/version.hpp>
#include <boost/thread.hpp>
int main()
{
boost::this_thread::sleep(boost::posix_time::seconds(1));
}
I compile it using Intel C++:
icpc test.cc -lboost_thread -lboost_system -I/path/to/boost/inc/dir -L/path/to/boost/lib/dir
As I said, when I run the resulting program, I get a near-immediate segfault. Via gdb, the stack trace from the point of the segfault is as follows:
#0 0x00007ffff79b6351 in boost::exception_ptr boost::exception_detail::get_static_exception_object<boost::exception_detail::bad_exception_>() () from ./libboost_thread.so.1.55.0
#1 0x00007ffff79b02e1 in _GLOBAL__sub_I_thread.cpp () from ./libboost_thread.so.1.55.0
#2 0x00007ffff7de9876 in call_init (l=l#entry=0x7ffff7ff9a10, argc=argc#entry=1,
argv=argv#entry=0x7fffffffe0b8, env=env#entry=0x7fffffffe0c8) at dl-init.c:84
#3 0x00007ffff7de9930 in call_init (env=<optimized out>, argv=<optimized out>,
argc=<optimized out>, l=0x7ffff7ff9a10) at dl-init.c:55
#4 _dl_init (main_map=0x7ffff7ffe268, argc=1, argv=0x7fffffffe0b8, env=0x7fffffffe0c8)
at dl-init.c:133
#5 0x00007ffff7ddb68a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#6 0x0000000000000001 in ?? ()
#7 0x00007fffffffe391 in ?? ()
#8 0x0000000000000000 in ?? ()
Not very enlightening, but it's clearly dying during the initialization of libboost_thread.so. If I rebuild Boost including debug symbols, then I get a slightly better picture:
#0 shared_count (r=..., this=0x7ffff7bbc5f8 <boost::exception_ptr boost::exception_detail::get_static_exception_object<boost::exception_detail::bad_exception_>()::ep+8>)
at ./boost/smart_ptr/shared_ptr.hpp:328
#1 shared_ptr (this=0x7ffff7bbc5f0 <boost::exception_ptr boost::exception_detail::get_static_exception_object<boost::exception_detail::bad_exception_>()::ep>) at ./boost/smart_ptr/shared_ptr.hpp:328
#2 exception_ptr (ptr=..., this=0x7ffff7bbc5f0 <boost::exception_ptr boost::exception_detail::get_static_exception_object<boost::exception_detail::bad_exception_>()::ep>)
at ./boost/exception/detail/exception_ptr.hpp:53
#3 boost::exception_detail::get_static_exception_object<boost::exception_detail::bad_exception_> () at ./boost/exception/detail/exception_ptr.hpp:130
#4 0x00007ffff79b02e1 in __static_initialization_and_destruction_0 (__initialize_p=<optimized out>, __priority=<optimized out>) at ./boost/exception/detail/exception_ptr.hpp:143
#5 _GLOBAL__sub_I_thread.cpp(void) () at libs/thread/src/pthread/thread.cpp:767
#6 0x00007ffff7de9876 in call_init (l=l#entry=0x7ffff7ff9a10, argc=argc#entry=1, argv=argv#entry=0x7fffffffe0b8, env=env#entry=0x7fffffffe0c8) at dl-init.c:84
#7 0x00007ffff7de9930 in call_init (env=<optimized out>, argv=<optimized out>, argc=<optimized out>, l=0x7ffff7ff9a10) at dl-init.c:55
#8 _dl_init (main_map=0x7ffff7ffe268, argc=1, argv=0x7fffffffe0b8, env=0x7fffffffe0c8) at dl-init.c:133
#9 0x00007ffff7ddb68a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#10 0x0000000000000001 in ?? ()
#11 0x00007fffffffe391 in ?? ()
#12 0x0000000000000000 in ?? ()
It's unclear to me what static/global object is causing the problem to occur, so I'm not sure how to proceed. I have duplicated this behavior using a number of Boost versions and a few different versions of the Intel C++ compiler in the v13.x series, which is the only release that I have access to at the moment. I have tried every compiler permutation (i.e. I have built Boost with both gcc and icpc and I've built my test application with both also); the only permutation that fails is where Boost is built with gcc and my test application is built using icpc. In every other case, the test application runs successfully.
With that said, you might be led to the obvious answer:
Why not just rebuild Boost using icpc and call it a day? That approach would seem to be effective, given my experimentation, but I have customers who like to use icpc to build my software. Those same customers are likely to have a Linux-distro-provided Boost package installed; they do not have any control over the build environment that was used to generate that package (and, in all likelihood, it was compiled using gcc anyway). Therefore, if it is possible to support such a mixed-compiler configuration, that would be optimal.
Does anyone have any recommendations as to how I might address this static initialization issue?
This is a long shot, but... If you have a different g++ in your PATH than the one used to build the Boost libraries, get rid of it or pass -gxx-name /usr/bin/g++ to icpc. (The Intel compiler adapts itself to the version of GCC it thinks you are using. -gxx-name lets you force the issue.)
OK that probably did not help.
Ubuntu 13.04 is not supported prior to Intel Composer XE 2013 SP1, aka. compiler version 14.0.0. See the "System Requirements" section of the Release Notes and compare it to the same section for the last 13.x release.
Intel definitely aims for link compatibility with GCC. If you can reproduce this problem on a clean install of a supported version of Linux, you should be able to submit a support ticket and get it fixed.