solang icon indicating copy to clipboard operation
solang copied to clipboard

Accessing values from a string array causes an execution error.

Open Subway2023 opened this issue 11 months ago • 0 comments

Version: v0.3.3: Atlantis Description: The statement return (z[0]); causes an execution error.

contract C {
    function f() public returns (string memory) {
        string memory x = "Hello";
        string memory y = "World";
        string[2] memory z = [x, y];
        return (z[0]);
    }
}

Reproduction: I set up a Solang compilation and execution environment to test the program.

solang/target/debug/vmRunNoPara test.sol C f

The execution error is as follows:

Contract name: C
function new for GT7Gf9ZAgkYKSrK6RVqgxAy78b8zL4P8SAXooowtWeer
input: 872ccdc6190148bc
running bpf with calldata:872ccdc6190148bc
program: GT7Gf9ZAgkYKSrK6RVqgxAy78b8zL4P8SAXooowtWeer
static: length:0 
offset:20 prev:10 next:10 length:0 allocated:0 
function f for GT7Gf9ZAgkYKSrK6RVqgxAy78b8zL4P8SAXooowtWeer
input: 352dd00eb9a6751b
running bpf with calldata:352dd00eb9a6751b
program: GT7Gf9ZAgkYKSrK6RVqgxAy78b8zL4P8SAXooowtWeer
thread 'main' panicked at src/tests/solana.rs:1857:38:
error AccessViolation(219, Load, 25, 4, "unknown")

Subway2023 avatar Feb 11 '25 04:02 Subway2023