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:
		
							parent
							
								
									0db35980a0
								
							
						
					
					
						commit
						0df018cf5f
					
				| @ -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); | ||||
| 
 | ||||
|  | ||||
| @ -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") | ||||
|  | ||||
							
								
								
									
										19
									
								
								test/emu/ovni/empty-stream.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								test/emu/ovni/empty-stream.c
									
									
									
									
									
										Normal 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; | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user