mlachwani / google-breakpad

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

Breakpad doesn't allow safe use of dbghelp.dll #311

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

This is theoretical, but here's 2 use cases.

Case 1, breakpad colliding with user code using dbghelp.dll
  1. Write code that uses dbghelp.dll functions (eg SymFromAddr)
  2. Crash in the middle with breakpad catching the exception.

Case 2, breakpad colliding with itself:
  1. Create 2 threads,
  2. Crash them in quick succession with breakpad catching the exception 
twice.

The second case could happen fairly easily.  Imagine someone servicing a 
producer/consumer queue of short-tasks with threadpool.  Let the queue run 
out, and start handing out NULLs.  Let the threads have a broken null 
check.  Bang, lots of thread crashes in quick succession.

What is the expected output? What do you see instead?

I would expect that the API would allow for safe interaction with breakpad 
when using a system library like dbghelp.  I think this requires (a) 
creating a global lock for dbghelp.dll, (b) exposing it for clients of the 
breakpad library.

For this to happen, you would probably need to provide failure case 
semantics for breakpad if the lock cannot be acquired.  I think there are 3 
possibilities:

If lock held:
  a) breakpad ignores the lock and hopes for the best (current behavior, 
might as well not expose lock)
  b) breakpad becomes a no-op.  Don't generate a dump.
  c) breakpad becomes a no-op, but uploads something to the server saying 
that it failed due to lock contention (possibly with some info on which 
thread it is locked on???)

I think (c) is the best solution.

Both (b) and (c) are probably fairly easily implemented with a global lock 
that you try-enter on, and on failure, just no-op or upload a dummy-dump 
entry.

This methodology could also be extended to the multi-thread crashing issue, 
especially if there were a smart way to detect when it's another breakpad 
thread holding the lock.

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

Windows, no version since this is theoretical.

Please provide any additional information below.

None.

Original issue reported on code.google.com by ajw...@chromium.org on 14 Apr 2009 at 1:07