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

feat: fuzz gnovm/pkg/transpiler.Transpile #3457

Merged
merged 2 commits into from
Jan 9, 2025

Conversation

odeke-em
Copy link
Contributor

@odeke-em odeke-em commented Jan 8, 2025

Adds a fuzzer for Transpile, which found bugs:

package A
import(""//"
""/***/)
package main

func main() {
	const c1 = 1 < 8
	main()
	1
}

which we shouldn't allow

package main

func main() {
	const c1 = int8(1) << 8
	println(c1)
}

because 1<<8 (256) is higher than the range of int8 for which the maximum is (1<<7) - 1 aka 127

Updates #3087

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Jan 8, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jan 8, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details (checked by @n2p5)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 The pull request was created from a fork (head branch repo: odeke-em/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission
The pull request description provides enough details

If

🟢 Condition met
└── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)

Can be checked by

  • team core-contributors

@odeke-em odeke-em force-pushed the fuzz-transpiler branch 2 times, most recently from 6eeae78 to 991623e Compare January 8, 2025 07:48
@jefft0 jefft0 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jan 8, 2025
Adds a fuzzer for Transpile, which found bugs:
* gnolang#3425
* gnolang#3426
* partially gnolang#3428

Updates gnolang#3087
Copy link
Contributor

@n2p5 n2p5 left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. Before we give a LGTM, A couple of things:

  • can I get you to clean up that one unused variable in the code that I pointed out?
  • Could you add some more context into the PR body explaining what this PR does to give some more context to the issues you've linked it to?

gnovm/pkg/transpiler/fuzz_test.go Show resolved Hide resolved
@jefft0 jefft0 removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jan 8, 2025
@jefft0
Copy link
Contributor

jefft0 commented Jan 8, 2025

Removed the review/triage-pending label because this PR was reviewed by core dev n2p5.

@thehowl thehowl added the bounty/candidate PR is candidate to receive a bounty. label Jan 9, 2025
@odeke-em
Copy link
Contributor Author

odeke-em commented Jan 9, 2025

Gotcha @n2p5, I have added more succinct context to the body/description of the PR per #3457 (comment), please take a look.

@odeke-em odeke-em requested a review from n2p5 January 9, 2025 13:23
Copy link
Contributor

@n2p5 n2p5 left a comment

Choose a reason for hiding this comment

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

Spoke with @odeke-em on this and we reviewed together.

@n2p5 n2p5 merged commit 41f8763 into gnolang:master Jan 9, 2025
20 of 21 checks passed
@thehowl
Copy link
Member

thehowl commented Jan 9, 2025

@n2p5 Why was this merged with a failing CI?

@n2p5
Copy link
Contributor

n2p5 commented Jan 9, 2025

ah, @thehowl , that was a mistake, I think I mixed up my tabs here and missed this one.

albttx pushed a commit that referenced this pull request Jan 10, 2025
Adds a fuzzer for Transpile, which found bugs:
* #3425 in which this following Go program crashed the transpiler
```go
package A
import(""//"
""/***/)
```
* #3426 which generated an input that revealed the fact that Gno
deviates from Go by allowing unused variables yet Go's standard is
strict on unused variables like this program
```go
package main

func main() {
	const c1 = 1 < 8
	main()
	1
}
```
which we shouldn't allow
* partially #3428 which revealed the discrepancy in Gno that the
overflow detection is still lacking as the following program is invalid
Go but Gno allowed it to run
```go
package main

func main() {
	const c1 = int8(1) << 8
	println(c1)
}
```
because 1<<8 (256) is higher than the range of int8 for which the
maximum is `(1<<7) - 1 aka 127`

Updates #3087

Co-authored-by: Nathan Toups <[email protected]>
@odeke-em odeke-em deleted the fuzz-transpiler branch January 13, 2025 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty/candidate PR is candidate to receive a bounty. 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants