llvm-context: do not trap zero length OOB heap access (#389)

Fixes https://github.com/paritytech/contract-issues/issues/120

---------

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2025-10-15 22:39:42 +02:00
committed by GitHub
parent 2090830858
commit f46bea6a96
8 changed files with 62 additions and 12 deletions
+8 -8
View File
@@ -1,10 +1,10 @@
{
"Baseline": 932,
"Computation": 2313,
"DivisionArithmetics": 9103,
"ERC20": 17479,
"Events": 1692,
"FibonacciIterative": 1508,
"Flipper": 2098,
"SHA1": 8176
"Baseline": 914,
"Computation": 2295,
"DivisionArithmetics": 9085,
"ERC20": 17499,
"Events": 1674,
"FibonacciIterative": 1490,
"Flipper": 2102,
"SHA1": 8158
}
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/* runner.json
{
"differential": true,
"actions": [
{
"Instantiate": {
"code": {
"Solidity": {
"contract": "MemoryBounds"
}
}
}
},
{
"Call": {
"dest": {
"Instantiated": 0
}
}
}
]
}
*/
contract MemoryBounds {
fallback() external {
assembly {
// Accessing OOB offsets should always work when the length is 0.
return(100000, 0)
}
}
}
+1
View File
@@ -62,6 +62,7 @@ test_spec!(function_type, "FunctionType", "FunctionType.sol");
test_spec!(layout_at, "LayoutAt", "LayoutAt.sol");
test_spec!(shift_arithmetic_right, "SAR", "SAR.sol");
test_spec!(add_mod_mul_mod, "AddModMulModTester", "AddModMulMod.sol");
test_spec!(memory_bounds, "MemoryBounds", "MemoryBounds.sol");
fn instantiate(path: &str, contract: &str) -> Vec<SpecsAction> {
vec![Instantiate {