-
Notifications
You must be signed in to change notification settings - Fork 425
Show callstack in browser upon REPL crashes #2021
Changes from 3 commits
4c5bc2f
2ac8819
43902a6
4ffb7b2
511cb65
4e74412
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,10 +253,17 @@ class ModifiedBindingEntry extends GeneratorEntry { | |
containingGenerator === this.containingGenerator, | ||
"This entry requires effects to be applied and may not be moved" | ||
); | ||
invariant(this.modifiedBinding.value === this.newValue); | ||
invariant( | ||
this.modifiedBinding.value === this.newValue, | ||
"ModifiedBinding's value has been changed since last visit." | ||
); | ||
let [residualBinding, newValue] = context.visitModifiedBinding(this.modifiedBinding); | ||
invariant(this.residualFunctionBinding === undefined || this.residualFunctionBinding === residualBinding); | ||
invariant( | ||
this.residualFunctionBinding === undefined || this.residualFunctionBinding === residualBinding, | ||
"ResidualFunctionBinding has been changed since last visit." | ||
); | ||
this.residualFunctionBinding = residualBinding; | ||
this.modifiedBinding.value = newValue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change really needed? Looks a bit scary to me. I'd rather do less state mutation on the side than more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without it, we run into the following problem: In the provided example
when the
since the This problem actually seems to be at least somewhat independent of the problem caused by the cache/ResidualFunctionBinding, but it was in the same code area and also causes the code to crash. It seems that the more fundamental issue is that we're re-traversing a the heap, which has some sort of assumption that it won't be re-traversed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, that's the underlying problem here... While the introduced assignment makes the invariant violation go away, it changes what happens during the next visiting, which is bad. The right thing to do would be to stop mutating state on the side in these GeneratorEntry's, they should be just values. Instead, build up new data structure in the visitor, a mapping of GeneratorEntry to something --- whatever mutable state there was, and pass that on to the next phase that really needs it, and just throw it away after the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yinghuitan was saying then that it might be easier to detect and reject calls to |
||
this.newValue = newValue; | ||
return true; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Tests that code with heapgraph enabled doesn't crash. | ||
// Regression test for issue #1732. | ||
|
||
// heapGraphFilePath | ||
|
||
(function () { | ||
let a = global.__abstract ? __abstract("number", "5") : 5; | ||
let b, c; | ||
global.f = function() { | ||
b = a + 42; | ||
c = a + 42; | ||
return b; | ||
} | ||
global.__optimize && __optimize(f); | ||
|
||
})(); | ||
|
||
inspect = function() { return global.f(); } |
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 do not think we need this change anymore.