Skip to content

Conversation

@eejbyfeldt
Copy link
Contributor

Which issue does this PR close?

Follow up to #12814

Rationale for this change

This address a bug that previously always replace % 1 expression with a 0 of type i32. This lead to panics/crashes in a lot of places since we expect the type to not change as part of this simplification rule.

What changes are included in this PR?

This patch fixes it by replacing it with a 0 of correct type.

Are these changes tested?

Yes.

Are there any user-facing changes?

No.

This address a bug that previously always replace % 1 expression with a
0 of type i32. This lead to panics/crashes in a lot of places since we
expect the type to not change as part of this simplification rule. This
patch fixes it by replacing it with a 0 of correct type.

This was discovered in apache#12814
@github-actions github-actions bot added the optimizer Optimizer rules label Oct 13, 2024
@eejbyfeldt eejbyfeldt marked this pull request as ready for review October 13, 2024 17:43
Copy link
Member

@jonahgao jonahgao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @eejbyfeldt

Copy link
Contributor

@2010YOUY01 2010YOUY01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch for another vulnerability.

Some additional thoughts: this optimization rule seems quite error-prone for edge cases. We should run property tests with the optimization rules both enabled and disabled.

@findepi
Copy link
Member

findepi commented Oct 15, 2024

We could perhaps validate the types before and after simplification are the same

@alamb alamb merged commit 0e08e06 into apache:main Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants