Solidity provides invalid `start` in the source map
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
## Description
The value of `start` in the sourceMap is greater than the length of source file.
The `start` is the byte offset to the start of the range in the source file. Hence this value should be less than the byte length of source file.
## Environment
- Compiler version: 0.6.8
- Target EVM version (as per compiler settings):
- Framework/IDE (e.g. Truffle or Remix): Truffle
- EVM execution environment / backend / blockchain client:
- Operating system: MacOS Big Sur
## Steps to Reproduce
The steps to reproduce this issue are given in the truffle issue (https://github.com/trufflesuite/truffle/issues/4616).
After stepping to 8240 with truffle debugger command `; 8239`, use the following commands to see the issue:
1. issue command `:!` to see the `start` of the first instruction is 28307
```
debug(inline_config:0x1c796d1e...)> :!
{
pc: 0,
name: 'PUSH1',
pushData: '0x80',
index: 0,
jump: '-',
start: 28307,
length: 3774,
file: 0,
modifierDepth: 0,
range: {
start: {
line: null,
column: null
},
end: {
line: null,
column: null
}
}
}
```
2. Issue command `:!` to see the source map which shows the `start` of the first instruction is 28307
```
debug(inline_config:0x1c796d1e...)> :!
'28307:3774:0:-:0;;;;5:9:-1;2:2;;;27:1;24;17:12;2:2;28307:3774:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12:1:-1;9;2:12;28367:53:0;;;:::i;:::-;;;;;;;;;;;;;;;;;;;
```
3. issue command `:!.source.length` to see the length of source is 27370 which is less than the start in the source map above.
```
debug(inline_config:0x1c796d1e...)> :!.source.length
27370
```
Contributor guide
Research direction
Reproduce the report with Solidity compiler 0.6.8 using the Truffle debugger commands shown: inspect sourcemapping.current.instruction, sourcemapping.current.sourceMap, and sourcemapping.current.source.length after stepping to 8240. Trace how the compiler produces the first source-map entry. Done means the reported start offset is within the source byte length for the reproduced contract.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100