Changeset - r28435:f543fbd941c7
[Not reviewed]
master
0 4 0
Loïc Guilloux - 9 months ago 2024-01-12 16:04:43
glx22@users.noreply.github.com
Revert a2edf52: SQOpsLimiter does a more precise job (#11754)
4 files changed with 30 insertions and 11 deletions:
0 comments (0 inline, 0 general)
cmake/scripts/Regression.cmake
Show inline comments
 
@@ -51,20 +51,24 @@ endif()
 

	
 
# For some reason pointer can be printed as '0x(nil)', '0x0000000000000000', or '0x0x0'
 
string(REPLACE "0x(nil)" "0x00000000" REGRESSION_RESULT "${REGRESSION_RESULT}")
 
string(REPLACE "0x0000000000000000" "0x00000000" REGRESSION_RESULT "${REGRESSION_RESULT}")
 
string(REPLACE "0x0x0" "0x00000000" REGRESSION_RESULT "${REGRESSION_RESULT}")
 

	
 
# Convert path separators
 
string(REPLACE "\\" "/" REGRESSION_RESULT "${REGRESSION_RESULT}")
 

	
 
# Remove timestamps if any
 
string(REGEX REPLACE "\[[0-9-]+ [0-9:]+\] " "" REGRESSION_RESULT "${REGRESSION_RESULT}")
 

	
 
# Convert the output to a format that is expected (and more readable) by result.txt
 
string(REPLACE "\ndbg: [script]" "\n" REGRESSION_RESULT "${REGRESSION_RESULT}")
 
string(REPLACE "\n " "\nERROR: " REGRESSION_RESULT "${REGRESSION_RESULT}")
 
string(REPLACE "\nERROR: [1] " "\n" REGRESSION_RESULT "${REGRESSION_RESULT}")
 
string(REPLACE "\n[P] " "\n" REGRESSION_RESULT "${REGRESSION_RESULT}")
 
string(REPLACE "\n[S] " "\n" REGRESSION_RESULT "${REGRESSION_RESULT}")
 
string(REGEX REPLACE "dbg: ([^\n]*)\n?" "" REGRESSION_RESULT "${REGRESSION_RESULT}")
 

	
 
# Read the expected result
 
file(READ ai/${REGRESSION_TEST}/result.txt REGRESSION_EXPECTED)
 

	
 
# Convert the string to a list
regression/regression/main.nut
Show inline comments
 
@@ -2023,8 +2023,15 @@ function Regression::Start()
 
				break;
 
		}
 
	}
 
	print("  IsEventWaiting:        false");
 

	
 
	this.Math();
 

	
 
	/* Check Valuate() is actually limited, MUST BE THE LAST TEST. */
 
	print("--Valuate() with excessive CPU usage--")
 
	local list = AIList();
 
	list.AddItem(0, 0);
 
	local Infinite = function(id) { while(true); }
 
	list.Valuate(Infinite);
 
}
 

	
regression/regression/result.txt
Show inline comments
 
@@ -9584,7 +9584,26 @@ ERROR: IsEnd() is invalid as Begin() is 
 
   2147483646 >  2147483647:   false
 
   1          >  2147483647:   false
 
   0          >  2147483647:   false
 
  -1          >  2147483647:   false
 
  -2147483648 >  2147483647:   false
 
   13725      > -2147483648:   true
 
--Valuate() with excessive CPU usage--
 
Your script made an error: excessive CPU usage in valuator function
 

	
 
*FUNCTION [unknown()] regression/main.nut line [2034]
 
*FUNCTION [Valuate()] NATIVE line [-1]
 
*FUNCTION [Start()] regression/main.nut line [2035]
 

	
 
[id] 0
 
[this] TABLE
 
[Infinite] CLOSURE
 
[list] INSTANCE
 
[this] INSTANCE
 
Your script made an error: excessive CPU usage in valuator function
 

	
 
*FUNCTION [Start()] regression/main.nut line [2035]
 

	
 
[Infinite] CLOSURE
 
[list] INSTANCE
 
[this] INSTANCE
 
ERROR: The script died unexpectedly.
src/script/api/script_list.cpp
Show inline comments
 
@@ -6,13 +6,12 @@
 
 */
 

	
 
/** @file script_list.cpp Implementation of ScriptList. */
 

	
 
#include "../../stdafx.h"
 
#include "script_list.hpp"
 
#include "script_controller.hpp"
 
#include "../../debug.h"
 
#include "../../script/squirrel.hpp"
 

	
 
#include "../../safeguards.h"
 

	
 
/**
 
@@ -911,22 +910,12 @@ SQInteger ScriptList::Valuate(HSQUIRRELV
 

	
 
				ScriptObject::SetAllowDoCommand(backup_allow);
 
				return sq_throwerror(vm, "return value of valuator is not valid (not integer/bool)");
 
			}
 
		}
 

	
 
		/* Kill the script when the valuator call takes way too long.
 
		 * Triggered by nesting valuators, which then take billions of iterations. */
 
		if (ScriptController::GetOpsTillSuspend() < -1000000) {
 
			/* See below for explanation. The extra pop is the return value. */
 
			sq_pop(vm, nparam + 4);
 

	
 
			ScriptObject::SetAllowDoCommand(backup_allow);
 
			return sq_throwerror(vm, "excessive CPU usage in valuator function");
 
		}
 

	
 
		/* Was something changed? */
 
		if (previous_modification_count != this->modifications) {
 
			/* See below for explanation. The extra pop is the return value. */
 
			sq_pop(vm, nparam + 4);
 

	
 
			ScriptObject::SetAllowDoCommand(backup_allow);
0 comments (0 inline, 0 general)