jsiicckk / google-breakpad

Automatically exported from code.google.com/p/google-breakpad
0 stars 0 forks source link

Breakpad won't create crash report for multi-threaded application on embedded Linux #495

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a test application, like the example from the Wiki, but also create 
some threads.
2. Run it on a non-standard Linux distribution.

What is the expected output? What do you see instead?
If I run the same test application on my Ubuntu 12.04 system, I get a full 
minidump of all running threads. 

When I run it on my custom embedded Linux target, the dumpCallback function is 
passed "bool succeeded = false".

The minidump file is written but it is incomplete.

If I remove the threads from my test application then it works normally. i.e. I 
get a full mini dump on my embedded Linux target.

What version of the product are you using? On what operating system?

Breakpad version 0.1. 
Custom operating system: Linux 3.3.8, x86 CPU. Breakpad enabled application was 
built for target i486-unknown-linux-gnu with gcc 4.4.6 and glibc 2.9.

Please provide any additional information below.

I recently had a problem with gdb where I could not debug threads. It turned 
out that it was because I had built a static gdb and therefore thread_db was 
not able to load symbols from the gdb application. I'm not sure if that's the 
same problem that is occurring here. Can I built Breakpad in debug mode so I 
can see *why* it is failing to create the minidump?

Original issue reported on code.google.com by aras.vai...@gmail.com on 11 Sep 2012 at 1:06

GoogleCodeExporter commented 9 years ago
Just to add:
I build the application like so:
$ /opt/br/output/host/usr/bin/i486-unknown-linux-gnu-g++ mytest.cpp -g -I. 
client/linux/libbreakpad_client.a -lrt -lpthread -o mytest

I can run the *same* mytest binary on Ubuntu 12.04, it works.
If I run mytest on my custom Linux, it fails.

e.g. Ubuntu:
$ ./mytest 
dump path: ./203067e6-2feb-e836-2d7f49cd-68352f3e.dmp
dump succeeded
Segmentation fault (core dumped)

* Custom Linux
$ ./mytest
dump path: ./12451f9f-2602-6ff5-35ed760a-57787be1.dmp
dump failed
Segmentation fault

The problem has to be some run time difference if the same application can 
perform differently.

Does Breakpad require something special in the standard libraries to debug 
threads?

Original comment by aras.vai...@gmail.com on 11 Sep 2012 at 1:23

GoogleCodeExporter commented 9 years ago
I've traced the application as much as I can. It appears that the problem is 
caused by the ThreadEntry function returning non-zero to GenerateDump via the 
sys_waitpid() call.

If anyone is reading this ... I will keep tracing ...

Original comment by aras.vai...@gmail.com on 12 Sep 2012 at 9:32

GoogleCodeExporter commented 9 years ago
This code in src/client/linux/minidump_writer/linux_ptrace_dumper.cc:

#if defined(__i386)
  if (sys_ptrace(PTRACE_GETFPXREGS, tid, NULL, &info->fpxregs) == -1)
    {
    perror("sys_ptrace");
    printf( "sys_prtrace PTRACE_GETFPXREGS in LinuxPtraceDumper::GetThreadInfoByIndex\n" );
//    return false;
    }
#endif

Will cause the entire minidump to fail on pre-Pentium III CPUs that do not 
contain these register.

For example, the Vortex86DX embedded x86 microcontroller does not support these 
registers and it is commonly used in many industrial processor boards. 

I will post a patch.

Original comment by aras.vai...@gmail.com on 12 Sep 2012 at 12:49

GoogleCodeExporter commented 9 years ago
Glad to see you found the root cause of your problem. Please attach patches by 
creating a new issue here: https://breakpad.appspot.com/

Original comment by ted.mielczarek on 12 Sep 2012 at 1:00

GoogleCodeExporter commented 9 years ago
I've faced with this problem.

I tested this patch on my Vortex86DX and it worked fine for me. The problem was 
that Vortex86DX doesn't have MMX registers so their state cannot be obtained 
and we shouldn't try to do that.

Patch is very simple, could anybody finally make a review and apply it?

Original comment by alexande...@gmail.com on 26 Nov 2013 at 8:52

GoogleCodeExporter commented 9 years ago
Sure, will do.

Original comment by thestig@chromium.org on 26 Nov 2013 at 8:58

GoogleCodeExporter commented 9 years ago
Maybe this link will be helpful too: 
http://stackoverflow.com/questions/12299333/breakpad-fails-to-create-minidump-on
-target-when-i-use-threads

Link to patch is posted in one of the comments: 
https://breakpad.appspot.com/455002/

Original comment by alexande...@gmail.com on 26 Nov 2013 at 9:44

GoogleCodeExporter commented 9 years ago
AFAICT I was ready to land that patch, I just couldn't find out if the author 
had a CLA on file with Google.

Original comment by ted.mielczarek on 26 Nov 2013 at 10:51

GoogleCodeExporter commented 9 years ago
Un-owning since there's already a patch out there from the original bug 
reporter.

Original comment by thestig@chromium.org on 26 Nov 2013 at 11:51

GoogleCodeExporter commented 9 years ago
https://code.google.com/p/google-breakpad/source/detail?r=1248

Original comment by thestig@chromium.org on 9 Dec 2013 at 8:23