-
Notifications
You must be signed in to change notification settings - Fork 37
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
Use of unsafe is unsound #9
Comments
I'm saying that converting a |
Hey Steve,
the ptr is not carried around multiple statements. the ptr is locally casted, incremented and changed by a bitoperation. This behaviour is not volatile at runtime - at least not in the golang binary.
Anyway - when bbloom was written in 2015 i guess the math/bits package was not part of the standard library (came 2017/18 ? from the guys working on math64 and integer ssa ... implementation?). Maybe it is a good idea to go for the for the present standard library and following your suggestion.
I will look into it and will replace unsafe use, where it is suitable without performance loss.
If you have changed the API maybe you should remaster your code with a different name i.e bbbloom ?
Andreas
… Am 23.08.2019 um 22:34 schrieb Steven Allen ***@***.***>:
I'm saying that converting a uintptr back to a unsafe.Pointer across multiple statements is unsound.
https://golang.org/pkg/unsafe/#Pointer <https://golang.org/pkg/unsafe/#Pointer>
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub <#9?email_source=notifications&email_token=AAKKFCYMH4K4CKC3W3JTT2DQGBCWTA5CNFSM4IPBVSPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5BILTY#issuecomment-524453327>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAKKFC3HWWKVMFOFEVECYGLQGBCWTANCNFSM4IPBVSPA>.
|
Take a look at the functions I'm quoting in the issue description. You can't save a uintptr to the stack then convert it back to an Take the JSONMarshal function. The garbage collector is allowed to pause the function between lines 236 and 238, move anything it wants, update the pointers, then restart the function. At that point, the saved |
... p.s. look at (3) here https://golang.org/pkg/unsafe/#Pointer <https://golang.org/pkg/unsafe/#Pointer>
… Am 23.08.2019 um 22:34 schrieb Steven Allen ***@***.***>:
I'm saying that converting a uintptr back to a unsafe.Pointer across multiple statements is unsound.
https://golang.org/pkg/unsafe/#Pointer <https://golang.org/pkg/unsafe/#Pointer>
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub <#9?email_source=notifications&email_token=AAKKFCYMH4K4CKC3W3JTT2DQGBCWTA5CNFSM4IPBVSPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5BILTY#issuecomment-524453327>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAKKFC3HWWKVMFOFEVECYGLQGBCWTANCNFSM4IPBVSPA>.
|
That's exactly what I'm looking at: Note that both conversions must appear in the same expression, with only the intervening arithmetic between them:// INVALID: uintptr cannot be stored in variable // before conversion back to Pointer. u := uintptr(p) p = unsafe.Pointer(u + offset) |
I considered Your comments and opted for the way documented at https://golang.org/pkg/unsafe/#Pointer |
That looks safe. Thanks! |
This commit fixes the `checkptr` issue reported in #1294. The `checkptr` issue was fixed in the upstream library AndreasBriese/bbloom#9 . This PR updates the go.mod file to use the latest version of `AndreasBriese/bbloom`
This commit fixes the `checkptr` issue reported in dgraph-io#1294. The `checkptr` issue was fixed in the upstream library AndreasBriese/bbloom#9 . This PR updates the go.mod file to use the latest version of `AndreasBriese/bbloom`
Casting to a
uintptr
, saving theuintptr
, and then casting it back is unsound.bbloom/bbloom.go
Lines 80 to 88 in e2d15f3
bbloom/bbloom.go
Lines 232 to 246 in e2d15f3
The text was updated successfully, but these errors were encountered: