mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	Fix tcl crash in case of error executing command
This commit is contained in:
		
							parent
							
								
									f9db7c0599
								
							
						
					
					
						commit
						b0469b3863
					
				
					 2 changed files with 8 additions and 1 deletions
				
			
		|  | @ -590,7 +590,9 @@ void yosys_shutdown() | |||
| 
 | ||||
| #ifdef YOSYS_ENABLE_TCL | ||||
| 	if (yosys_tcl_interp != NULL) { | ||||
| 		if (!Tcl_InterpDeleted(yosys_tcl_interp)) { | ||||
| 			Tcl_DeleteInterp(yosys_tcl_interp); | ||||
| 		} | ||||
| 		Tcl_Finalize(); | ||||
| 		yosys_tcl_interp = NULL; | ||||
| 	} | ||||
|  | @ -789,11 +791,13 @@ struct TclPass : public Pass { | |||
| 			script_args.push_back(Tcl_NewStringObj((*it).c_str(), (*it).size())); | ||||
| 
 | ||||
| 		Tcl_Interp *interp = yosys_get_tcl_interp(); | ||||
| 		Tcl_Preserve(interp); | ||||
| 		Tcl_ObjSetVar2(interp, Tcl_NewStringObj("argc", 4), NULL, Tcl_NewIntObj(script_args.size()), 0); | ||||
| 		Tcl_ObjSetVar2(interp, Tcl_NewStringObj("argv", 4), NULL, Tcl_NewListObj(script_args.size(), script_args.data()), 0); | ||||
| 		Tcl_ObjSetVar2(interp, Tcl_NewStringObj("argv0", 5), NULL, Tcl_NewStringObj(args[1].c_str(), args[1].size()), 0); | ||||
| 		if (Tcl_EvalFile(interp, args[1].c_str()) != TCL_OK) | ||||
| 			log_cmd_error("TCL interpreter returned an error: %s\n", Tcl_GetStringResult(interp)); | ||||
| 		Tcl_Release(interp); | ||||
| 	} | ||||
| } TclPass; | ||||
| #endif | ||||
|  |  | |||
|  | @ -82,6 +82,9 @@ | |||
| #  ifdef YOSYS_MXE_HACKS | ||||
| extern Tcl_Command Tcl_CreateCommand(Tcl_Interp *interp, const char *cmdName, Tcl_CmdProc *proc, ClientData clientData, Tcl_CmdDeleteProc *deleteProc); | ||||
| extern Tcl_Interp *Tcl_CreateInterp(void); | ||||
| extern void Tcl_Preserve(ClientData data); | ||||
| extern void Tcl_Release(ClientData clientData); | ||||
| extern int Tcl_InterpDeleted(Tcl_Interp *interp); | ||||
| extern void Tcl_DeleteInterp(Tcl_Interp *interp); | ||||
| extern int Tcl_Eval(Tcl_Interp *interp, const char *script); | ||||
| extern int Tcl_EvalFile(Tcl_Interp *interp, const char *fileName); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue