From 2ab427e287da694ecca537600f75b94839bf5e74 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Wed, 30 Jun 2021 12:48:50 -0700 Subject: [PATCH] Statically allocate messages used in js stack trace (#1678) --- src/core/error_handling.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/error_handling.c b/src/core/error_handling.c index 4022c470a..8abef29aa 100644 --- a/src/core/error_handling.c +++ b/src/core/error_handling.c @@ -219,6 +219,9 @@ pythonexc2js() hiwire_throw_error(jserror); } +char* error__js_funcname_string = ""; +char* error__js_filename_string = "???.js"; + EM_JS_NUM(errcode, error_handling_init_js, (), { Module.handle_js_error = function(e) { @@ -238,11 +241,9 @@ EM_JS_NUM(errcode, error_handling_init_js, (), { // Add a marker to the traceback to indicate that we passed through "native" // frames. // TODO? Use stacktracejs to add more detailed info here. - let funcname_ptr = stringToNewUTF8(""); - let filename_ptr = stringToNewUTF8("???.js"); - __PyTraceback_Add(funcname_ptr, filename_ptr, -1); - _free(funcname_ptr); - _free(filename_ptr); + __PyTraceback_Add(HEAPU32[_error__js_funcname_string / 4], + HEAPU32[_error__js_filename_string / 4], + -1); }; class PythonError extends Error {