Skip to content
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

prevent an infinite loop #31

Merged
merged 2 commits into from Jul 27, 2020
Merged

prevent an infinite loop #31

merged 2 commits into from Jul 27, 2020

Conversation

Fil
Copy link
Member

@Fil Fil commented Jul 6, 2020

The situation happens in force simulations when a point is horribly far (maybe because of a programming error, or because we set the wrong parameters on an experimental force). Then forceCollide calls quadtree(nodes, x,,y), which tries to cover by repeatedly doubling z=0. This ends up crashing the browser.

The situation happens in force simulations when a point is horribly far (maybe because of a programming error, or because we set the wrong parameters on an experimental force). Then forceCollide calls quadtree(nodes, x,,y), which tries to cover by repeatedly doubling z=0. This ends up crashing the browser.
@Fil
Copy link
Member Author

Fil commented Jul 6, 2020

test:

tape("quadtree.cover() does not crash on huge values", function(test) {
  d3_quadtree.quadtree([[1e23, 0]]);
  test.end();
});

result:

<--- Last few GCs --->

[42466:0x103b14000]    11271 ms: Mark-sweep 1396.5 (1425.2) -> 1396.2 (1425.7) MB, 1207.9 / 0.0 ms  (+ 0.0 ms in 68 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1217 ms) (average mu = 0.162, current mu = 0.013) alloca[42466:0x103b14000]    12525 ms: Mark-sweep 1398.3 (1425.7) -> 1397.9 (1427.2) MB, 1251.7 / 0.0 ms  (average mu = 0.088, current mu = 0.002) allocation failure scavenge might not succeed


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0xe6b825dbe3d]
Security context: 0x029c33e1e6e9 <JSObject>
    1: tree_cover [0x29c08a2d7e9] [/Users/fil/Sites/d3/d3-quadtree/dist/d3-quadtree.js:~93] [pc=0xe6b825e5b7e](this=0x029cfb3a69a9 <Quadtree map = 0x29c631185c9>,x=0x029cfb3a6999 <Number 1e+23>,y=0x029cfb3a6989 <Number 0>)
    2: addAll [0x29c08a2da29] [/Users/fil/Sites/d3/d3-quadtree/dist/d3-quadtree.js:83] [bytecode=0x29c08a4e929 offset=257](this=0x029cfb3a...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1009746b6 node::Abort() (.cold.1) [/usr/local/Cellar/node@10/10.16.3/bin/node]
 2: 0x10003b9d6 node_module_register [/usr/local/Cellar/node@10/10.16.3/bin/node]
 3: 0x10003bb97 node::OnFatalError(char const*, char const*) [/usr/local/Cellar/node@10/10.16.3/bin/node]
 4: 0x100178c5b v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node@10/10.16.3/bin/node]
 5: 0x100178bfd v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node@10/10.16.3/bin/node]
 6: 0x10042d170 v8::internal::Heap::UpdateSurvivalStatistics(int) [/usr/local/Cellar/node@10/10.16.3/bin/node]
 7: 0x10042edad v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/Cellar/node@10/10.16.3/bin/node]
 8: 0x10042c44a v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/Cellar/node@10/10.16.3/bin/node]
 9: 0x10042b25b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/Cellar/node@10/10.16.3/bin/node]
10: 0x100433882 v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/Cellar/node@10/10.16.3/bin/node]
11: 0x1004338cc v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/Cellar/node@10/10.16.3/bin/node]
12: 0x1004141bb v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/Cellar/node@10/10.16.3/bin/node]
13: 0x1005ee4e1 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/Cellar/node@10/10.16.3/bin/node]
14: 0xe6b825dbe3d

@Fil Fil added the bugfix label Jul 10, 2020
@Fil Fil mentioned this pull request Jul 10, 2020
Merged
1 task
@Fil Fil changed the base branch from master to two July 27, 2020 09:00
@Fil Fil merged commit fdcf997 into two Jul 27, 2020
@Fil Fil deleted the prevent-crash branch August 17, 2020 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

1 participant