-
Notifications
You must be signed in to change notification settings - Fork 570
reflect: avoid dereferencing non-pointers in mapassign #718
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
base: master
Are you sure you want to change the base?
Conversation
In order for me to approve this, I'll have to gain understanding of the context of the problem, and the change, in order to have confidence that this is the optimal fix. It's going to take me some time. I'll try to do it as soon as I can. If you can provide more information about the investigation you've done before coming up with the fix, it'd be helpful to me. For example, have you considered an alternative fix where the Unfortunately, I don't know these things off the top of my head because I didn't write the original relevant code, so it takes me longer to review fixes. |
Sorry for the lack of the explanation. My understanding is that pointer type values in GopherJS has [1] https://github.com/gopherjs/gopherjs/blob/master/compiler/natives/src/reflect/reflect.go#L521 I understand that GopherJS people are quite busy. Thank you for taking time. |
tests/misc_test.go
Outdated
func TestJSONWithFixedArray(t *testing.T) { | ||
var v map[string][2]float64 | ||
if err := json.Unmarshal([]byte(`{"a": [350, 350]}`), &v); err != nil { | ||
t.Error(err) |
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.
Since the bug and the fix are in reflect
package, can we make the test lower level and use reflect
directly? Relying on encoding/json
is not optimal, because its internal implementation details may change, rendering the test ineffective.
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.
Done: Used reflect package directly.
ping |
Found that this fix causes a new error on unmarshaling JSON, I couldn't make a minimized case though. |
That's pretty surprising. How big is the non-minimized case? Are you able to share it? |
Ah sorry, the crash was not related to this fix. Please ignore my last comment :-) |
Given that my bug report dates back to July, I'm super happy someone finally found the problem! Some comments:
|
Thanks, I've changed the title.
Not sure what you meant. All tests passed anyway.
Agreed but this is what GopherJS members would do.
Well, I'll do that later. |
Ugh,
I'd want to commit this PR as it is and make another PR for the fix of |
Is that a regression with this change, or is it unrelated? |
I was wondering why there are changes to |
Not sure since |
Fixing some Go files requires regenerating |
What's going on? Probably you are working on WebAssembly version, which is great, but I'm worried that this GopherJS is not updated recently. |
Yes, I am working on the WebAssembly backend for the Go compiler (and other work). Unfortunately this means that I have almost no time left for GopherJS. I feel like GopherJS is in a good enough state to have it further maintained by the community.
|
Hmm, but recently GopherJS is not updated, although there are reported bugs and sent PRs? |
@hajimehoshi Would you be open to helping with maintaining this project? I could give you commit permissions. @shurcooL already has them, but maybe he is also quite busy atm. ;-) |
I'll be glad to help this project :-) I'm afraid I can't do such quick reviews as you did before for a while, but I'd like to try to do my best. |
@shurcooL Wdyt? I think you two should talk a bit to discuss how you want to go about it. |
@hajimehoshi Help with maintaining this project would be greatly appreciated, thanks for the offer. I'll want to discuss it in more detail with you on Slack, hopefully soon. But first let's focus on this PR and the issue(s) it tries to solve. I want to post an (incomplete) update about that. The PR is short and simple, but the issues it tries to solve are difficult. To fix them, it requires good understanding of the type system. That's something I never had a chance to really spend time on fully understanding (and it's not well documented), which makes working on this harder and more time intensive for me. I ended up spending the entire day (!) today on this issue and better understanding it, the relevant concepts of GopherJS type system implementation, and what would be a good overall fix. (In the process, I also found and resolved another issue in reflect package on my WIP 1.10 branch.) That is one of the the main reasons for my delay in getting back; I haven't had the chance to dedicate such a large uninterrupted block of time to this until today, sorry about that. The day was enough to make significant progress on this, but not enough to finish. I'll resume tomorrow. We can talk more about how to move forward. The summary is that... This PR makes a small change that's acceptable, but it's not enough to fix #662 and #717. To really fix those issues (and I have semi-working prototypes of that), many additional changes are needed, and this PR may or may no longer be relevant. That's why I think it might actually make more sense to fix the entire issue at once and review that change; rather than making incremental incomplete steps. But I don't have objections to merging this PR as is either if you strongly prefer (just need to update PR description so it won't close those two issues). |
I'm fine with waiting for fixing the root cause instead of merging my PR. I'd like to know your insights of GopherJS implemention :-) |
Fixes #662 and #717
EDIT: To run only the new test quickly, I did
go run ./tool.go test --run=TestReflectSetMapIndex ./tests/