Breakpad does not catch crash in QThread

62 views
Skip to first unread message

Kristian Karl

unread,
Mar 5, 2011, 7:21:07 AM3/5/11
to google-breakpad-dev
Hi,

I have following code:

============== crasch.cpp ======================
#include <QThread>
#include "client/linux/handler/exception_handler.h"

class MyThread : public QThread {
public:
virtual void run();
void crash();
};

void MyThread::run() {
crash();
}

void MyThread::crash() {
volatile int* a = (int*)(NULL);
*a = 1;
}

static bool dumpCallback(const char* dump_path, const char*
minidump_id, void*, bool succeeded) {
if (succeeded) {
printf("Dump path: %s/%s.dmp\n", dump_path, minidump_id);
} else {
printf("Failed to write crash dump\n");
}
return succeeded;
}

int main(int, char **){
google_breakpad::ExceptionHandler eh("/tmp", NULL, dumpCallback,
NULL, true);
MyThread a;
a.start();
return 0;
}
============== end of crasch.cpp ======================

============== crasch.pro ======================
TEMPLATE = app
SOURCES = crash.cpp
CONFIG += console
INCLUDEPATH += /home/krikar/Tools/google-breakpad/trunk/src
============== end of crasch.pro ======================

Now when I build an run the code:
krikar@krikar-desktop:~/foo$ qmake crash.pro
krikar@krikar-desktop:~/foo$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -
DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/
include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I../
Tools/google-breakpad/trunk/src -I. -o crash.o crash.cpp
g++ -Wl,-O1 -o crash crash.o -L/usr/lib -lbreakpad_client -lQtGui -
lQtCore -lpthread
krikar@krikar-desktop:~/foo$ ./crash
QThread: Destroyed while thread is still running
krikar@krikar-desktop:~/foo$

Google breakpad does not catch the crash. Why? I have similar problmes
in other QThread apps, where breakpad actually catches a crash in a
thread, but writes empty minidump files.

Kristian Karl

unread,
Mar 6, 2011, 12:08:54 PM3/6/11
to google-breakpad-dev
And I forgot to tell you, that I ran this on a 64-bit ubuntu using
libqt4-dev 4.7.0 with svn r774 from breakpad.
/Kristian

Jimmy Bahuleyan

unread,
Mar 7, 2011, 6:06:37 AM3/7/11
to google-br...@googlegroups.com

There is nothing wrong with breakpad here. You must stop your
application from exiting before the child thread gets a chance to
execute. Try adding a.wait() below a.start()

-jb

Kristian Karl

unread,
Mar 7, 2011, 10:20:45 AM3/7/11
to google-breakpad-dev
> There is nothing wrong with breakpad here. You must stop your
> application from exiting before the child thread gets a chance to
> execute. Try adding a.wait() below a.start()
>
> -jb

You're absolutely right! I forgot a.wait(); But when I run the updated
version below, I get:
Failed to write crash dump
Segmentation fault

And in the /tmp folder, there is an empty dump file:

ls -ltr /tmp/
-rw------- 1 krikar krikar 0 2011-03-07 14:51
6b99e91c-7b50-65d5-67ad3454-7860368c.dmp



============== crasch.cpp ======================
#include <QThread>
#include "client/linux/handler/exception_handler.h"

class MyThread : public QThread {
public:
virtual void run();
void crash();
};

void MyThread::run() {
crash();
}

void MyThread::crash() {
volatile int* a = (int*)(NULL);
*a = 1;
}

static bool dumpCallback(const char* dump_path, const char*
minidump_id, void*, bool succeeded) {
if (succeeded) {
printf("Dump path: %s/%s.dmp\n", dump_path, minidump_id);
} else {
printf("Failed to write crash dump\n");
}
return succeeded;
}

int main(int, char **){
google_breakpad::ExceptionHandler eh("/tmp", NULL, dumpCallback,
NULL, true);
MyThread a;
a.start();
a.wait();
return 0;
}
============== end of crasch.cpp ======================

============== crasch.pro ======================
TEMPLATE = app
SOURCES = crash.cpp
CONFIG += console
INCLUDEPATH += /home/krikar/Tools/breakpad/trunk/src
LIBS += -L/usr/local/lib -lbreakpad_client

Kristian Karl

unread,
Mar 7, 2011, 11:39:48 AM3/7/11
to google-breakpad-dev
Running with elevated privileges helps.
sudo ./crash
Dump path: /tmp/3d24d02e-add3-bfba-7fc4513e-474f4124.dmp
Segmentation fault

I found this:
http://groups.google.com/group/google-breakpad-dev/browse_thread/thread/38091af0d8695a5/fa0fe29bb3fc42e9?lnk=gst&q=ptrace#fa0fe29bb3fc42e9

I'm running Ubuntu 10.10
uname -r => 2.6.35-28-generic


On Mar 7, 4:20 pm, Kristian Karl <kristian.hermann.k...@gmail.com>
wrote:

Ted Mielczarek

unread,
Mar 7, 2011, 12:16:20 PM3/7/11
to google-br...@googlegroups.com, Kristian Karl, chris....@canonical.com
On Mon, Mar 7, 2011 at 11:39 AM, Kristian Karl
<kristian.h...@gmail.com> wrote:
> Running with elevated privileges helps.
>  sudo ./crash
>  Dump path: /tmp/3d24d02e-add3-bfba-7fc4513e-474f4124.dmp
>  Segmentation fault
>
> I found this:
> http://groups.google.com/group/google-breakpad-dev/browse_thread/thread/38091af0d8695a5/fa0fe29bb3fc42e9?lnk=gst&q=ptrace#fa0fe29bb3fc42e9
>
> I'm running Ubuntu 10.10
> uname -r => 2.6.35-28-generic

Those changes landed a while back:
http://code.google.com/p/google-breakpad/source/detail?r=673

CCing Chris Coulson, who wrote the patch. AFAIK things should work on
Ubuntu 10.10.

-Ted

Kristian Karl

unread,
Mar 7, 2011, 4:30:49 PM3/7/11
to google-breakpad-dev, chris....@canonical.com
Actually may be a bug in ubuntu
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/729839
/Kristian

Chris Coulson

unread,
Mar 7, 2011, 4:48:50 PM3/7/11
to Kristian Karl, google-breakpad-dev

(Trying a second time - my first mail got rejected).

Quite possibly. I know that Breakpad does not work from Chrome on Ubuntu
at the moment, although it does work for Firefox. At some point this
week I'll be investigating that, but the bug report you've pointed out
might be a good starting point for me.

Regards
Chris

Lei Zhang

unread,
Mar 7, 2011, 7:11:06 PM3/7/11
to google-br...@googlegroups.com, Chris Coulson, Kristian Karl

On Maverick, Chromium has problems with dumping renderer crashes when
the renderer is sandboxed. There's no problem with dumping browser
crashes. This is http://crbug.com/56730.

Reply all
Reply to author
Forward
0 new messages