mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 19:52:29 +00:00 
			
		
		
		
	[WIP] Add a mutex to warning.cpp to ensure that warning messages from different threads don't interfere (#7963)
* Initial plan * Add mutex to warning.cpp for thread safety Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									d6d1d7f19c
								
							
						
					
					
						commit
						0972ab08bb
					
				
					 1 changed files with 11 additions and 0 deletions
				
			
		|  | @ -24,6 +24,10 @@ Revision History: | |||
| #include "util/buffer.h" | ||||
| #include "util/vector.h" | ||||
| 
 | ||||
| #ifndef SINGLE_THREAD | ||||
| #include <mutex> | ||||
| #endif | ||||
| 
 | ||||
| #ifdef _WINDOWS | ||||
| #if defined( __MINGW32__ ) && ( defined( __GNUG__ ) || defined( __clang__ ) ) | ||||
| #include <crtdbg.h> | ||||
|  | @ -67,6 +71,10 @@ static bool g_use_std_stdout = false; | |||
| static std::ostream* g_error_stream = nullptr; | ||||
| static std::ostream* g_warning_stream = nullptr; | ||||
| 
 | ||||
| #ifndef SINGLE_THREAD | ||||
| static std::mutex g_warning_mutex; | ||||
| #endif | ||||
| 
 | ||||
| void send_warnings_to_stdout(bool flag) { | ||||
|     g_use_std_stdout = flag; | ||||
| } | ||||
|  | @ -129,6 +137,9 @@ void print_msg(std::ostream * out, const char* prefix, const char* msg, va_list | |||
| 
 | ||||
| void warning_msg(const char * msg, ...) { | ||||
|     if (g_warning_msgs) { | ||||
| #ifndef SINGLE_THREAD | ||||
|         std::lock_guard<std::mutex> lock(g_warning_mutex); | ||||
| #endif | ||||
|         va_list args; | ||||
|         va_start(args, msg); | ||||
|         print_msg(g_warning_stream, "WARNING: ", msg, args); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue