Merge branch 'main' into aegilops/polyfill-io-compromised-script

This commit is contained in:
Paul Hodgkinson
2024-07-12 14:22:15 +01:00
committed by GitHub
4 changed files with 44 additions and 30 deletions

View File

@@ -373,7 +373,8 @@ def syntax_error_message(exception, unit):
return error
def recursion_error_message(exception, unit):
l = Location(file=unit.path)
# if unit is a BuiltinModuleExtractable, there will be no path attribute
l = Location(file=unit.path) if hasattr(unit, "path") else None
return (DiagnosticMessage(Source("py/diagnostics/recursion-error", "Recursion error in Python extractor"), Severity.ERROR)
.with_location(l)
.text(exception.args[0])
@@ -383,7 +384,8 @@ def recursion_error_message(exception, unit):
)
def internal_error_message(exception, unit):
l = Location(file=unit.path)
# if unit is a BuiltinModuleExtractable, there will be no path attribute
l = Location(file=unit.path) if hasattr(unit, "path") else None
return (DiagnosticMessage(Source("py/diagnostics/internal-error", "Internal error in Python extractor"), Severity.ERROR)
.with_location(l)
.text("Internal error")

View File

@@ -10,7 +10,7 @@ from io import BytesIO
#Semantic version of extractor.
#Update this if any changes are made
VERSION = "6.1.1"
VERSION = "6.1.2"
PY_EXTENSIONS = ".py", ".pyw"

View File

@@ -274,16 +274,24 @@ def _extract_loop(proc_id, queue, trap_dir, archive, options, reply_queue, logge
# Syntax errors have already been handled in extractor.py
reply_queue.put(("FAILURE", unit, None))
except RecursionError as ex:
error = recursion_error_message(ex, unit)
diagnostics_writer.write(error)
logger.error("Failed to extract %s: %s", unit, ex)
logger.traceback(WARN)
try:
error = recursion_error_message(ex, unit)
diagnostics_writer.write(error)
except Exception as ex:
logger.warning("Failed to write diagnostics: %s", ex)
logger.traceback(WARN)
reply_queue.put(("FAILURE", unit, None))
except Exception as ex:
error = internal_error_message(ex, unit)
diagnostics_writer.write(error)
logger.error("Failed to extract %s: %s", unit, ex)
logger.traceback(WARN)
try:
error = internal_error_message(ex, unit)
diagnostics_writer.write(error)
except Exception as ex:
logger.warning("Failed to write diagnostics: %s", ex)
logger.traceback(WARN)
reply_queue.put(("FAILURE", unit, None))
else:
reply_queue.put(("SUCCESS", unit, None))

View File

@@ -1322,31 +1322,27 @@ module Make<LocationSig Location, InputSig<Location> Input> {
}
}
private module Cached {
cached
newtype TNode =
TParamNode(DfInput::Parameter p) { DfInput::ssaDefInitializesParam(_, p) } or
TExprNode(DfInput::Expr e, Boolean isPost) {
e = DfInput::getARead(_)
or
DfInput::ssaDefAssigns(_, e) and
isPost = false
} or
TSsaDefinitionNode(DefinitionExt def) or
TSsaInputNode(SsaInputDefinitionExt def, BasicBlock input) {
def.hasInputFromBlock(_, _, _, _, input)
}
cached
Definition getAPhiInputDef(SsaInputNode n) {
exists(SsaInputDefinitionExt phi, BasicBlock bb |
phi.hasInputFromBlock(result, _, _, _, bb) and
n.isInputInto(phi, bb)
)
}
cached
private DefinitionExt getAPhiInputDef(SsaInputDefinitionExt phi, BasicBlock bb) {
phi.hasInputFromBlock(result, _, _, _, bb)
}
private import Cached
private newtype TNode =
TParamNode(DfInput::Parameter p) {
exists(WriteDefinition def | DfInput::ssaDefInitializesParam(def, p))
} or
TExprNode(DfInput::Expr e, Boolean isPost) {
e = DfInput::getARead(_)
or
exists(DefinitionExt def |
DfInput::ssaDefAssigns(def, e) and
isPost = false
)
} or
TSsaDefinitionNode(DefinitionExt def) or
TSsaInputNode(SsaInputDefinitionExt phi, BasicBlock input) {
exists(getAPhiInputDef(phi, input))
}
/**
* A data flow node that we need to reference in the value step relation.
@@ -1627,6 +1623,14 @@ module Make<LocationSig Location, InputSig<Location> Input> {
*/
signature predicate guardChecksSig(DfInput::Guard g, DfInput::Expr e, boolean branch);
pragma[nomagic]
private Definition getAPhiInputDef(SsaInputNode n) {
exists(SsaInputDefinitionExt phi, BasicBlock bb |
result = getAPhiInputDef(phi, bb) and
n.isInputInto(phi, bb)
)
}
/**
* Provides a set of barrier nodes for a guard that validates an expression.
*