I met a very strange segfault and I does not understand the cause.
Context: in a console QT application, I need to create a PDF file containing some information but the PDF generation causes a segmentation fault.
I reduced the initial code to the main function and a method.
The qt .pro file:
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
QT += core
QT += gui # need for pdf generation
QT += printsupport #need for pdf generation
main.cpp
int main(int argc, char *argv[])
{
QCoreApplication::setSetuidAllowed(true);
QCoreApplication app(argc, argv);
CPdfCreationDryRun pdfCreate(&app);
QTimer::singleShot(0, &pdfCreate, SLOT(start()));
return app.exec();
}
test.cpp
void CPdfCreationDryRun::start()
{
QTextDocument doc {};
const QString msg {"<p>toto</p>"};
doc.setHtml(msg);
const QString pdfFileName {"toto.pdf"};
QPrinter printer {QPrinter::PrinterResolution};
printer.setPageSize(QPrinter::A4);
printer.setOrientation(QPrinter::Portrait);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(pdfFileName);
printer.setFontEmbeddingEnabled(true);
doc.print(&printer);
}
gdb backtrace
#0 0x00007f5cfec7bc42 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#1 0x00007f5cfec7f2cd in QFontDatabase::findFont(QFontDef const&, int) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#2 0x00007f5cfec7faf6 in QFontDatabase::load(QFontPrivate const*, int) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#3 0x00007f5cfec553b3 in QFontPrivate::engineForScript(int) const () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#4 0x00007f5cfec86cf9 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#5 0x00007f5cfeca0006 in QTextLine::layout_helper(int) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#6 0x00007f5cfeca1840 in QTextLine::setLineWidth(double) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#7 0x00007f5cfece4d3d in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#8 0x00007f5cfece5845 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#9 0x00007f5cfeceac3d in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#10 0x00007f5cfeceb0b9 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#11 0x00007f5cfeceb2b8 in QTextDocumentLayout::doLayout(int, int, int) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#12 0x00007f5cfecebde1 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#13 0x00007f5cfecec789 in QTextDocumentLayout::documentChanged(int, int, int) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#14 0x00007f5cfecb6bc6 in QTextDocument::documentLayout() const () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#15 0x00007f5cfecbe1ed in QTextDocument::print(QPagedPaintDevice*) const () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#16 0x0000559445993520 in CPdfCreationDryRun::start (this=0x7ffc7ea14be0) at
valgrind logs:
==82570== Invalid read of size 8
==82570== at 0x54A8C42: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54AC2CC: QFontDatabase::findFont(QFontDef const&, int) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54ACAF5: QFontDatabase::load(QFontPrivate const*, int) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54823B2: QFontPrivate::engineForScript(int) const (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54B7617: QTextEngine::fontEngine(QScriptItem const&, QFixed*, QFixed*, QFixed*) const (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54B8708: QTextEngine::shapeText(int) const (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54B93EE: QTextEngine::shape(int) const (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54CDDFB: QTextLine::layout_helper(int) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54CE83F: QTextLine::setLineWidth(double) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x5511D3C: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x5512844: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x5517C3C: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==82570==
==82570==
==82570== Process terminating with default action of signal 11 (SIGSEGV)
==82570== Access not within mapped region at address 0x0
==82570== at 0x54A8C42: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54AC2CC: QFontDatabase::findFont(QFontDef const&, int) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54ACAF5: QFontDatabase::load(QFontPrivate const*, int) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54823B2: QFontPrivate::engineForScript(int) const (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54B7617: QTextEngine::fontEngine(QScriptItem const&, QFixed*, QFixed*, QFixed*) const (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54B8708: QTextEngine::shapeText(int) const (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54B93EE: QTextEngine::shape(int) const (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54CDDFB: QTextLine::layout_helper(int) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x54CE83F: QTextLine::setLineWidth(double) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x5511D3C: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x5512844: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
==82570== by 0x5517C3C: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.9.5)
I tried to redefine QT_QPA_FONTDIR env variable to different directories containing fonts but this did not change the behavior.
EDIT1: I tried without "printer.setFontEmbeddingEnabled()" and it did not change the behavior.
EDIT2: The doc variable content:
doc.toHtml: "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\np, li { white-space: pre-wrap; }\n</style></head><body style=\" font-family:''; font-weight:400; font-style:normal;\">\n<p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">toto</p></body></html>"
doc.toPlainText: "toto"
doc.toRaw: "toto"
Host configuration:
Linux ubuntu 4.18.0-25-generic #26~18.04.1-Ubuntu SMP Thu Jun 27 07:28:31 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
g++ --version
g++ (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0
QT: 5.9.5-0ubuntu1
I am looking for any helps to understand the observed behavior and how to fix it.
Thanks & regards,
I found a workaround: I replaced
QCoreApplication
per
QApplication
then rebuilt... And it works :'(
Related
Consider following (broken) code:
#include <iostream>
#include <memory>
using namespace std;
class Test {
public:
unique_ptr<string> s;
Test() : s(NULL) {
}
void update(string& st) {
s = unique_ptr<string>(&(st));
}
};
void update(Test& t) {
string s("Hello to you");
t.update(s);
}
int main() {
Test t;
update(t);
cout << *t.s << endl;
}
Here we have error in method Test::update() we do not make a uniq copy of an object. So when the program is run under macOS, you'll get:
$ ./test
Hello t��E]�
test(44981,0x7fff99ba93c0) malloc: *** error for object 0x7fff5d45b690: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
[1] 44981 abort ./test
I've been able to to debug this case successfully using lldb. Even without setting a breakpoint in malloc_error_break, just running application until it gets caught in SIGABRT handler.
lldb ./test
(lldb) target create "./test"
Current executable set to './test' (x86_64).
(lldb) run
Process 44993 launched: './test' (x86_64)
Hello t��_�
test(44993,0x7fff99ba93c0) malloc: *** error for object 0x7fff5fbff680: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Process 44993 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00007fff90d6cd42 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
-> 0x7fff90d6cd42 <+10>: jae 0x7fff90d6cd4c ; <+20>
0x7fff90d6cd44 <+12>: movq %rax, %rdi
0x7fff90d6cd47 <+15>: jmp 0x7fff90d65caf ; cerror_nocancel
0x7fff90d6cd4c <+20>: retq
Target 0: (test) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: 0x00007fff90d6cd42 libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x00007fff90e5a457 libsystem_pthread.dylib`pthread_kill + 90
frame #2: 0x00007fff90cd2420 libsystem_c.dylib`abort + 129
frame #3: 0x00007fff90dc1fe7 libsystem_malloc.dylib`free + 530
frame #4: 0x0000000100001f7b test`Test::~Test() [inlined] std::__1::default_delete<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::operator(this=0x00007fff5fbff730, __ptr="\a\x94\x99�\x7f\0\0��_�\x7f\0\0\x80�_�\x7f\0\00�_�\x7f\0\00�_�\x7f\0\00�_�\x7f\0\00�_�\x7f\0\00�_�\x7f\0\0��_�\x7f\0\0\x15\x1e\0\0\x01\0\0\0\x80�_�\x7f\0\n0")(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) const at memory:2397
frame #5: 0x0000000100001f46 test`Test::~Test() [inlined] std::__1::unique_ptr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::default_delete<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::reset(this=0x00007fff5fbff730, __p="") at memory:2603
frame #6: 0x0000000100001ef3 test`Test::~Test() [inlined] std::__1::unique_ptr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::default_delete<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::~unique_ptr(this=0x00007fff5fbff730) at memory:2571
frame #7: 0x0000000100001ef3 test`Test::~Test() [inlined] std::__1::unique_ptr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::default_delete<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::~unique_ptr(this=0x00007fff5fbff730) at memory:2571
frame #8: 0x0000000100001ef3 test`Test::~Test(this=0x00007fff5fbff730) at main.cpp:6
frame #9: 0x0000000100001e15 test`Test::~Test(this=0x00007fff5fbff730) at main.cpp:6
frame #10: 0x0000000100001ab6 test`main at main.cpp:28
frame #11: 0x00007fff90c3e235 libdyld.dylib`start + 1
Now I see that the problem is in Test destructor, and from here it's a piece of cake.
Unfortunately, trying to debug this case using gdb under macOS was a total failure. Here is what I've done:
$ gdb ./test
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin16.7.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from test...Reading symbols from /Users/bazhenov/Developer/linear-counter/tests/test/test.dSYM/Contents/Resources/DWARF/test...done.
done.
(gdb) run
Starting program: /Users/bazhenov/Developer/linear-counter/tests/test/test
[New Thread 0x1403 of process 45204]
warning: unhandled dyld version (15)
Hello tQ�_�
test(45204,0x7fff99ba93c0) malloc: *** error for object 0x7fff5fbff650: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Thread 2 received signal SIGABRT, Aborted.
0x00007fff90d6cd42 in ?? ()
(gdb) bt
#0 0x00007fff90d6cd42 in ?? ()
#1 0x00007fff90e5a457 in ?? ()
#2 0x00007fff5fbff590 in ?? ()
#3 0x0000030700000000 in ?? ()
#4 0x00007fff5fbff590 in ?? ()
#5 0x00007fff5fbff650 in ?? ()
#6 0x00007fff5fbff5a0 in ?? ()
#7 0x00007fff90cd2420 in ?? ()
#8 0xffffffff00000018 in ?? ()
#9 0x00007fff5fbff5b0 in ?? ()
#10 0x00007fffffffffdf in ?? ()
#11 0x00000001000c4000 in ?? ()
#12 0x00007fff5fbff5f0 in ?? ()
#13 0x00007fff90dc1fe7 in ?? ()
#14 0x378b45e65b700074 in ?? ()
#15 0x00007fff99ba00ac in ?? ()
#16 0x0000000000000000 in ?? ()
(gdb)
The question is: why gdb fails to unwind the stack correctly and what options do I have if I need to get correct backtrace using gdb?
why gdb fails to unwind the stack correctly
There are some problems on Mac OS X Sierra with gdb, see this post and gdb bug report.
what options do I have if I need to get correct backtrace using gdb
You can try to downgrade Mac OS (don't know whether is it possible) or try to apply temporary hack patch from above bug report.
On macOS 10.12.6, I have a shared library and an executable (both built myself, SIP should not apply AFAIK) and I'd like to preload the library for the executable. It fails, with a return code of 1, and silently otherwise:
$ ./bar/exec
<does stuff>
$ DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=./foo/my.dylib ./bar/exec
<returns immediately>
$ echo $?
1
# 1 is not an explicitly returned value from ./bar/exec
If I add either DYLD_PRINT_LIBRARIES or DYLD_PRINT_LIBRARIES_POST_LAUNCH options as documented in man dyld, they both show that both the library and the executable have been loaded successfully:
...
dyld: loaded: /full/path/to/exec
dyld: loaded: ./foo/my.dylib
...
If I try to run the executable with preload in either dtruss or lldb, it runs, without the library preloaded. This might make sense because these tools are SIP-protected.
How do I go about debugging this?
UPDATE
Thanks to #macmoonshine, I am able to reproduce the return code 1 exit under lldb by setting the preload environment from LLDB itself as opposed for LLDB:
(lldb) env DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=./foo/my.dylib
(lldb) run
...
Process 24130 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
frame #0: 0x00007fffc8aac310 libsystem_kernel.dylib`__exit
...
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
* frame #0: 0x00007fffc8aac310 libsystem_kernel.dylib`__exit
frame #1: 0x000000010008ebac my.dylib`my_init at my.c:86 [opt]
frame #2: 0x0000000100018a1b dyld`ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 385
frame #3: 0x0000000100018c1e dyld`ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 40
frame #4: 0x00000001000144aa dyld`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 338
frame #5: 0x0000000100013524 dyld`ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 138
frame #6: 0x00000001000135b9 dyld`ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 75
frame #7: 0x0000000100005434 dyld`dyld::initializeMainExecutable() + 125
frame #8: 0x00000001000098c6 dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 3966
frame #9: 0x0000000100004249 dyld`dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) + 470
frame #10: 0x0000000100004036 dyld`_dyld_start + 54
This is a start for debugging.
You can run your code in lldb, where you can set the environment with the env command:
env DYLD_FORCE_FLAT_NAMESPACE=1
env DYLD_INSERT_LIBRARIES=./foo/my.dylib
run
With lldb you can run your program until it crashes. If it exists abnormally with exit() (or _exit()), you should set symbolic breakpoints with b exitand b _exit. So you have the chance to get a backtrace where it fails.
I added DTPerformanceSession.framework to the OSX app Build Phases and when I run the app it crashes with the following error:
dyld`dyld_fatal_error:
0x7fff5fc0109c: int3
0x7fff5fc0109d: nop
Console message:
dyld: Library not loaded: #rpath/DTPerformanceSession.framework/Versions/A/DTPerformanceSession
Referenced from: /Users/Danger/Library/Developer/Xcode/DerivedData/HSCountingInputStream-dbhgckaaqtaiqueimpvpxllvygvt/Build/Products/Debug/HSCountingInputStream
Reason: image not found
Back trace:
* thread #1: tid = 0x5e40d, 0x00007fff5fc0109d dyld`dyld_fatal_error + 1, stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x00007fff5fc0109d dyld`dyld_fatal_error + 1
frame #1: 0x00007fff5fc02138 dyld`dyld::halt(char const*) + 79
frame #2: 0x00007fff5fc059bd dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 2733
frame #3: 0x00007fff5fc01397 dyld`dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) + 761
frame #4: 0x00007fff5fc0105e dyld`_dyld_start + 54
Note: DTPerformanceSession.framework is at path:
/Applications/Xcode.app/Contents/Developer/Library/Frameworks
See the great page: Using code generated flags to debug with Instruments. Basically one just needs to add the framework, build and remove the framework, it is needed only for Xcode to find the include and only once. Alternatively add the framework and mark it "Optional".
boost library version 1.53
Debian Linux 6.0 ( Linux 2.6.32-5-amd64 on x86_64 )
It is hard to test own software when valgrind log contains lots of warnings.
So with no changes I built the HTTP server3 example and run it under the Valgrind.
Take a look, please. Did I miss something?
valgrind --tool=helgrind --log-file=valgrind.log ./server3 0.0.0.0 83 5 /root/server3
Here is the Helgrind log (edited to 30000 body characters limit, full log http://pastebin.com/Vkbr9vsA):
Helgrind, a thread error detector
Copyright (C) 2007-2012, and GNU GPL'd, by OpenWorks LLP et al.
Using Valgrind-3.9.0.SVN and LibVEX; rerun with -h for copyright info
Command: ./server3 0.0.0.0 83 5 /root/server3
Parent PID: 8662
Lock at 0x524F5E0 was first observed
at 0x4C2C692: pthread_mutex_lock (hg_intercepts.c:495)
by 0x5043388: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043498: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (in /usr/lib/libboost_thread.so.1.53.0)
by 0x504380E: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x4C2D6FE: mythread_wrapper (hg_intercepts.c:219)
by 0x5256B4F: start_thread (pthread_create.c:304)
by 0x5CE5A7C: clone (clone.S:112)
Possible data race during read of size 8 at 0x524F4E8 by thread #3
Locks held: none
at 0x5043356: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043498: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (in /usr/lib/libboost_thread.so.1.53.0)
by 0x504380E: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x4C2D6FE: mythread_wrapper (hg_intercepts.c:219)
by 0x5256B4F: start_thread (pthread_create.c:304)
by 0x5CE5A7C: clone (clone.S:112)
This conflicts with a previous write of size 8 by thread #2
Locks held: 1, at address 0x524F5E0
at 0x5043416: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043498: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (in /usr/lib/libboost_thread.so.1.53.0)
by 0x504380E: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x4C2D6FE: mythread_wrapper (hg_intercepts.c:219)
by 0x5256B4F: start_thread (pthread_create.c:304)
by 0x5CE5A7C: clone (clone.S:112)
----------------------------------------------------------------
Possible data race during read of size 4 at 0x524F60C by thread #3
Locks held: none
at 0x50496D4: boost::detail::get_once_per_thread_epoch() (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043361: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043498: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (in /usr/lib/libboost_thread.so.1.53.0)
by 0x504380E: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x4C2D6FE: mythread_wrapper (hg_intercepts.c:219)
by 0x5256B4F: start_thread (pthread_create.c:304)
by 0x5CE5A7C: clone (clone.S:112)
This conflicts with a previous write of size 4 by thread #2
Locks held: none
at 0x525C27B: pthread_key_create (pthread_key_create.c:44)
by 0x525C82F: pthread_once (pthread_once.S:104)
by 0x50496D3: boost::detail::get_once_per_thread_epoch() (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043361: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043498: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (in /usr/lib/libboost_thread.so.1.53.0)
by 0x504380E: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x4C2D6FE: mythread_wrapper (hg_intercepts.c:219)
by 0x5256B4F: start_thread (pthread_create.c:304)
----------------------------------------------------------------
Possible data race during read of size 8 at 0x524F4E8 by thread #1
Locks held: 1, at address 0x61A1E20
at 0x5043356: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043478: boost::detail::get_current_thread_data() (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5047875: boost::detail::interruption_checker::interruption_checker(pthread_mutex_t*, pthread_cond_t*) (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5044002: boost::thread::join_noexcept() (in /usr/lib/libboost_thread.so.1.53.0)
by 0x42660E: boost::thread::join() (thread.hpp:751)
by 0x4215C5: http::server3::server::run() (server.cpp:63)
by 0x41A65B: main (main.cpp:37)
----------------------------------------------------------------
Possible data race during read of size 4 at 0x524F60C by thread #1
Locks held: 1, at address 0x61A1E20
at 0x50496D4: boost::detail::get_once_per_thread_epoch() (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043361: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043478: boost::detail::get_current_thread_data() (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5047875: boost::detail::interruption_checker::interruption_checker(pthread_mutex_t*, pthread_cond_t*) (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5044002: boost::thread::join_noexcept() (in /usr/lib/libboost_thread.so.1.53.0)
by 0x42660E: boost::thread::join() (thread.hpp:751)
by 0x4215C5: http::server3::server::run() (server.cpp:63)
by 0x41A65B: main (main.cpp:37)
This conflicts with a previous write of size 4 by thread #2
Locks held: none
at 0x525C27B: pthread_key_create (pthread_key_create.c:44)
by 0x525C82F: pthread_once (pthread_once.S:104)
by 0x50496D3: boost::detail::get_once_per_thread_epoch() (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043361: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x5043498: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (in /usr/lib/libboost_thread.so.1.53.0)
by 0x504380E: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x4C2D6FE: mythread_wrapper (hg_intercepts.c:219)
by 0x5256B4F: start_thread (pthread_create.c:304)
----------------------------------------------------------------
Possible data race during write of size 4 at 0x61A36B8 by thread #6
Locks held: none
at 0x4223B0: boost::asio::detail::epoll_reactor::descriptor_state::set_ready_events(unsigned int) (epoll_reactor.hpp:68)
by 0x4228A5: boost::asio::detail::epoll_reactor::run(bool, boost::asio::detail::op_queue<boost::asio::detail::task_io_service_operation>&) (epoll_reactor.ipp:430)
by 0x423629: boost::asio::detail::task_io_service::do_run_one(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&, boost::asio::detail::task_io_service_thread_info&, boost::system::error_code const&) (task_io_service.ipp:396)
by 0x423302: boost::asio::detail::task_io_service::run(boost::system::error_code&) (task_io_service.ipp:153)
by 0x42393A: boost::asio::io_service::run() (io_service.ipp:59)
by 0x42EB34: boost::_mfi::mf0<unsigned long, boost::asio::io_service>::operator()(boost::asio::io_service*) const (mem_fn_template.hpp:49)
by 0x42EA72: unsigned long boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> >::operator()<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list0>(boost::_bi::type<unsigned long>, boost::_mfi::mf0<unsigned long, boost::asio::io_service>&, boost::_bi::list0&, long) (bind.hpp:243)
by 0x42E91E: boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > >::operator()() (bind_template.hpp:20)
by 0x42E65D: boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::run() (thread.hpp:117)
by 0x5043818: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x4C2D6FE: mythread_wrapper (hg_intercepts.c:219)
by 0x5256B4F: start_thread (pthread_create.c:304)
Address 0x61A36B8 is 24 bytes inside a block of size 160 alloc'd
at 0x4C28A3A: operator new(unsigned long) (vg_replace_malloc.c:298)
by 0x42806A: boost::asio::detail::epoll_reactor::descriptor_state* boost::asio::detail::object_pool_access::create<boost::asio::detail::epoll_reactor::descriptor_state>() (object_pool.hpp:35)
by 0x4267B8: boost::asio::detail::object_pool<boost::asio::detail::epoll_reactor::descriptor_state>::alloc() (object_pool.hpp:89)
by 0x4229E3: boost::asio::detail::epoll_reactor::allocate_descriptor_state() (epoll_reactor.ipp:512)
by 0x4223D4: boost::asio::detail::epoll_reactor::register_descriptor(int, boost::asio::detail::epoll_reactor::descriptor_state*&) (epoll_reactor.ipp:151)
by 0x424405: boost::asio::detail::reactive_socket_service_base::do_assign(boost::asio::detail::reactive_socket_service_base::base_implementation_type&, int, int const&, boost::system::error_code&) (reactive_socket_service_base.ipp:182)
by 0x42DA98: boost::asio::detail::reactive_socket_service<boost::asio::ip::tcp>::assign(boost::asio::detail::reactive_socket_service<boost::asio::ip::tcp>::implementation_type&, boost::asio::ip::tcp const&, int const&, boost::system::error_code&) (reactive_socket_service.hpp:117)
by 0x42D75C: boost::asio::stream_socket_service<boost::asio::ip::tcp>::assign(boost::asio::detail::reactive_socket_service<boost::asio::ip::tcp>::implementation_type&, boost::asio::ip::tcp const&, int const&, boost::system::error_code&) (stream_socket_service.hpp:138)
by 0x42D263: boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >::assign(boost::asio::ip::tcp const&, int const&, boost::system::error_code&) (basic_socket.hpp:285)
by 0x42CAD7: boost::asio::detail::reactive_socket_accept_op_base<boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ip::tcp>::do_perform(boost::asio::detail::reactor_op*) (reactive_socket_accept_op.hpp:66)
by 0x409DE0: boost::asio::detail::reactor_op::perform() (reactor_op.hpp:40)
by 0x422C2F: boost::asio::detail::epoll_reactor::descriptor_state::perform_io(unsigned int) (epoll_reactor.ipp:622)
----------------------------------------------------------------
Possible data race during write of size 8 at 0x61A36A8 by thread #6
Locks held: none
at 0x410E9E: void boost::asio::detail::op_queue_access::next<boost::asio::detail::task_io_service_operation, boost::asio::detail::task_io_service_operation>(boost::asio::detail::task_io_service_operation*&, boost::asio::detail::task_io_service_operation*) (op_queue.hpp:41)
by 0x40EBEE: boost::asio::detail::op_queue<boost::asio::detail::task_io_service_operation>::push(boost::asio::detail::task_io_service_operation*) (op_queue.hpp:107)
by 0x4228BB: boost::asio::detail::epoll_reactor::run(bool, boost::asio::detail::op_queue<boost::asio::detail::task_io_service_operation>&) (epoll_reactor.ipp:431)
by 0x423629: boost::asio::detail::task_io_service::do_run_one(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&, boost::asio::detail::task_io_service_thread_info&, boost::system::error_code const&) (task_io_service.ipp:396)
by 0x423302: boost::asio::detail::task_io_service::run(boost::system::error_code&) (task_io_service.ipp:153)
by 0x42393A: boost::asio::io_service::run() (io_service.ipp:59)
by 0x42EB34: boost::_mfi::mf0<unsigned long, boost::asio::io_service>::operator()(boost::asio::io_service*) const (mem_fn_template.hpp:49)
by 0x42EA72: unsigned long boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> >::operator()<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list0>(boost::_bi::type<unsigned long>, boost::_mfi::mf0<unsigned long, boost::asio::io_service>&, boost::_bi::list0&, long) (bind.hpp:243)
by 0x42E91E: boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > >::operator()() (bind_template.hpp:20)
by 0x42E65D: boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::run() (thread.hpp:117)
by 0x5043818: ??? (in /usr/lib/libboost_thread.so.1.53.0)
by 0x4C2D6FE: mythread_wrapper (hg_intercepts.c:219)
Address 0x61A36A8 is 8 bytes inside a block of size 160 alloc'd
at 0x4C28A3A: operator new(unsigned long) (vg_replace_malloc.c:298)
by 0x42806A: boost::asio::detail::epoll_reactor::descriptor_state* boost::asio::detail::object_pool_access::create<boost::asio::detail::epoll_reactor::descriptor_state>() (object_pool.hpp:35)
by 0x4267B8: boost::asio::detail::object_pool<boost::asio::detail::epoll_reactor::descriptor_state>::alloc() (object_pool.hpp:89)
by 0x4229E3: boost::asio::detail::epoll_reactor::allocate_descriptor_state() (epoll_reactor.ipp:512)
by 0x4223D4: boost::asio::detail::epoll_reactor::register_descriptor(int, boost::asio::detail::epoll_reactor::descriptor_state*&) (epoll_reactor.ipp:151)
by 0x424405: boost::asio::detail::reactive_socket_service_base::do_assign(boost::asio::detail::reactive_socket_service_base::base_implementation_type&, int, int const&, boost::system::error_code&) (reactive_socket_service_base.ipp:182)
by 0x42DA98: boost::asio::detail::reactive_socket_service<boost::asio::ip::tcp>::assign(boost::asio::detail::reactive_socket_service<boost::asio::ip::tcp>::implementation_type&, boost::asio::ip::tcp const&, int const&, boost::system::error_code&) (reactive_socket_service.hpp:117)
by 0x42D75C: boost::asio::stream_socket_service<boost::asio::ip::tcp>::assign(boost::asio::detail::reactive_socket_service<boost::asio::ip::tcp>::implementation_type&, boost::asio::ip::tcp const&, int const&, boost::system::error_code&) (stream_socket_service.hpp:138)
by 0x42D263: boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >::assign(boost::asio::ip::tcp const&, int const&, boost::system::error_code&) (basic_socket.hpp:285)
by 0x42CAD7: boost::asio::detail::reactive_socket_accept_op_base<boost::asio::basic_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::ip::tcp>::do_perform(boost::asio::detail::reactor_op*) (reactive_socket_accept_op.hpp:66)
by 0x409DE0: boost::asio::detail::reactor_op::perform() (reactor_op.hpp:40)
by 0x422C2F: boost::asio::detail::epoll_reactor::descriptor_state::perform_io(unsigned int) (epoll_reactor.ipp:622)
----------------------------------------------------------------
Thread #2: lock order "0x64C720 before 0x619E550" violated
Observed (incorrect) order is: acquisition of lock at 0x619E550
at 0x4C2C692: pthread_mutex_lock (hg_intercepts.c:495)
by 0x408545: boost::asio::detail::posix_mutex::lock() (posix_mutex.hpp:52)
by 0x40D9E1: boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>::scoped_lock(boost::asio::detail::posix_mutex&) (scoped_lock.hpp:36)
by 0x422BD3: boost::asio::detail::epoll_reactor::descriptor_state::perform_io(unsigned int) (epoll_reactor.ipp:611)
by 0x422D38: boost::asio::detail::epoll_reactor::descriptor_state::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long) (epoll_reactor.ipp:648)
by 0x409C69: boost::asio::detail::task_io_service_operation::complete(boost::asio::detail::task_io_service&, boost::system::error_code const&, unsigned long) (task_io_service_operation.hpp:37)
by 0x4236AD: boost::asio::detail::task_io_service::do_run_one(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&, boost::asio::detail::task_io_service_thread_info&, boost::system::error_code const&) (task_io_service.ipp:412)
by 0x423302: boost::asio::detail::task_io_service::run(boost::system::error_code&) (task_io_service.ipp:153)
by 0x42393A: boost::asio::io_service::run() (io_service.ipp:59)
by 0x42EB34: boost::_mfi::mf0<unsigned long, boost::asio::io_service>::operator()(boost::asio::io_service*) const (mem_fn_template.hpp:49)
by 0x42EA72: unsigned long boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> >::operator()<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list0>(boost::_bi::type<unsigned long>, boost::_mfi::mf0<unsigned long, boost::asio::io_service>&, boost::_bi::list0&, long) (bind.hpp:243)
by 0x42E91E: boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > >::operator()() (bind_template.hpp:20)
followed by a later acquisition of lock at 0x64C720
at 0x4C2C692: pthread_mutex_lock (hg_intercepts.c:495)
by 0x408845: boost::asio::detail::posix_static_mutex::lock() (posix_static_mutex.hpp:44)
by 0x40E523: boost::asio::detail::scoped_lock<boost::asio::detail::posix_static_mutex>::scoped_lock(boost::asio::detail::posix_static_mutex&) (scoped_lock.hpp:36)
by 0x424EE7: boost::asio::detail::signal_set_service::deliver_signal(int) (signal_set_service.ipp:431)
by 0x42477C: boost::asio::detail::signal_set_service::pipe_read_op::do_perform(boost::asio::detail::reactor_op*) (signal_set_service.ipp:95)
by 0x409DE0: boost::asio::detail::reactor_op::perform() (reactor_op.hpp:40)
by 0x422C2F: boost::asio::detail::epoll_reactor::descriptor_state::perform_io(unsigned int) (epoll_reactor.ipp:622)
by 0x422D38: boost::asio::detail::epoll_reactor::descriptor_state::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long) (epoll_reactor.ipp:648)
by 0x409C69: boost::asio::detail::task_io_service_operation::complete(boost::asio::detail::task_io_service&, boost::system::error_code const&, unsigned long) (task_io_service_operation.hpp:37)
by 0x4236AD: boost::asio::detail::task_io_service::do_run_one(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&, boost::asio::detail::task_io_service_thread_info&, boost::system::error_code const&) (task_io_service.ipp:412)
by 0x423302: boost::asio::detail::task_io_service::run(boost::system::error_code&) (task_io_service.ipp:153)
by 0x42393A: boost::asio::io_service::run() (io_service.ipp:59)
Required order was established by acquisition of lock at 0x64C720
at 0x4C2C692: pthread_mutex_lock (hg_intercepts.c:495)
by 0x408845: boost::asio::detail::posix_static_mutex::lock() (posix_static_mutex.hpp:44)
by 0x40E523: boost::asio::detail::scoped_lock<boost::asio::detail::posix_static_mutex>::scoped_lock(boost::asio::detail::posix_static_mutex&) (scoped_lock.hpp:36)
by 0x425060: boost::asio::detail::signal_set_service::add_service(boost::asio::detail::signal_set_service*) (signal_set_service.ipp:467)
by 0x4248BB: boost::asio::detail::signal_set_service::signal_set_service(boost::asio::io_service&) (signal_set_service.ipp:128)
by 0x42558B: boost::asio::signal_set_service::signal_set_service(boost::asio::io_service&) (signal_set_service.hpp:53)
by 0x42B628: boost::asio::io_service::service* boost::asio::detail::service_registry::create<boost::asio::signal_set_service>(boost::asio::io_service&) (service_registry.hpp:81)
by 0x408742: boost::asio::detail::service_registry::do_use_service(boost::asio::io_service::service::key const&, boost::asio::io_service::service* (*)(boost::asio::io_service&)) (service_registry.ipp:123)
by 0x42A92F: boost::asio::signal_set_service& boost::asio::detail::service_registry::use_service<boost::asio::signal_set_service>() (service_registry.hpp:48)
by 0x42984A: boost::asio::signal_set_service& boost::asio::use_service<boost::asio::signal_set_service>(boost::asio::io_service&) (io_service.hpp:33)
by 0x428633: boost::asio::basic_io_object<boost::asio::signal_set_service, false>::basic_io_object(boost::asio::io_service&) (basic_io_object.hpp:90)
by 0x42753A: boost::asio::basic_signal_set<boost::asio::signal_set_service>::basic_signal_set(boost::asio::io_service&) (basic_signal_set.hpp:106)
followed by a later acquisition of lock at 0x619E550
at 0x4C2C692: pthread_mutex_lock (hg_intercepts.c:495)
by 0x408545: boost::asio::detail::posix_mutex::lock() (posix_mutex.hpp:52)
by 0x40D9E1: boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>::scoped_lock(boost::asio::detail::posix_mutex&) (scoped_lock.hpp:36)
by 0x4224E4: boost::asio::detail::epoll_reactor::register_internal_descriptor(int, int, boost::asio::detail::epoll_reactor::descriptor_state*&, boost::asio::detail::reactor_op*) (epoll_reactor.ipp:179)
by 0x4250FC: boost::asio::detail::signal_set_service::add_service(boost::asio::detail::signal_set_service*) (signal_set_service.ipp:485)
by 0x4248BB: boost::asio::detail::signal_set_service::signal_set_service(boost::asio::io_service&) (signal_set_service.ipp:128)
by 0x42558B: boost::asio::signal_set_service::signal_set_service(boost::asio::io_service&) (signal_set_service.hpp:53)
by 0x42B628: boost::asio::io_service::service* boost::asio::detail::service_registry::create<boost::asio::signal_set_service>(boost::asio::io_service&) (service_registry.hpp:81)
by 0x408742: boost::asio::detail::service_registry::do_use_service(boost::asio::io_service::service::key const&, boost::asio::io_service::service* (*)(boost::asio::io_service&)) (service_registry.ipp:123)
by 0x42A92F: boost::asio::signal_set_service& boost::asio::detail::service_registry::use_service<boost::asio::signal_set_service>() (service_registry.hpp:48)
by 0x42984A: boost::asio::signal_set_service& boost::asio::use_service<boost::asio::signal_set_service>(boost::asio::io_service&) (io_service.hpp:33)
by 0x428633: boost::asio::basic_io_object<boost::asio::signal_set_service, false>::basic_io_object(boost::asio::io_service&) (basic_io_object.hpp:90)
----------------------------------------------------------------
Thread #1: lock order "0x619E550 before 0x64C720" violated
Observed (incorrect) order is: acquisition of lock at 0x64C720
at 0x4C2C692: pthread_mutex_lock (hg_intercepts.c:495)
by 0x408845: boost::asio::detail::posix_static_mutex::lock() (posix_static_mutex.hpp:44)
by 0x40E523: boost::asio::detail::scoped_lock<boost::asio::detail::posix_static_mutex>::scoped_lock(boost::asio::detail::posix_static_mutex&) (scoped_lock.hpp:36)
by 0x425166: boost::asio::detail::signal_set_service::remove_service(boost::asio::detail::signal_set_service*) (signal_set_service.ipp:492)
by 0x4248F0: boost::asio::detail::signal_set_service::shutdown_service() (signal_set_service.ipp:138)
by 0x42564D: boost::asio::signal_set_service::shutdown_service() (signal_set_service.hpp:110)
by 0x41AA69: boost::asio::detail::service_registry::~service_registry() (service_registry.ipp:37)
by 0x41AB32: boost::asio::io_service::~io_service() (io_service.ipp:53)
by 0x41B178: http::server3::server::~server() (in /root/server3/server3)
by 0x41A66A: main (main.cpp:37)
followed by a later acquisition of lock at 0x619E550
at 0x4C2C692: pthread_mutex_lock (hg_intercepts.c:495)
by 0x408545: boost::asio::detail::posix_mutex::lock() (posix_mutex.hpp:52)
by 0x40D9E1: boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>::scoped_lock(boost::asio::detail::posix_mutex&) (scoped_lock.hpp:36)
by 0x40AC3A: boost::asio::detail::epoll_reactor::deregister_descriptor(int, boost::asio::detail::epoll_reactor::descriptor_state*&, bool) (epoll_reactor.ipp:307)
by 0x4251BC: boost::asio::detail::signal_set_service::remove_service(boost::asio::detail::signal_set_service*) (signal_set_service.ipp:499)
by 0x4248F0: boost::asio::detail::signal_set_service::shutdown_service() (signal_set_service.ipp:138)
by 0x42564D: boost::asio::signal_set_service::shutdown_service() (signal_set_service.hpp:110)
by 0x41AA69: boost::asio::detail::service_registry::~service_registry() (service_registry.ipp:37)
by 0x41AB32: boost::asio::io_service::~io_service() (io_service.ipp:53)
by 0x41B178: http::server3::server::~server() (in /root/server3/server3)
by 0x41A66A: main (main.cpp:37)
Required order was established by acquisition of lock at 0x619E550
at 0x4C2C692: pthread_mutex_lock (hg_intercepts.c:495)
by 0x408545: boost::asio::detail::posix_mutex::lock() (posix_mutex.hpp:52)
by 0x40D9E1: boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>::scoped_lock(boost::asio::detail::posix_mutex&) (scoped_lock.hpp:36)
by 0x422BD3: boost::asio::detail::epoll_reactor::descriptor_state::perform_io(unsigned int) (epoll_reactor.ipp:611)
by 0x422D38: boost::asio::detail::epoll_reactor::descriptor_state::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long) (epoll_reactor.ipp:648)
by 0x409C69: boost::asio::detail::task_io_service_operation::complete(boost::asio::detail::task_io_service&, boost::system::error_code const&, unsigned long) (task_io_service_operation.hpp:37)
by 0x4236AD: boost::asio::detail::task_io_service::do_run_one(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&, boost::asio::detail::task_io_service_thread_info&, boost::system::error_code const&) (task_io_service.ipp:412)
by 0x423302: boost::asio::detail::task_io_service::run(boost::system::error_code&) (task_io_service.ipp:153)
by 0x42393A: boost::asio::io_service::run() (io_service.ipp:59)
by 0x42EB34: boost::_mfi::mf0<unsigned long, boost::asio::io_service>::operator()(boost::asio::io_service*) const (mem_fn_template.hpp:49)
by 0x42EA72: unsigned long boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> >::operator()<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list0>(boost::_bi::type<unsigned long>, boost::_mfi::mf0<unsigned long, boost::asio::io_service>&, boost::_bi::list0&, long) (bind.hpp:243)
by 0x42E91E: boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > >::operator()() (bind_template.hpp:20)
followed by a later acquisition of lock at 0x64C720
at 0x4C2C692: pthread_mutex_lock (hg_intercepts.c:495)
by 0x408845: boost::asio::detail::posix_static_mutex::lock() (posix_static_mutex.hpp:44)
by 0x40E523: boost::asio::detail::scoped_lock<boost::asio::detail::posix_static_mutex>::scoped_lock(boost::asio::detail::posix_static_mutex&) (scoped_lock.hpp:36)
by 0x424EE7: boost::asio::detail::signal_set_service::deliver_signal(int) (signal_set_service.ipp:431)
by 0x42477C: boost::asio::detail::signal_set_service::pipe_read_op::do_perform(boost::asio::detail::reactor_op*) (signal_set_service.ipp:95)
by 0x409DE0: boost::asio::detail::reactor_op::perform() (reactor_op.hpp:40)
by 0x422C2F: boost::asio::detail::epoll_reactor::descriptor_state::perform_io(unsigned int) (epoll_reactor.ipp:622)
by 0x422D38: boost::asio::detail::epoll_reactor::descriptor_state::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long) (epoll_reactor.ipp:648)
by 0x409C69: boost::asio::detail::task_io_service_operation::complete(boost::asio::detail::task_io_service&, boost::system::error_code const&, unsigned long) (task_io_service_operation.hpp:37)
by 0x4236AD: boost::asio::detail::task_io_service::do_run_one(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&, boost::asio::detail::task_io_service_thread_info&, boost::system::error_code const&) (task_io_service.ipp:412)
by 0x423302: boost::asio::detail::task_io_service::run(boost::system::error_code&) (task_io_service.ipp:153)
by 0x42393A: boost::asio::io_service::run() (io_service.ipp:59)
The HTTP Server 3 example uses a pool of threads. And while Valgrind is an immensely useful suite of programs, using it correctly requires a bit of tact. As the helgrind documentation states, it is best to start using helgrind early in a project. Throwing an existing multi-threaded program at helgrind is very likely to report many false positives in my experience. As an example, helgrind cannot always detect data races when using posix condition variables, this quote is from the helgrind documentation I linked previously
Avoid POSIX condition variables. If you can, use POSIX semaphores
(sem_t, sem_post, sem_wait) to do inter-thread event signalling.
Semaphores with an initial value of zero are particularly useful for
this.
It is possible this is the cause of the false positives you have cited. Both the Asio and Thread libraries use condition variables as part of their implementation. I very much doubt the possible data races or incorrect lock ordering is due to a bug in either library. It's worth quoting Jeff Atwood's First Rule of Programming here
An essential part of being a humble programmer is realizing that
whenever there's a problem with the code you've written, it's always
your fault. It is possible that a bug exists in the OS, the compiler,
or a third-party product -- but this should not be your first thought.
It is much more likely that the bug exists in the application code
under development.
I have this web view connected via IB in a garbage collected project. I can load a url perfectly fine in the web view one time, but then anytime after that one time it seems to crash randomly. I've got a couple different errors, a few specifically referencing garbage collection and saying EXC_BAD_ACCESS... the most recent and common though is this:
Thread 1, Queue : com.apple.main-thread
#0 0x00007fff8b4ffe90 in objc_msgSend ()
#1 0x00000004001ae2c0 in <????> ()
#2 0x00007fff97ab1313 in _NSURLConnectionDidReceiveData ()
#3 0x00007fff93e22388 in URLConnectionClient::_clientDidReceiveData(__CFArray const*, URLConnectionClient::ClientConnectionEventQueue*) ()
#4 0x00007fff93ed3c5b in URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) ()
#5 0x00007fff93dfeb49 in URLConnectionClient::processEvents() ()
#6 0x00007fff93dfe9ee in MultiplexerSource::perform() ()
#7 0x00007fff8fd666e1 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#8 0x00007fff8fd65f4d in __CFRunLoopDoSources0 ()
#9 0x00007fff8fd8cd39 in __CFRunLoopRun ()
#10 0x00007fff8fd8c676 in CFRunLoopRunSpecific ()
#11 0x00007fff97a54f9f in -[NSRunLoop(NSRunLoop) runMode:beforeDate:] ()
#12 0x00007fff954861a2 in WebCore::ResourceHandle::loadResourceSynchronously(WebCore::NetworkingContext*, WebCore::ResourceRequest const&, WebCore::StoredCredentials, WebCore::ResourceError&, WebCore::ResourceResponse&, WTF::Vector<char, 0ul>&) ()
#13 0x00007fff95485c1f in WebCore::FrameLoader::loadResourceSynchronously(WebCore::ResourceRequest const&, WebCore::StoredCredentials, WebCore::ResourceError&, WebCore::ResourceResponse&, WTF::Vector<char, 0ul>&) ()
#14 0x00007fff9548583b in WebCore::DocumentThreadableLoader::loadRequest(WebCore::ResourceRequest const&, WebCore::SecurityCheckPolicy) ()
#15 0x00007fff95485376 in WebCore::DocumentThreadableLoader::DocumentThreadableLoader(WebCore::Document*, WebCore::ThreadableLoaderClient*, WebCore::DocumentThreadableLoader::BlockingBehavior, WebCore::ResourceRequest const&, WebCore::ThreadableLoaderOptions const&, WTF::String const&) ()
#16 0x00007fff95485220 in WebCore::DocumentThreadableLoader::loadResourceSynchronously(WebCore::Document*, WebCore::ResourceRequest const&, WebCore::ThreadableLoaderClient&, WebCore::ThreadableLoaderOptions const&) ()
#17 0x00007fff95485076 in WebCore::XMLHttpRequest::createRequest(int&) ()
#18 0x00007fff95484d07 in WebCore::XMLHttpRequest::send(WTF::String const&, int&) ()
#19 0x00007fff95484807 in WebCore::XMLHttpRequest::send(int&) ()
#20 0x00007fff954844e7 in WebCore::JSXMLHttpRequest::send(JSC::ExecState*) ()
#21 0x00007fff95484432 in WebCore::jsXMLHttpRequestPrototypeFunctionSend(JSC::ExecState*) ()
#22 0x00004f57b12011e8 in <????> ()
#23 0x00007fff900b778b in JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::ScopeChainNode*, JSC::JSObject*) ()
#24 0x000000010c2e4da0 in <????> ()
#25 0x000000010a3f76a0 in <????> ()
#26 0x00007fff90286700 in JSC::JSFunction::~JSFunction() ()
#27 0x4810c08348eba9ab in <????> ()
I really don't know what to do. The crashing is sporadic and sometimes I can load the web view a few times before it crashes the app...
Also I've been getting this one a lot:
Thread 10, Queue : Garbage Collection Work Queue
#0 0x00007fff90168f6f in auto_fatal ()
#1 0x00007fff9017713b in Auto::Zone::handle_overretained_garbage(void*, int, int) ()
#2 0x00007fff90177844 in Auto::Zone::free_garbage(unsigned long, void**, unsigned long, void**, unsigned long&, unsigned long&) ()
#3 0x00007fff90164837 in auto_collect_internal(Auto::Zone*, unsigned int) ()
#4 0x00007fff9016021a in __auto_zone_collect_block_invoke_0 ()
#5 0x00007fff954098ba in _dispatch_call_block_and_release ()
#6 0x00007fff9540b10a in _dispatch_queue_drain ()
#7 0x00007fff9540af66 in _dispatch_queue_invoke ()
#8 0x00007fff9540a760 in _dispatch_worker_thread2 ()
#9 0x00007fff91adf3da in _pthread_wqthread ()
#10 0x00007fff91ae0b85 in start_wqthread ()