@@ -1352,6 +1352,8 @@ COLD_FUNC static void cp_to_mod_lbl_off(term cp, Context *ctx, Module **cp_mod,
1352
1352
1353
1353
COLD_FUNC static void dump (Context * ctx )
1354
1354
{
1355
+ GlobalContext * glb = ctx -> global ;
1356
+
1355
1357
fprintf (stderr , "CRASH \n======\n" );
1356
1358
1357
1359
fprintf (stderr , "pid: " );
@@ -1377,7 +1379,7 @@ COLD_FUNC static void dump(Context *ctx)
1377
1379
term_display (stderr , ctx -> x [1 ], ctx );
1378
1380
fprintf (stderr , "\nx[2]: " );
1379
1381
term_display (stderr , ctx -> x [2 ], ctx );
1380
- fprintf (stderr , "\n\nStack \n------ \n\n" );
1382
+ fprintf (stderr , "\n\nStack \n-----\n\n" );
1381
1383
1382
1384
term * ct = ctx -> e ;
1383
1385
@@ -1402,12 +1404,12 @@ COLD_FUNC static void dump(Context *ctx)
1402
1404
ct ++ ;
1403
1405
}
1404
1406
1405
- fprintf (stderr , "\n\nMailbox\n-------- \n" );
1407
+ fprintf (stderr , "\n\nMailbox\n-------\n" );
1406
1408
mailbox_crashdump (ctx );
1407
1409
1408
1410
fprintf (stderr , "\n\nMonitors\n--------\n" );
1409
1411
// Lock processes table to make sure any dying process will not modify monitors
1410
- struct ListHead * processes_table = synclist_rdlock (& ctx -> global -> processes_table );
1412
+ struct ListHead * processes_table = synclist_rdlock (& glb -> processes_table );
1411
1413
UNUSED (processes_table );
1412
1414
struct ListHead * item ;
1413
1415
LIST_FOR_EACH (item , & ctx -> monitors_head ) {
@@ -1425,7 +1427,36 @@ COLD_FUNC static void dump(Context *ctx)
1425
1427
term_display (stderr , term_from_local_process_id (ctx -> process_id ), ctx );
1426
1428
fprintf (stderr , "\n" );
1427
1429
}
1428
- synclist_unlock (& ctx -> global -> processes_table );
1430
+ synclist_unlock (& glb -> processes_table );
1431
+
1432
+ // If crash is caused by out_of_memory, print more data about memory usage
1433
+ if (ctx -> x [0 ] == ERROR_ATOM && ctx -> x [1 ] == OUT_OF_MEMORY_ATOM ) {
1434
+ fprintf (stderr , "\n\nContext memory info\n-------------------\n" );
1435
+ fprintf (stderr , "context_size = %zu\n" , context_size (ctx ));
1436
+ fprintf (stderr , "context_avail_free_memory = %zu\n" , context_avail_free_memory (ctx ));
1437
+ fprintf (stderr , "heap_size = %zu\n" , memory_heap_youngest_size (& ctx -> heap ));
1438
+ fprintf (stderr , "total_heap_size = %zu\n" , memory_heap_memory_size (& ctx -> heap ));
1439
+ fprintf (stderr , "stack_size = %zu\n" , context_stack_size (ctx ));
1440
+ fprintf (stderr , "message_queue_len = %zu\n" , context_message_queue_len (ctx ));
1441
+ fprintf (stderr , "\n\nGlobal memory info\n------------------\n" );
1442
+
1443
+ processes_table = synclist_rdlock (& glb -> processes_table );
1444
+ size_t process_count = 0 ;
1445
+ size_t ports_count = 0 ;
1446
+ LIST_FOR_EACH (item , processes_table ) {
1447
+ Context * p = GET_LIST_ENTRY (item , Context , processes_table_head );
1448
+ process_count ++ ;
1449
+ if (p -> native_handler ) {
1450
+ ports_count ++ ;
1451
+ }
1452
+ }
1453
+ synclist_unlock (& glb -> processes_table );
1454
+
1455
+ fprintf (stderr , "process_count = %zu\n" , process_count );
1456
+ fprintf (stderr , "ports_count = %zu\n" , ports_count );
1457
+ fprintf (stderr , "atoms_count = %d\n" , atom_table_count (glb -> atom_table ));
1458
+ fprintf (stderr , "refc_binary_total_size = %zu\n" , refc_binary_total_size (ctx ));
1459
+ }
1429
1460
fprintf (stderr , "\n\n**End Of Crash Report**\n" );
1430
1461
}
1431
1462
0 commit comments