@@ -33,7 +33,7 @@ term stacktrace_create_raw(Context *ctx, Module *mod, int current_offset, term e
3333 return exception_class ;
3434}
3535
36- term stacktrace_build (Context * ctx , term * stack_info , uint32_t live )
36+ term stacktrace_build (Context * ctx )
3737{
3838 UNUSED (ctx );
3939 UNUSED (stack_info );
@@ -257,38 +257,41 @@ static term find_path_created(const void *key, struct ModulePathPair *module_pat
257257 return term_invalid_term ();
258258}
259259
260- term stacktrace_build (Context * ctx , term * stack_info , uint32_t live )
260+ term stacktrace_build (Context * ctx )
261261{
262262 GlobalContext * glb = ctx -> global ;
263263
264- if (* stack_info == OUT_OF_MEMORY_ATOM ) {
265- return * stack_info ;
264+ term stack_info = ctx -> exception_stacktrace ;
265+
266+ if (stack_info == OUT_OF_MEMORY_ATOM ) {
267+ return stack_info ;
266268 }
267- if (!term_is_tuple (* stack_info )) {
269+ if (!term_is_tuple (stack_info )) {
268270 return UNDEFINED_ATOM ;
269271 }
270272
271- int num_frames = term_to_int (term_get_tuple_element (* stack_info , 0 ));
272- int num_aux_terms = term_to_int (term_get_tuple_element (* stack_info , 1 ));
273- int filename_lens = term_to_int (term_get_tuple_element (* stack_info , 2 ));
274- int num_mods = term_to_int (term_get_tuple_element (* stack_info , 3 ));
273+ int num_frames = term_to_int (term_get_tuple_element (stack_info , 0 ));
274+ int num_aux_terms = term_to_int (term_get_tuple_element (stack_info , 1 ));
275+ int filename_lens = term_to_int (term_get_tuple_element (stack_info , 2 ));
276+ int num_mods = term_to_int (term_get_tuple_element (stack_info , 3 ));
275277
276278 struct ModulePathPair * module_paths = malloc (num_mods * sizeof (struct ModulePathPair ));
277279 if (IS_NULL_PTR (module_paths )) {
278280 fprintf (stderr , "Unable to allocate space for module paths. Returning raw stacktrace.\n" );
279- return * stack_info ;
281+ return stack_info ;
280282 }
281283
282284 //
283285 // [{module, function, arity, [{file, string()}, {line, int}]}, ...]
284286 //
285287 size_t requested_size = (TUPLE_SIZE (4 ) + 2 ) * num_frames + num_aux_terms * (4 + 2 * TUPLE_SIZE (2 )) + 2 * filename_lens ;
286- if (UNLIKELY (memory_ensure_free_with_roots (ctx , requested_size , live , ctx -> x , MEMORY_CAN_SHRINK ) != MEMORY_GC_OK )) {
288+ if (UNLIKELY (memory_ensure_free_opt (ctx , requested_size , MEMORY_CAN_SHRINK ) != MEMORY_GC_OK )) {
287289 free (module_paths );
288290 return OUT_OF_MEMORY_ATOM ;
289291 }
292+ stack_info = ctx -> exception_stacktrace ;
290293
291- term raw_stacktrace = term_get_tuple_element (* stack_info , 4 );
294+ term raw_stacktrace = term_get_tuple_element (stack_info , 4 );
292295
293296 term stacktrace = term_nil ();
294297 term el = raw_stacktrace ;
0 commit comments