Fix segfault reading empty streams

The check_clock_gate() was trying to access to the first event in all
streams. However, streams that are empty don't have any event, so they
cause a NULL dereference. Skipping not active streams avoids the
problem.
This commit is contained in:
Rodrigo Arias 2023-10-20 09:52:53 +02:00 committed by Rodrigo Arias Mallo
parent 0db35980a0
commit 0df018cf5f
3 changed files with 23 additions and 0 deletions

View File

@ -73,6 +73,9 @@ check_clock_gate(struct trace *trace)
struct stream *stream;
DL_FOREACH(trace->streams, stream) {
if (!stream->active)
continue;
struct ovni_ev *oev = stream_ev(stream);
int64_t sclock = stream_evclock(stream, oev);

View File

@ -17,3 +17,4 @@ test_emu(no-cpus.c SHOULD_FAIL REGEX "loom .* has no physical CPUs")
test_emu(sort-cpus-by-loom.c MP)
test_emu(sort-cpus-by-rank.c MP)
test_emu(tracedir-subdir.c MP DRIVER "tracedir-subdir.driver.sh")
test_emu(empty-stream.c SHOULD_FAIL REGEX "model_ovni_finish: thread .* is not dead")

View File

@ -0,0 +1,19 @@
/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include <ovni.h>
#include "instr.h"
/* Create a trace where a stream doesn't contain any event */
int
main(void)
{
instr_start(0, 1);
/* Don't flush the thread to create an empty stream */
ovni_proc_fini();
return 0;
}