Skip to content

Commit 2cf2cd2

Browse files
committed
Crash on fatal exit so that the crash logger can catch the failure.
1 parent cd36ace commit 2cf2cd2

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
diff --git a/rtc_base/checks.cc b/rtc_base/checks.cc
2+
index e732a2659d..29baf495e4 100644
3+
--- a/rtc_base/checks.cc
4+
+++ b/rtc_base/checks.cc
5+
@@ -69,13 +69,22 @@ RTC_NORETURN void WriteFatalLog(absl::string_view output) {
6+
__android_log_print(ANDROID_LOG_ERROR, RTC_LOG_TAG_ANDROID, "%s\n",
7+
output_str.c_str());
8+
#endif
9+
+ // write to stdout so that it ends up in the logs.
10+
+ fwrite(output.data(), output.size(), 1, stdout);
11+
fflush(stdout);
12+
fwrite(output.data(), output.size(), 1, stderr);
13+
fflush(stderr);
14+
#if defined(WEBRTC_WIN)
15+
- DebugBreak();
16+
+// DebugBreak();
17+
#endif
18+
- abort();
19+
+ // force a crash so that the crash logger can capture the exception.
20+
+ long* null_ptr;
21+
+ null_ptr = 0;
22+
+ *null_ptr = 0xDEADBEEF;
23+
+ while (true)
24+
+ {
25+
+ _sleep(1);
26+
+ }
27+
}
28+
29+
RTC_NORETURN void WriteFatalLog(const char* file,

build/run.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def get_depot_tools(source_dir, fetch=False):
187187
'bug_8759_workaround.patch',
188188
'msvc-checks-template.patch',
189189
'disable_mute_of_audio_processing.patch',
190+
'crash_on_fatal_error.patch',
190191
],
191192
'windows_x86': [
192193
'add_license_dav1d.patch',
@@ -198,6 +199,7 @@ def get_depot_tools(source_dir, fetch=False):
198199
'bug_8759_workaround.patch',
199200
'msvc-checks-template.patch',
200201
'disable_mute_of_audio_processing.patch',
202+
'crash_on_fatal_error.patch',
201203
],
202204
'windows_arm64': [
203205
'add_license_dav1d.patch',
@@ -209,6 +211,7 @@ def get_depot_tools(source_dir, fetch=False):
209211
'bug_8759_workaround.patch',
210212
'msvc-checks-template.patch'
211213
'disable_mute_of_audio_processing.patch',
214+
'crash_on_fatal_error.patch',
212215
],
213216
'macos_x86_64': [
214217
'add_license_dav1d.patch',
@@ -217,6 +220,7 @@ def get_depot_tools(source_dir, fetch=False):
217220
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
218221
'bug_8759_workaround.patch',
219222
'disable_mute_of_audio_processing.patch',
223+
'crash_on_fatal_error.patch',
220224
],
221225
'macos_arm64': [
222226
'add_license_dav1d.patch',
@@ -225,6 +229,7 @@ def get_depot_tools(source_dir, fetch=False):
225229
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
226230
'bug_8759_workaround.patch',
227231
'disable_mute_of_audio_processing.patch',
232+
'crash_on_fatal_error.patch',
228233
],
229234
'ios': [
230235
'add_license_dav1d.patch',
@@ -233,6 +238,7 @@ def get_depot_tools(source_dir, fetch=False):
233238
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
234239
'bug_8759_workaround.patch',
235240
'disable_mute_of_audio_processing.patch',
241+
'crash_on_fatal_error.patch',
236242
],
237243
'android': [
238244
'add_license_dav1d.patch',
@@ -241,69 +247,79 @@ def get_depot_tools(source_dir, fetch=False):
241247
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
242248
'bug_8759_workaround.patch',
243249
'disable_mute_of_audio_processing.patch',
250+
'crash_on_fatal_error.patch',
244251
],
245252
'android_prefixed': [
246253
'add_license_dav1d.patch',
247254
'android_webrtc_version.patch',
248255
'fix_mocks.patch',
249256
'jni_prefix.patch',
250257
'disable_mute_of_audio_processing.patch',
258+
'crash_on_fatal_error.patch',
251259
],
252260
'raspberry-pi-os_armv6': [
253261
'add_license_dav1d.patch',
254262
'fix_mocks.patch',
255263
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
256264
'bug_8759_workaround.patch',
257265
'disable_mute_of_audio_processing.patch',
266+
'crash_on_fatal_error.patch',
258267
],
259268
'raspberry-pi-os_armv7': [
260269
'add_license_dav1d.patch',
261270
'fix_mocks.patch',
262271
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
263272
'bug_8759_workaround.patch',
264273
'disable_mute_of_audio_processing.patch',
274+
'crash_on_fatal_error.patch',
265275
],
266276
'raspberry-pi-os_armv8': [
267277
'add_license_dav1d.patch',
268278
'fix_mocks.patch',
269279
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
270280
'bug_8759_workaround.patch',
271281
'disable_mute_of_audio_processing.patch',
282+
'crash_on_fatal_error.patch',
272283
],
273284
'ubuntu-18.04_armv8': [
274285
'add_license_dav1d.patch',
275286
'fix_mocks.patch',
276287
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
277288
'bug_8759_workaround.patch',
278289
'disable_mute_of_audio_processing.patch',
290+
'crash_on_fatal_error.patch',
279291
],
280292
'ubuntu-20.04_armv8': [
281293
'add_license_dav1d.patch',
282294
'fix_mocks.patch',
283295
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
284296
'bug_8759_workaround.patch',
285297
'disable_mute_of_audio_processing.patch',
298+
'crash_on_fatal_error.patch',
286299
],
287300
'ubuntu-18.04_x86_64': [
288301
'add_license_dav1d.patch',
289302
'fix_mocks.patch',
290303
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
291304
'bug_8759_workaround.patch',
292305
'disable_mute_of_audio_processing.patch',
306+
'crash_on_fatal_error.patch',
293307
],
294308
'ubuntu-20.04_x86_64': [
295309
'add_license_dav1d.patch',
296310
'fix_mocks.patch',
297311
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
298312
'bug_8759_workaround.patch',
299313
'disable_mute_of_audio_processing.patch',
314+
'crash_on_fatal_error.patch',
300315
],
301316
'ubuntu-22.04_x86_64': [
302317
'add_license_dav1d.patch',
303318
'fix_mocks.patch',
304319
'upsample-to-48khz-for-echo-cancellation-for-now.patch',
305320
'bug_8759_workaround.patch',
306321
'disable_mute_of_audio_processing.patch',
322+
'crash_on_fatal_error.patch',
307323
],
308324
}
309325

0 commit comments

Comments
 (0)