-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Auditing use of unsafe rust #398
Comments
Hello @pchickey! Thanks for your comment on using unsafe Rust. I am not the author of the code itself, so I cannot really guarantee that the use of unsafe code is done safely, nor that it is actually important at every place it is used. I think an important first step would be to investigate the use of the The solution to have a This question needs further investigation, and help from anyone is more than welcome! |
I also have an application for logos handling untrusted input, so I took some time today to audit the usage of unsafe code in logos. The logos crate itself does not pull in any external dependencies (yay!), so the only source of unsafety is the crate itself. Of these, there are four areas using
Beyond that, there is an additional safety issue with the current implementation. The If the unsafe code is enabled, then the entire I've implemented all of the above, except for marking the There is a decision to be made around including Regarding benchmarks, I hoped there would be a clear difference which would help make that decision. But compilers are smart and there are surprises! I'll include benchmark results on the PR. EDIT: I realized |
@pchickey The Should just need to add a Some benchmarking showed that there wasn't a massive throughput difference, but the performance outcome will depend greatly on your specific grammar. |
@davidkern Thanks so much David for your work on this feature! @jeertmans Can you ping me when a new release is made, so I can move bytecodealliance/wasmtime#8872 forward? |
Done with v0.14.2 @pchickey ;-) Note that you can also subscribe to new release notification if you want! |
Hi - I am new to the
logos
ecosystem.I don't want to cast any doubt on the correctness of logos or that anyone should choose to use it - it looks like its a remarkable project that is clearly a great choice for many users.
I am upstreaming a crate which uses logos to generate a lexer ( bytecodealliance/wasmtime#8872 ) into wasmtime. As part of accepting
logos
to be used as a transitive dependency in the wasmtime project, I need to certify that it meetscargo-vet
'ssafe-to-deploy
criteria: https://mozilla.github.io/cargo-vet/built-in-criteria.html#safe-to-deploy .The lexer will be handling untrusted input, and after spending some time examining the way logos codegen works, I don't feel that I can certify that the use of
unsafe
rust is sound: while I don't have any evidence that it is unsound, the code generator, and the code it generates, is too complex for me to reasonably declare that any use of thelogos
derive macro is fully sound, as would be implied by marking it assafe-to-deploy
.My rough understanding, from reading the code generator and the author's blog, is that performance is a huge goal of
logos
, and it has achieved very high performance. In my use case, I don't really care about performance: the inputs to the lexer are small and infrequent, and if the lexer was one or two orders of magnitude slower, that would be fine. However, I do care about correctness, to the point of being very conservative in what dependencies I can accept.One path forward might be to have an alternative code generator for the logos macros that uses entirely safe rust. Have the logos authors ever considered this approach? Otherwise, I will have to rewrite my lexer by hand, and in doing so I will lose composability with other logos lexers in our ecosystem.
The text was updated successfully, but these errors were encountered: