-
-
Notifications
You must be signed in to change notification settings - Fork 152
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 decoding of slice with type implemented UnmarshalJSON #198
Conversation
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.
Sorry, the comment does not apply to this PR.
5b7b1ac
to
e647daf
Compare
I'll receive a segmentation fault with this PR:
Will add a reproducer in a jiffy. |
Sorry it takes me ages to reduce the test case to something that i can safely send out without any company violation. Just a note, i already tested your new commit in the meantime 6444a1b: did not solve the problem i am currently seeing. So am continuing to work on a reproducer. |
@zimmski Thank you, I wait for your report |
I think it has something to do with data being marked as invalid... when i add a "Valid" call to our code, i see that go-json marks the JSON raw data as invalid. Here is an ugly reproducer... sorry i cannot post the original content.
|
However, i can reproduce with the master the same problem. So this is a bug that has nothing to do with this PR. So i create a new issue and since this PR solves the original reproducer, it can be merged? |
I did find another case where it fails with a segmentation fault on this PR. Will first create the issue with the invalid case, since that can be reproduced with the master (will double check that). And then move on to have a reproducer for the segmentation fault for this PR. Sorry to flipflop. Side question: is the form of reproducers in #198 (comment) ok? Because that is a no-brainer to send out. |
Finally. I got one that i can post (as i sidenote this happens with and without #200):
|
@goccy @zimmski for reproduce:
|
Probably, I was able to fix the problem without disabling the slice pool . |
In my last comment on the code i suggested solution without disabling pool, but your solution looks better, all my yesterday tests are green. |
Thanks @goccy and @IncSW for taking such an interested! Looking at the made changes, i am pretty sure that i would have needed lots of time to build up the context to fix them. I tested the changes (with and without the current version of #200) and my reproducers work now as well as another set of tests in our test suite. However, there are unfortunately still problems left:
Do you know any tooling to reduce JSON data automatically? If not, i could help out creating a reducer. Please let me know. Since all tests passed and the code got reviewed(?), maybe this PR should be just merged and i will continue do add reproducers to new issues? What is your take on this? |
Agreed, thanks!
I am on it. Finding send-able reproducers is a pain. Do you know of any "reducer" tooling? If not, i will create one. |
Btw: I think this package also found a problem in our code base. We have a type that looks like this
And the values for "someInterface" are always "null" in that case so encoding/json automatically decodes to null, however go-json does not like that. Will report that as well, because the behavior is different to encoding/json, but i found it interesting since it is practically a bug in our code. |
Sorry, I know the tools for fuzzing, but I don't know any "reducer" tooling . |
fix #195
In decoding
UnmarshalJSON
, it is assumed that the passed pointer is used as it is as a receiver. If a type that implements UnmarshalJSON is specified as an element of slice, this should be taken into consideration so that the pointer of the reused slice element is not passed as it is.