File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -232,10 +232,28 @@ static struct span *trace_span_slot(void)
232232
233233 /* In the unlikely case this fails, double it */
234234 if (!s ) {
235+ /* Adjust current and parents when we reallocate! */
236+ size_t num_active = tal_count (active_spans );
237+ size_t current_off COMPILER_WANTS_INIT ("11.4.0-1ubuntu1~22.04 -03" );
238+ size_t parent_off [num_active ];
239+ if (current )
240+ current_off = current - active_spans ;
241+ for (size_t i = 0 ; i < num_active ; i ++ ) {
242+ if (!active_spans [i ].parent )
243+ continue ;
244+ parent_off [i ] = active_spans [i ].parent - active_spans ;
245+ }
235246 TRACE_DBG ("%u: out of %zu spans, doubling!\n" ,
236247 getpid (), tal_count (active_spans ));
237248 tal_resizez (& active_spans , tal_count (active_spans ) * 2 );
238249 s = trace_span_find (0 );
250+ if (current )
251+ current = active_spans + current_off ;
252+ for (size_t i = 0 ; i < num_active ; i ++ ) {
253+ if (!active_spans [i ].parent )
254+ continue ;
255+ active_spans [i ].parent = active_spans + parent_off [i ];
256+ }
239257 }
240258 assert (s -> parent == NULL );
241259
You can’t perform that action at this time.
0 commit comments