This implements the crash helper service used to move child process crash report generation out of the main process and into its own process. This is implemented as a separate executable that is launched on startup by the main process on the desktop platforms and as a service hosted by a separate process on Android. The crash helper process is started when the first exception handler is set on desktop platforms and before loading libxul on Android. In both cases starting this process happens asynchronously so that neither the main process nor child processes have to wait for it to come up. If a crash happens before the crash helper has started, the crashed process will wait for it to fully come up and then proceed with regular crash generation. IPC with the crash helper is implemented using Unix sockets on Linux and macOS with the former using sequential packets and the latter using stream sockets. On Windows we use named pipes. In all cases the choice of IPC was dictated both by the requirement to eventually talk directly to child processes from within the sandbox, and to external processes in case of Windows as the Windows Error Reporting exception handler must be able to reach out to the helper from within a restricted context. These particular requirements are not used yet but will be as we move more logic out of the main process logic. Differential Revision: https://phabricator.services.mozilla.com/D231083
168 lines
4.1 KiB
Rust
168 lines
4.1 KiB
Rust
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
extern crate geckoservo;
|
|
|
|
extern crate app_services_logger;
|
|
#[cfg(feature = "cubeb-remoting")]
|
|
extern crate audioipc2_client;
|
|
#[cfg(feature = "cubeb-remoting")]
|
|
extern crate audioipc2_server;
|
|
extern crate authrs_bridge;
|
|
#[cfg(feature = "bitsdownload")]
|
|
extern crate bitsdownload;
|
|
#[cfg(feature = "moz_places")]
|
|
extern crate bookmark_sync;
|
|
extern crate buildid_reader_ffi;
|
|
extern crate cascade_bloom_filter;
|
|
extern crate cert_storage;
|
|
extern crate chardetng_c;
|
|
extern crate cosec;
|
|
extern crate crypto_hash;
|
|
#[cfg(feature = "cubeb_coreaudio_rust")]
|
|
extern crate cubeb_coreaudio;
|
|
#[cfg(feature = "cubeb_pulse_rust")]
|
|
extern crate cubeb_pulse;
|
|
extern crate data_storage;
|
|
extern crate dom_fragmentdirectives;
|
|
extern crate encoding_glue;
|
|
extern crate fog_control;
|
|
extern crate gecko_profiler;
|
|
extern crate gkrust_utils;
|
|
extern crate http_sfv;
|
|
extern crate idna_glue;
|
|
extern crate ipdl_utils;
|
|
extern crate jog;
|
|
extern crate jsrust_shared;
|
|
extern crate kvstore;
|
|
extern crate mapped_hyph;
|
|
extern crate mozurl;
|
|
extern crate mp4parse_capi;
|
|
extern crate netwerk_helper;
|
|
extern crate nserror;
|
|
extern crate nsstring;
|
|
extern crate prefs_parser;
|
|
extern crate processtools;
|
|
#[cfg(feature = "gecko_profiler")]
|
|
extern crate profiler_helper;
|
|
extern crate rsdparsa_capi;
|
|
extern crate signature_cache;
|
|
extern crate static_prefs;
|
|
extern crate storage;
|
|
extern crate webrender_bindings;
|
|
extern crate xpcom;
|
|
|
|
extern crate audio_thread_priority;
|
|
|
|
#[cfg(not(target_os = "android"))]
|
|
extern crate webext_storage;
|
|
|
|
#[cfg(feature = "webrtc")]
|
|
extern crate mdns_service;
|
|
extern crate neqo_glue;
|
|
extern crate wgpu_bindings;
|
|
|
|
extern crate aa_stroke;
|
|
extern crate qcms;
|
|
extern crate wpf_gpu_raster;
|
|
|
|
extern crate unic_langid;
|
|
extern crate unic_langid_ffi;
|
|
|
|
extern crate fluent_langneg;
|
|
extern crate fluent_langneg_ffi;
|
|
|
|
extern crate fluent;
|
|
extern crate fluent_ffi;
|
|
|
|
extern crate oxilangtag_ffi;
|
|
extern crate unicode_bidi_ffi;
|
|
|
|
extern crate rure;
|
|
|
|
extern crate fluent_fallback;
|
|
extern crate l10nregistry_ffi;
|
|
extern crate localization_ffi;
|
|
|
|
extern crate ipcclientcerts;
|
|
extern crate trust_anchors;
|
|
|
|
#[cfg(any(
|
|
target_os = "android",
|
|
target_os = "macos",
|
|
target_os = "ios",
|
|
all(target_os = "windows", not(target_arch = "aarch64"))
|
|
))]
|
|
extern crate osclientcerts;
|
|
|
|
#[cfg(not(target_os = "android"))]
|
|
extern crate gkrust_uniffi_components;
|
|
|
|
#[cfg(feature = "uniffi_fixtures")]
|
|
extern crate gkrust_uniffi_fixtures;
|
|
|
|
#[cfg(not(target_os = "android"))]
|
|
extern crate viaduct;
|
|
|
|
extern crate gecko_logger;
|
|
|
|
#[cfg(feature = "oxidized_breakpad")]
|
|
extern crate rust_minidump_writer_linux;
|
|
|
|
#[cfg(feature = "crashreporter")]
|
|
extern crate mozannotation_client;
|
|
|
|
#[cfg(feature = "crashreporter")]
|
|
extern crate crash_helper_client;
|
|
|
|
#[cfg(feature = "webmidi_midir_impl")]
|
|
extern crate midir_impl;
|
|
|
|
#[cfg(target_os = "windows")]
|
|
extern crate detect_win32k_conflicts;
|
|
|
|
extern crate origin_trials_ffi;
|
|
|
|
extern crate dap_ffi;
|
|
|
|
extern crate data_encoding_ffi;
|
|
|
|
extern crate binary_http;
|
|
extern crate mls_gk;
|
|
extern crate oblivious_http;
|
|
|
|
extern crate mime_guess_ffi;
|
|
|
|
#[cfg(feature = "libz-rs-sys")]
|
|
extern crate libz_rs_sys;
|
|
|
|
extern crate log;
|
|
use log::info;
|
|
|
|
use std::{ffi::CStr, os::raw::c_char};
|
|
|
|
use gecko_logger::GeckoLogger;
|
|
|
|
#[no_mangle]
|
|
pub extern "C" fn GkRust_Init() {
|
|
// Initialize logging.
|
|
let _ = GeckoLogger::init();
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub extern "C" fn GkRust_Shutdown() {}
|
|
|
|
/// Used to implement `nsIDebug2::RustPanic` for testing purposes.
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn intentional_panic(message: *const c_char) {
|
|
panic!("{}", CStr::from_ptr(message).to_string_lossy());
|
|
}
|
|
|
|
/// Used to implement `nsIDebug2::rustLog` for testing purposes.
|
|
#[no_mangle]
|
|
pub unsafe extern "C" fn debug_log(target: *const c_char, message: *const c_char) {
|
|
// NOTE: The `info!` log macro is used here because we have the `release_max_level_info` feature set.
|
|
info!(target: CStr::from_ptr(target).to_str().unwrap(), "{}", CStr::from_ptr(message).to_str().unwrap());
|
|
}
|