On Wed, Jan 16, 2019 at 10:57:49AM -0800, Song Liu wrote: > Hi, > > We are debugging a segfault of perf in ordered_events__free().
hi, any backtrace or info on how to reproduce it? > Disassemble shows the segfault was caused by oe->buff == NULL > in the following line: > > /* > * Current buffer might not have all the events allocated > * yet, we need to free only allocated ones ... > */ > list_del(&oe->buffer->list); > > After poking around the code, I suspect it is caused by the following > condition in alloc_event(): > > } else if (oe->buffer) { > new = &oe->buffer->event[oe->buffer_idx]; > if (++oe->buffer_idx == MAX_SAMPLE_BUFFER) > oe->buffer = NULL; argh.. yea, we need to check oe->buffer in ordered_events__free would attached change fix it for you? thanks, jirka --- diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c index 897589507d97..ea523d3b248f 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c @@ -391,8 +391,10 @@ void ordered_events__free(struct ordered_events *oe) * Current buffer might not have all the events allocated * yet, we need to free only allocated ones ... */ - list_del(&oe->buffer->list); - ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe); + if (oe->buffer) { + list_del(&oe->buffer->list); + ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe); + } /* ... and continue with the rest */ list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) {