-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/compile: checking len(data) and erroring out if too small does not help BCE #19126
Comments
/cc @dr2chase |
I thought that the fix for #16813 would help here. I thought wrong. There's probably a x >= c implies x-d >= c-d implication that needs to be added to BCE. |
That implication requires inference of no over/underflow. |
This would only be for constants c, d >= 0, which I think makes it always work. |
Thanks for feedback. Indeed it is a Looking forward for this to be eventually improved. Thanks again, |
/cc @aclements |
If the slices access are written as
Then the bounds checks are correctly removed. I saw a similar issue with dgryski/go-metro@1308eab but I assumed it was because the bounds check "proof" (that |
@dgryski thanks for information about workaround. I confirm that with
and both either go19 or today's tip Decode becomes something like (tip version below):
From this offhand I would say for original case it seems to be there is some BCE-related information lost somehow when inlining. |
The problem here is that in code like |
Change https://golang.org/cl/193838 mentions this issue: |
Fixed by the CL stack starting at https://go-review.googlesource.com/c/go/+/599255 |
Thanks! |
Please answer these questions before submitting your issue. Thanks!
What did you do?
Hello up there. In my program there are many autogenerated packet decoder/encoders. A simple decoder looks like this:
(https://play.golang.org/p/BganWzetvq)
The decoder explicitly cares to first check whether
len(data)
is too small and if so returns viagoto overflow
.What did you expect to see?
Code generated for main Decode part does not have bound checks.
What did you see instead?
Compiled assembly has many bound checks:
Does this issue reproduce with the latest release (go1.7.5)?
Yes, with both go1.7.4 and go1.8
Possibly related issues:
#17370
#16092
#15074
System details
/cc @randall77
The text was updated successfully, but these errors were encountered: