Closed Bug 1337051 Opened 4 years ago Closed 4 years ago

Add a test to make sure that we crash properly on uncaught exceptions

Categories

(Toolkit :: Crash Reporting, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla54
Tracking Status
firefox54 --- fixed

People

(Reporter: mconley, Assigned: mconley)

References

Details

Attachments

(1 file)

Bug 1333223 added a generic exception handler that allows us to crash properly for uncaught exceptions thrown by third-party libaries. We should add a test for that case.
Assignee: nobody → mconley
Status: NEW → ASSIGNED
Canceling review because my try build looks fishy.

Hey ted, on Linux, with the above patch, I'm getting:

[task 2017-02-06T18:30:41.884391Z] 18:30:41     INFO -  # 75 "/home/worker/workspace/build/src/obj-firefox/toolkit/crashreporter/test/Unified_cpp_crashreporter_test0.cpp" 2
[task 2017-02-06T18:30:41.884545Z] 18:30:41     INFO -  In file included from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.h:46:0,
[task 2017-02-06T18:30:41.884653Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.cc:37,
[task 2017-02-06T18:30:41.884791Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/toolkit/crashreporter/test/Unified_cpp_crashreporter_test0.cpp:2:
[task 2017-02-06T18:30:41.884904Z] 18:30:41     INFO -  /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/vector:14:4: error: #error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.885024Z] 18:30:41     INFO -   #  error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.885126Z] 18:30:41     INFO -      ^
[task 2017-02-06T18:30:41.885267Z] 18:30:41     INFO -  In file included from /home/worker/workspace/build/src/gcc/include/c++/4.9.4/bits/move.h:57:0,
[task 2017-02-06T18:30:41.885392Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/gcc/include/c++/4.9.4/bits/stl_pair.h:59,
[task 2017-02-06T18:30:41.885515Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/gcc/include/c++/4.9.4/bits/stl_algobase.h:64,
[task 2017-02-06T18:30:41.885635Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/gcc/include/c++/4.9.4/vector:60,
[task 2017-02-06T18:30:41.885773Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/dist/system_wrappers/vector:3,
[task 2017-02-06T18:30:41.885884Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/vector:44,
[task 2017-02-06T18:30:41.886061Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.h:46,
[task 2017-02-06T18:30:41.886193Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.cc:37,
[task 2017-02-06T18:30:41.886318Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/toolkit/crashreporter/test/Unified_cpp_crashreporter_test0.cpp:2:
[task 2017-02-06T18:30:41.886440Z] 18:30:41     INFO -  /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/type_traits:14:4: error: #error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.886548Z] 18:30:41     INFO -   #  error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.886662Z] 18:30:41     INFO -      ^
[task 2017-02-06T18:30:41.886804Z] 18:30:41     INFO -  In file included from /home/worker/workspace/build/src/gcc/include/c++/4.9.4/ext/new_allocator.h:33:0,
[task 2017-02-06T18:30:41.886932Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/gcc/include/c++/4.9.4/x86_64-unknown-linux-gnu/bits/c++allocator.h:33,
[task 2017-02-06T18:30:41.887065Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/gcc/include/c++/4.9.4/bits/allocator.h:46,
[task 2017-02-06T18:30:41.887180Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/gcc/include/c++/4.9.4/vector:61,
[task 2017-02-06T18:30:41.887326Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/dist/system_wrappers/vector:3,
[task 2017-02-06T18:30:41.887451Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/vector:44,
[task 2017-02-06T18:30:41.887582Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.h:46,
[task 2017-02-06T18:30:41.887709Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.cc:37,
[task 2017-02-06T18:30:41.887834Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/toolkit/crashreporter/test/Unified_cpp_crashreporter_test0.cpp:2:
[task 2017-02-06T18:30:41.887974Z] 18:30:41     INFO -  /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/new:14:4: error: #error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.888071Z] 18:30:41     INFO -   #  error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.888211Z] 18:30:41     INFO -      ^
[task 2017-02-06T18:30:41.888354Z] 18:30:41     INFO -  In file included from /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/mozalloc.h:21:0,
[task 2017-02-06T18:30:41.888478Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/vector:52,
[task 2017-02-06T18:30:41.888626Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.h:46,
[task 2017-02-06T18:30:41.888749Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.cc:37,
[task 2017-02-06T18:30:41.888869Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/toolkit/crashreporter/test/Unified_cpp_crashreporter_test0.cpp:2:
[task 2017-02-06T18:30:41.888996Z] 18:30:41     INFO -  /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/cstdlib:14:4: error: #error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.889115Z] 18:30:41     INFO -   #  error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.889219Z] 18:30:41     INFO -      ^
[task 2017-02-06T18:30:41.889362Z] 18:30:41     INFO -  In file included from /home/worker/workspace/build/src/obj-firefox/dist/include/mozilla/mozalloc.h:22:0,
[task 2017-02-06T18:30:41.889483Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/vector:52,
[task 2017-02-06T18:30:41.889614Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.h:46,
[task 2017-02-06T18:30:41.889743Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.cc:37,
[task 2017-02-06T18:30:41.889862Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/toolkit/crashreporter/test/Unified_cpp_crashreporter_test0.cpp:2:
[task 2017-02-06T18:30:41.889998Z] 18:30:41     INFO -  /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/cstring:14:4: error: #error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.890102Z] 18:30:41     INFO -   #  error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.890215Z] 18:30:41     INFO -      ^
[task 2017-02-06T18:30:41.890363Z] 18:30:41     INFO -  In file included from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/range_map.h:44:0,
[task 2017-02-06T18:30:41.890488Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.h:50,
[task 2017-02-06T18:30:41.890611Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.cc:37,
[task 2017-02-06T18:30:41.890734Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/toolkit/crashreporter/test/Unified_cpp_crashreporter_test0.cpp:2:
[task 2017-02-06T18:30:41.890860Z] 18:30:41     INFO -  /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/map:14:4: error: #error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.891011Z] 18:30:41     INFO -   #  error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.891126Z] 18:30:41     INFO -      ^
[task 2017-02-06T18:30:41.891270Z] 18:30:41     INFO -  In file included from /home/worker/workspace/build/src/gcc/include/c++/4.9.4/bits/stl_map.h:63:0,
[task 2017-02-06T18:30:41.891391Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/gcc/include/c++/4.9.4/map:61,
[task 2017-02-06T18:30:41.891518Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/dist/system_wrappers/map:3,
[task 2017-02-06T18:30:41.891640Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/map:44,
[task 2017-02-06T18:30:41.891771Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/range_map.h:44,
[task 2017-02-06T18:30:41.891897Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.h:50,
[task 2017-02-06T18:30:41.892024Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/toolkit/crashreporter/google-breakpad/src/processor/basic_code_modules.cc:37,
[task 2017-02-06T18:30:41.892163Z] 18:30:41     INFO -                   from /home/worker/workspace/build/src/obj-firefox/toolkit/crashreporter/test/Unified_cpp_crashreporter_test0.cpp:2:
[task 2017-02-06T18:30:41.892300Z] 18:30:41     INFO -  /home/worker/workspace/build/src/obj-firefox/dist/stl_wrappers/tuple:14:4: error: #error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.892412Z] 18:30:41     INFO -   #  error "STL code can only be used with -fno-exceptions"
[task 2017-02-06T18:30:41.892530Z] 18:30:41     INFO -      ^

This is probably because I enabled -fcxx-exceptions on CXX_FLAGS so that I could use throw within nsTestCrasher.cpp. My moz.build-fu isn't amazing - but did I accidentally set -fcxx-exceptions true for all binary builds? If so, do you know how I can just set it to true for the testcrasher library?
Flags: needinfo?(ted)
You did only enable it for the testcrasher lib, but nsTestCrasher.cpp includes a bunch of headers and it looks like the Breakpad headers we include (so we can read minidumps for testing) wind up including the STL headers and you get screwed. This is what I was thinking of when I said "it might be a pain to actually raise a C++ exception since we disable exceptions by default" in the other bug.
Flags: needinfo?(ted)
Hm. Is it possible to link a separate object file into the testcrasher lib that was compiled with exceptions allowed?
Flags: needinfo?(ted)
Comment on attachment 8834058 [details]
Bug 1337051 - Test that we crash properly when exceptions thrown by third-party libraries aren't caught.

https://reviewboard.mozilla.org/r/110150/#review114602

Looks good, thanks for taking the time to write a useful test!

::: toolkit/crashreporter/test/moz.build:32
(Diff revision 4)
> +if CONFIG['CLANG_CL']:
> +    SOURCES['ExceptionThrower.cpp'].flags += [
> +        '-Xclang',
> +        '-fcxx-exceptions',
> +    ]
> +elif not CONFIG['_MSC_VER']:

Do you need to handle the MSVC case here, or does it work even though we're building without exceptions?
Attachment #8834058 - Flags: review?(ted) → review+
Flags: needinfo?(ted)
Comment on attachment 8834058 [details]
Bug 1337051 - Test that we crash properly when exceptions thrown by third-party libraries aren't caught.

https://reviewboard.mozilla.org/r/110150/#review114602

> Do you need to handle the MSVC case here, or does it work even though we're building without exceptions?

Full disclosure: no idea. Was fully cargo-culting from [this](http://searchfox.org/mozilla-central/rev/cac6cb6a10afb8ebb2ecfbeeedaff7c66f57dd75/toolkit/crashreporter/jsoncpp/src/lib_json/moz.build#19-28). How would I find out whether or not this condition is necessary?
ni? for comment 9.
Flags: needinfo?(ted)
If you pushed to try and the tests passed on Windows it should be fine.
Flags: needinfo?(ted)
(In reply to Ted Mielczarek [:ted.mielczarek] from comment #11)
> If you pushed to try and the tests passed on Windows it should be fine.

Cool - yeah, got an all-green here: https://treeherder.mozilla.org/#/jobs?repo=try&revision=160ec23f1a89
Pushed by mconley@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ea59e2cff30b
Test that we crash properly when exceptions thrown by third-party libraries aren't caught. r=ted
https://hg.mozilla.org/mozilla-central/rev/ea59e2cff30b
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.