@@ -1409,6 +1409,9 @@ int erts_is_call_break(Process *p, ErtsTraceSession *session, int is_time,
14091409
14101410 /* foreach threadspecific hash */
14111411 for (i = 0 ; i < bdt -> nthreads ; i ++ ) {
1412+ if (!bdt -> threads [i ]) {
1413+ continue ;
1414+ }
14121415 /* foreach hash bucket not NIL*/
14131416 for (ix = 0 ; ix < bdt -> threads [i ]-> n ; ix ++ ) {
14141417 item = & (bdt -> threads [i ]-> buckets [ix ]);
@@ -1695,6 +1698,10 @@ static void bp_hash_accum(bp_trace_hash_t **hash_p,
16951698{
16961699 bp_data_trace_bucket_t * item ;
16971700
1701+ if (* hash_p == NULL ) {
1702+ * hash_p = bp_hash_alloc (32 );
1703+ }
1704+
16981705 item = bp_hash_get (* hash_p , sitem );
16991706 if (!item ) {
17001707 bp_hash_put (hash_p , sitem );
@@ -2087,7 +2094,7 @@ static BpDataCallTrace* bp_calltrace_alloc(void)
20872094 bdt -> nthreads = n ;
20882095 erts_refc_init (& bdt -> refc , 1 );
20892096 for (Uint i = 0 ; i < n ; i ++ ) {
2090- bdt -> threads [i ] = bp_hash_alloc ( 32 );
2097+ bdt -> threads [i ] = NULL ; // allocate on demand
20912098 }
20922099 return bdt ;
20932100}
@@ -2097,7 +2104,9 @@ bp_calltrace_unref(BpDataCallTrace* bdt)
20972104{
20982105 if (erts_refc_dectest (& bdt -> refc , 0 ) <= 0 ) {
20992106 for (Uint i = 0 ; i < bdt -> nthreads ; ++ i ) {
2100- bp_hash_dealloc (bdt -> threads [i ]);
2107+ if (bdt -> threads [i ]) {
2108+ bp_hash_dealloc (bdt -> threads [i ]);
2109+ }
21012110 }
21022111 Free (bdt );
21032112 }
0 commit comments