-
Notifications
You must be signed in to change notification settings - Fork 1.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
CGOError
--> CGOErrCode
#12499
CGOError
--> CGOErrCode
#12499
Conversation
…ich removes a major potential memory leak/error footgun
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not overly familiar with Rust, but the Go/CGo changes look sensible.
Am I right in thinking that with this change we lose some detail on the Go side as to what error actually occurred, but that these errors are now logged in the Rust side ?
The motivation for this was actually the opposite. We were passing a string from Go to Rust, just so Rust could log the error and then terminate. Now, we log the error on the Go side, and then just indicate to Rust that there was a failure. It's a lot easier to pass an integer than a string across the FFI. (Though it looks like this was applied in both directions, so you're correct that Rust is also passing only an error code to Go). |
Rather than passing errors via C-strings, we pass them as integers which removes a major potential memory leak/error footgun
(Credit to @zmb3 for this idea)