Skip to content
New issue

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

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

Already on GitHub? # to your account

Fixes crash on encode_buffer_append with wrong args. #6365

Merged
merged 3 commits into from
Aug 7, 2024
Merged

Conversation

esdrubal
Copy link
Contributor

@esdrubal esdrubal commented Aug 6, 2024

Description

When encode_buffer_append was called with a wrong number of args an array OOB panic was thrown.

With this fix we throw a CompileError::IntrinsicIncorrectNumArgs in case the intrinsic encode_buffer_append is called with more or less than the expected 2 arguments.

Fixes #6337

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

When encode_buffer_append was called with wrong number of args an array
OOB panick was thrown.

With this fix we throw a CompileError::IntrinsicIncorrectNumArgs in case
the intrinsic encode_buffer_append is called with more or less than the
expected 2 arguments.

Fixes #6337
@esdrubal esdrubal added bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Aug 6, 2024
@esdrubal esdrubal self-assigned this Aug 6, 2024
Copy link

github-actions bot commented Aug 6, 2024

Benchmark for 86682f1

Click to view benchmark
Test Base PR %
code_action 5.2±0.02ms 5.2±0.10ms 0.00%
code_lens 304.2±20.06ns 299.0±9.47ns -1.71%
compile 2.6±0.02s 2.6±0.05s 0.00%
completion 4.7±0.06ms 4.7±0.03ms 0.00%
did_change_with_caching 2.6±0.03s 2.6±0.02s 0.00%
document_symbol 866.5±23.86µs 938.6±40.50µs +8.32%
format 72.5±0.80ms 71.8±0.82ms -0.97%
goto_definition 333.7±5.46µs 334.8±3.76µs +0.33%
highlight 9.0±0.13ms 9.1±0.10ms +1.11%
hover 488.5±6.53µs 490.4±14.85µs +0.39%
idents_at_position 119.0±2.14µs 119.3±0.88µs +0.25%
inlay_hints 639.4±39.14µs 636.5±20.18µs -0.45%
on_enter 2.1±0.07µs 2.0±0.09µs -4.76%
parent_decl_at_position 3.7±0.09ms 3.7±0.03ms 0.00%
prepare_rename 333.5±6.21µs 335.9±5.77µs +0.72%
rename 9.4±0.18ms 9.4±0.39ms 0.00%
semantic_tokens 1163.0±24.75µs 1187.2±36.93µs +2.08%
token_at_position 329.5±6.36µs 332.2±4.16µs +0.82%
tokens_at_position 3.7±0.03ms 3.7±0.02ms 0.00%
tokens_for_file 402.0±3.74µs 403.1±4.58µs +0.27%
traverse 37.3±0.79ms 37.2±0.85ms -0.27%

@esdrubal esdrubal marked this pull request as ready for review August 7, 2024 12:35
@esdrubal esdrubal requested a review from a team as a code owner August 7, 2024 12:35
@IGI-111 IGI-111 requested a review from a team August 7, 2024 12:52
@tritao tritao enabled auto-merge (squash) August 7, 2024 13:11
Copy link

github-actions bot commented Aug 7, 2024

Benchmark for 7bd877b

Click to view benchmark
Test Base PR %
code_action 5.2±0.07ms 5.2±0.07ms 0.00%
code_lens 286.2±7.32ns 286.5±8.66ns +0.10%
compile 2.6±0.06s 2.6±0.05s 0.00%
completion 4.7±0.07ms 4.7±0.06ms 0.00%
did_change_with_caching 2.6±0.05s 2.6±0.02s 0.00%
document_symbol 854.7±15.61µs 875.8±43.92µs +2.47%
format 73.0±0.93ms 72.3±0.69ms -0.96%
goto_definition 351.0±41.98µs 342.1±7.73µs -2.54%
highlight 9.0±0.12ms 9.0±0.15ms 0.00%
hover 494.8±6.45µs 497.0±5.82µs +0.44%
idents_at_position 117.5±0.25µs 117.5±0.58µs 0.00%
inlay_hints 636.1±23.46µs 633.7±23.36µs -0.38%
on_enter 2.0±0.04µs 1922.3±36.47ns -3.89%
parent_decl_at_position 3.7±0.03ms 3.7±0.03ms 0.00%
prepare_rename 337.0±6.27µs 340.3±10.60µs +0.98%
rename 9.3±0.16ms 9.2±0.02ms -1.08%
semantic_tokens 1212.6±10.25µs 1247.1±12.87µs +2.85%
token_at_position 334.8±2.50µs 332.4±2.90µs -0.72%
tokens_at_position 3.7±0.04ms 3.7±0.02ms 0.00%
tokens_for_file 394.8±5.61µs 401.9±4.37µs +1.80%
traverse 37.6±0.87ms 37.0±0.92ms -1.60%

@tritao tritao merged commit cd0213a into master Aug 7, 2024
35 checks passed
@tritao tritao deleted the esdrubal/6337 branch August 7, 2024 13:49
Copy link

github-actions bot commented Aug 7, 2024

Benchmark for 26d67ca

Click to view benchmark
Test Base PR %
code_action 5.2±0.02ms 5.3±0.14ms +1.92%
code_lens 285.7±11.55ns 283.5±9.02ns -0.77%
compile 2.7±0.03s 2.6±0.05s -3.70%
completion 4.9±0.47ms 4.7±0.02ms -4.08%
did_change_with_caching 2.6±0.02s 2.7±0.05s +3.85%
document_symbol 857.0±8.39µs 859.7±36.64µs +0.32%
format 73.1±0.99ms 72.8±1.81ms -0.41%
goto_definition 339.8±8.14µs 353.8±9.89µs +4.12%
highlight 9.0±0.14ms 9.0±0.16ms 0.00%
hover 494.6±7.26µs 527.0±14.91µs +6.55%
idents_at_position 118.5±1.02µs 118.7±0.46µs +0.17%
inlay_hints 631.5±8.56µs 681.5±48.06µs +7.92%
on_enter 2.0±0.04µs 2.0±0.05µs 0.00%
parent_decl_at_position 3.7±0.04ms 3.7±0.04ms 0.00%
prepare_rename 340.3±5.99µs 354.9±3.42µs +4.29%
rename 9.3±0.35ms 9.3±0.14ms 0.00%
semantic_tokens 1228.0±11.33µs 1188.0±19.14µs -3.26%
token_at_position 335.6±1.76µs 347.7±3.72µs +3.61%
tokens_at_position 3.7±0.03ms 3.7±0.05ms 0.00%
tokens_for_file 401.7±3.04µs 395.1±4.81µs -1.64%
traverse 38.3±0.88ms 37.6±1.01ms -1.83%

esdrubal added a commit that referenced this pull request Aug 13, 2024
## Description
When encode_buffer_append was called with a wrong number of args an
array OOB panic was thrown.

With this fix we throw a CompileError::IntrinsicIncorrectNumArgs in case
the intrinsic encode_buffer_append is called with more or less than the
expected 2 arguments.

Fixes #6337

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

Co-authored-by: João Matos <joao@tritao.eu>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
Projects
None yet
3 participants