Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index out of range #6878

Closed
2 tasks done
ethever opened this issue Jan 22, 2024 · 4 comments · Fixed by #6886
Closed
2 tasks done

Index out of range #6878

ethever opened this issue Jan 22, 2024 · 4 comments · Fixed by #6886
Labels
T-bug Type: bug

Comments

@ethever
Copy link

ethever commented Jan 22, 2024

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (5ea2c5e 2024-01-22T00:21:08.216952070Z)

What command(s) is the bug in?

forge debug --debug exploit.sol --sig "exec()"

Operating System

Linux

Describe the bug

(base) root@DESKTOP-Q664A32:~/projects/web3/exploits/dev5/contracts#  RUST_BACKTRACE=full forge debug --debug exploit.sol --sig "exec()"
[⠊] Compiling...
No files changed, compilation skipped
The application panicked (crashed).
Message:  range start index 24 out of range for slice of length 23
Location: crates/debugger/src/tui/draw.rs:280

This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1: __libc_start_main<unknown>
      at ./csu/../csu/libc-start.c:308

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Aborted
@ethever ethever added the T-bug Type: bug label Jan 22, 2024
@Evalir
Copy link
Member

Evalir commented Jan 22, 2024

hi! thanks—is it possible for you to provide a repro so we can look into it?

@brockelmore is this the bug you ran into the other day?

@ethever
Copy link
Author

ethever commented Jan 22, 2024

hi! thanks—is it possible for you to provide a repro so we can look into it?

@brockelmore is this the bug you ran into the other day?

Yes, thank you for your attention to the bug report. I am new to foundry but I will make sure to document the reproduction steps clearly as soon as I am able to dedicate the required time to it.

It seems to be a bug in frontend UI, when I first start the debugger, and then i click the down button to navigate the debugger to the next binary code as you can see in the red rectangle
image
Keep going down the binary code and suddenly it will crash (something ran out of the range).

@mattsse
Copy link
Member

mattsse commented Jan 22, 2024

@DaniPopes I don't remember who initially wrote this, so it's hard to make sense of what's going on here, but this looks very fishy:

let (start_line, end_line) = if needed_highlight > height {
// highlighted section is more lines than we have avail
(before.len(), before.len() + needed_highlight)

this sets the start line to the number of items in the vec, which then causes the index out of bounds

for line in &before[start_line..] {

unclear if the fix is as simple as just using len - 1

@ethever
Copy link
Author

ethever commented Jan 23, 2024

Thanks to #6886, this bug has been fixed

@ethever ethever closed this as completed Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants