-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime/checkptr:Pro 8000 posed some changes to pointer detection #68220
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
Comments
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
Closing as a dup of #68170. |
Here is a minimized example https://go.dev/play/p/zUPGPmUqkzq :
This panics on the playground. One issue is that If you would like the situation to change, I recommend filing a proposal that proposes changes to the valid patterns of unsafe.Pointer. The proposal process is documented here https://github.com/golang/proposal . (I didn't really follow what your are saying about |
Pointer safety discussion I would suggest discussing pointers in the range 0x1-0xFFFF, a range (GO) that is unreadable and unwritable, and theoretically safe, just not for reading and writing. Regarding writing the value of the code (unsafe.Pointer), a setting in the 0x1-0xFFFF range (or there can be a smaller range) is safe in my hunch. So you won't see a GC error triggered by a savage write like this unsafe.Pointer(0x34534632), as long as the GC excludes the low value range it has nothing going on, and the actual system doesn't allocate low-address memory. |
If the GC requests memory in the 0x1-0xFFFF range, just discard it, 64k memory is not much of a problem |
@timothy-king adjustpointers is a highly frequently called function, and if it's not running correctly, it will be detected early on. Pointer detection is not its job, and can be done by moving to build -race if you need a hint. Use raceenabled to mask it, so it won't compile in at compile time, and if I don't mask it, it's featured where it is and doesn't look secure |
Proposal Details
build-debug runs the following code, and when it reaches stack_expansion it reports an error: (invalid pointer found on stack)
You can run it under this site:https://onlinegdb.com/LekF0Chbo
For this kind of code, you consider it an invalid pointer. If it is valid for me, then it is valid. Whether it's valid or not, we'll leave that aside for now.
For the behaviour that reported the error, I found two places
I recommend that they only run under build-race, so add the (raceenabled) condition.
Don't say there are lots of alternatives and that's all we'll discuss. If you say you haven't encountered this situation yet, you just haven't. It's natural to report an error when a pointer read or write is invalid, there's no need to actively report an error, that's my option.
If it is valid for me, then it is valid: https://onlinegdb.com/iW2ppsMTS
The text was updated successfully, but these errors were encountered: