-
Notifications
You must be signed in to change notification settings - Fork 60
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
Fix out-of-bounds error in atdgen parsers #150
Conversation
parses an unquoted JSON field. TODO: write a unit test.
I'll take a look tomorrow to see if some kind of unit test can be built to exercise this, given it is quite subtle and has not been detected by anything but |
I've been wondering whether I can write a test for I am not sure how this API is supposed to be used. The only function I see for reading this is to call According to this autogenerated code it does seem to |
Ok, I added tests for Looks like if we remove the variants as suggested in #104 we'd either need to break the API for atdgen or live with somewhat confusing function names but that can be revisited at that time. |
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.
Thanks a lot for the fix!
I guess the fact that map_ident
and map_lexeme
are values that are not actually used by yojson itself, but by atdgen, made them escape the tests...
This is now fixed, thanks @Leonidas-from-XIV for the added tests.
It calls it via
(returning an int rather than constructing an expression is itself part of an optimization that prevents the creation of a closure) Now that we use the Note that there are other optimizations that make atdgen's code generation more complicated than it could be. I estimate the speedup provided by these optimizations to be about 4x compared to naive implementation. It's something but it's not huge. I think these optimizations are only valuable when dealing with massive amounts of JSON data. I'm open to getting rid of them. Atdgen parsers could work on the |
I was just thinking about it the other day - there is a lot of support-code for atdgen that's dealing with the internals of Yojson, which forces us to either keep the implementation fixed to not break atdgen or break atdgen all the time, neither of these options is particularly exciting (that said, there is also not much of a need to change things willy-nilly) So making atdgen use the |
CHANGES: *2022-08-09* ### Added - Expanded documentation of exceptions (@sim642, ocaml-community/yojson#148) ### Removed - Removed undocumented and unused functions `write_float_fast` and `write_std_float_fast` from `Yojson`, `Yojson.Basic` and `Yojson.Safe` (@sim642, ocaml-community/yojson#149) ### Fixed - Fix out-of-bounds error occurring when parsing object field names with atdgen parsers using `map_ident` or `map_lexeme` (@mjambon, ocaml-community/yojson#150)
When running
make test
in atd, which just switched to yojson 2.0.x, we get an out-of-bounds error on two unit tests:The problem occurs when parsing unquoted JSON fields, which are supported as an extension of JSON. I believe I fixed the bug, but didn't add a unit test yet because I'm not sure yet where to put it.
To get the detailed error message above, check out ahrefs/atd#310 and run
make test
.