Skip to content

Commit 55e3c59

Browse files
authored
[browser] dont trim fail fast message (#101056)
1 parent bfea872 commit 55e3c59

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

src/mono/browser/runtime/dotnet.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ declare interface EmscriptenModule {
3232
UTF8ToString(ptr: CharPtr, maxBytesToRead?: number): string;
3333
UTF8ArrayToString(u8Array: Uint8Array, idx?: number, maxBytesToRead?: number): string;
3434
stringToUTF8Array(str: string, heap: Uint8Array, outIdx: number, maxBytesToWrite: number): void;
35+
lengthBytesUTF8(str: string): number;
3536
FS_createPath(parent: string, path: string, canRead?: boolean, canWrite?: boolean): string;
3637
FS_createDataFile(parent: string, name: string, data: TypedArray, canRead: boolean, canWrite: boolean, canOwn?: boolean): string;
3738
addFunction(fn: Function, signature: string): number;

src/mono/browser/runtime/exports.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { jiterpreter_dump_stats } from "./jiterpreter";
2424
import { forceDisposeProxies } from "./gc-handles";
2525
import { mono_wasm_dump_threads } from "./pthreads";
2626

27+
import { threads_c_functions as tcwraps } from "./cwraps";
28+
2729
export let runtimeList: RuntimeList;
2830

2931
function initializeExports (globalObjects: GlobalObjects): RuntimeAPI {
@@ -43,6 +45,7 @@ function initializeExports (globalObjects: GlobalObjects): RuntimeAPI {
4345
};
4446
if (WasmEnableThreads) {
4547
rh.dumpThreads = mono_wasm_dump_threads;
48+
rh.mono_wasm_print_thread_dump = () => tcwraps.mono_wasm_print_thread_dump();
4649
}
4750
Object.assign(runtimeHelpers, rh);
4851

src/mono/browser/runtime/loader/exit.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ function onAbort (reason: any) {
6868
if (originalOnAbort) {
6969
originalOnAbort(reason || loaderHelpers.exitReason);
7070
}
71+
if (WasmEnableThreads && loaderHelpers.config?.dumpThreadsOnNonZeroExit && runtimeHelpers.mono_wasm_print_thread_dump && loaderHelpers.exitCode === undefined) {
72+
try {
73+
runtimeHelpers.mono_wasm_print_thread_dump();
74+
} catch (e) {
75+
// ignore
76+
}
77+
}
7178
mono_exit(1, reason || loaderHelpers.exitReason);
7279
}
7380

src/mono/browser/runtime/types/internal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ export type RuntimeHelpers = {
237237
jiterpreter_dump_stats?: (concise?: boolean) => void,
238238
forceDisposeProxies: (disposeMethods: boolean, verbose: boolean) => void,
239239
dumpThreads: () => void,
240+
mono_wasm_print_thread_dump: () => void,
240241
}
241242

242243
export type AOTProfilerOptions = {

src/mono/mono/eglib/glib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ const char * g_get_assertion_message (void);
759759
#define g_message(...) g_log_disabled (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __FILE__, __LINE__)
760760
#define g_debug(...) g_log_disabled (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FILE__, __LINE__)
761761
#endif
762+
#define g_warning_dont_trim(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, __VA_ARGS__)
762763

763764
typedef void (*GLogFunc) (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data);
764765
typedef void (*GPrintFunc) (const gchar *string);

src/mono/mono/metadata/icall.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6164,16 +6164,16 @@ void
61646164
ves_icall_System_Environment_FailFast (MonoStringHandle message, MonoExceptionHandle exception, MonoStringHandle errorSource, MonoError *error)
61656165
{
61666166
if (MONO_HANDLE_IS_NULL (errorSource)) {
6167-
g_warning ("Process terminated.");
6167+
g_warning_dont_trim ("Process terminated.");
61686168
} else {
61696169
char *errorSourceMsg = mono_string_handle_to_utf8 (errorSource, error);
6170-
g_warning ("Process terminated. %s", errorSourceMsg);
6170+
g_warning_dont_trim ("Process terminated. %s", errorSourceMsg);
61716171
g_free (errorSourceMsg);
61726172
}
61736173

61746174
if (!MONO_HANDLE_IS_NULL (message)) {
61756175
char *msg = mono_string_handle_to_utf8 (message, error);
6176-
g_warning (msg);
6176+
g_warning_dont_trim (msg);
61776177
g_free (msg);
61786178
}
61796179

0 commit comments

Comments
 (0)