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

JavaScript out of memory crashes the program #210

Open
jonatanklosko opened this issue Feb 3, 2025 · 0 comments
Open

JavaScript out of memory crashes the program #210

jonatanklosko opened this issue Feb 3, 2025 · 0 comments

Comments

@jonatanklosko
Copy link

jonatanklosko commented Feb 3, 2025

When converting a large VegaLite spec, the JS runtime OOMs and results in a crash.

See 4ee79be for an example reproducing this. This is the output:

Output
$ cargo run --example conversion_oom
   Compiling vl-convert-rs v1.7.0 (/Users/jonatanklosko/git/vl-convert/vl-convert-rs)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.28s
     Running `target/debug/examples/conversion_oom`

<--- Last few GCs --->

[25397:0x1700f0000]    15556 ms: Scavenge (reduce) (interleaved) 1392.9 (1399.5) -> 1392.2 (1399.5) MB, pooled: 0 MB, 2.38 / 0.00 ms  (average mu = 0.195, current mu = 0.169) allocation failure;
[25397:0x1700f0000]    15977 ms: Mark-Compact (reduce) 1392.5 (1399.5) -> 1390.7 (1399.0) MB, pooled: 0 MB, 403.50 / 0.00 ms  (+ 274.8 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 725 ms) (average mu = 0.171,

<--- JS stacktrace --->



#
# Fatal JavaScript out of memory: Ineffective mark-compacts near heap limit
#
==== C stack trace ===============================

    0   conversion_oom                      0x000000010930b494 v8::base::debug::StackTrace::StackTrace() + 24
    1   conversion_oom                      0x00000001093112ec v8::platform::(anonymous namespace)::PrintStackTrace() + 24
    2   conversion_oom                      0x0000000109301a0c v8::base::FatalOOM(v8::base::OOMType, char const*) + 68
    3   conversion_oom                      0x0000000109365724 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) + 616
    4   conversion_oom                      0x000000010952526c v8::internal::Heap::stack() + 0
    5   conversion_oom                      0x0000000109537bd0 _ZZN2v88internal4Heap14CollectGarbageENS0_15AllocationSpaceENS0_23GarbageCollectionReasonENS_15GCCallbackFlagsEENK3$_1clEv + 1836
    6   conversion_oom                      0x000000010953748c _ZN4heap4base5Stack24SetMarkerAndCallbackImplIZN2v88internal4Heap14CollectGarbageENS4_15AllocationSpaceENS4_23GarbageCollectionReasonENS3_15GCCallbackFlagsEE3$_1EEvPS1_PvPKv + 40
    7   conversion_oom                      0x0000000109d7fa84 PushAllRegistersAndIterateStack + 40
    8   conversion_oom                      0x00000001095233e8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) + 412
    9   conversion_oom                      0x00000001094ad808 v8::internal::StackGuard::HandleInterrupts(v8::internal::StackGuard::InterruptLevel) + 504
    10  conversion_oom                      0x00000001098e6f38 v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) + 304
    11  conversion_oom                      0x000000010a6779f4 Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit + 84
    12  conversion_oom                      0x000000010a664ec8 Builtins_StringPrototypeReplace + 1192
    13  ???                                 0x0000000300040cdc 0x0 + 12885167324
    14  ???                                 0x000000030006efd8 0x0 + 12885356504
    15  ???                                 0x00000003000686bc 0x0 + 12885329596
    16  ???                                 0x0000000300068c14 0x0 + 12885330964
    17  ???                                 0x00000003000677f8 0x0 + 12885325816
    18  conversion_oom                      0x000000010a5e0838 Builtins_InterpreterEntryTrampoline + 280
    19  conversion_oom                      0x000000010a5e0838 Builtins_InterpreterEntryTrampoline + 280
    20  conversion_oom                      0x000000010a5e0838 Builtins_InterpreterEntryTrampoline + 280
    21  conversion_oom                      0x000000010a5e0838 Builtins_InterpreterEntryTrampoline + 280
    22  conversion_oom                      0x000000010a5e0838 Builtins_InterpreterEntryTrampoline + 280
    23  conversion_oom                      0x000000010a5e0838 Builtins_InterpreterEntryTrampoline + 280
    24  conversion_oom                      0x000000010a5e0838 Builtins_InterpreterEntryTrampoline + 280
    25  conversion_oom                      0x000000010a5e0838 Builtins_InterpreterEntryTrampoline + 280
    26  conversion_oom                      0x000000010a61de20 Builtins_AsyncFunctionAwaitResolveClosure + 64
    27  conversion_oom                      0x000000010a6eb298 Builtins_PromiseFulfillReactionJob + 56
    28  conversion_oom                      0x000000010a60d214 Builtins_RunMicrotasks + 564
    29  conversion_oom                      0x000000010a5de3f0 Builtins_JSRunMicrotasksEntry + 176
    30  conversion_oom                      0x00000001094826ec v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) + 1524
    31  conversion_oom                      0x0000000109482fac v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) + 88
    32  conversion_oom                      0x00000001094830e4 v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*) + 60
    33  conversion_oom                      0x00000001094ab8b8 v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) + 356
    34  conversion_oom                      0x00000001094ab724 v8::internal::MicrotaskQueue::PerformCheckpointInternal(v8::Isolate*) + 88
    35  conversion_oom                      0x000000010949d678 v8::internal::Isolate::FireCallCompletedCallbackInternal(v8::internal::MicrotaskQueue*) + 100
    36  conversion_oom                      0x0000000109368c44 v8::Script::Run(v8::Local<v8::Context>, v8::Local<v8::Data>) + 844
    37  conversion_oom                      0x0000000108ed7b44 _ZN2v86script34_$LT$impl$u20$v8..data..Script$GT$3run28_$u7b$$u7b$closure$u7d$$u7d$17h3f6ce67ddec0e497E + 224
    38  conversion_oom                      0x0000000108f42a98 _ZN2v86script34_$LT$impl$u20$v8..data..Script$GT$3run17h932a130a10f2b53bE + 724
    39  conversion_oom                      0x0000000108dbd5b4 deno_core::runtime::jsrealm::JsRealm::execute_script::h95192f96f9d212e4 + 1844
    40  conversion_oom                      0x0000000104ecc5e4 deno_core::runtime::jsruntime::JsRuntime::execute_script::h6b83a6db95aa7410 + 276
    41  conversion_oom                      0x00000001052dc0b4 deno_runtime::worker::MainWorker::execute_script::h35e3a462f691df25 + 36
    42  conversion_oom                      0x00000001045a27ec _ZN13vl_convert_rs9converter16InnerVlConverter15vegalite_to_svg28_$u7b$$u7b$closure$u7d$$u7d$17h320b968e08b119a5E + 3500
    43  conversion_oom                      0x00000001045a7f90 _ZN13vl_convert_rs9converter11VlConverter3new28_$u7b$$u7b$closure$u7d$$u7d$28_$u7b$$u7b$closure$u7d$$u7d$17h1ff7581f32050117E + 3760
    44  conversion_oom                      0x0000000104592d00 _ZN72_$LT$core..pin..Pin$LT$P$GT$$u20$as$u20$core..future..future..Future$GT$4poll17hbe9a506568894effE + 56
    45  conversion_oom                      0x000000010457cb54 _ZN5tokio7runtime9scheduler14current_thread9CoreGuard8block_on28_$u7b$$u7b$closure$u7d$$u7d$28_$u7b$$u7b$closure$u7d$$u7d$28_$u7b$$u7b$closure$u7d$$u7d$17h3d5274ef6be95217E + 48
    46  conversion_oom                      0x000000010457c938 _ZN5tokio7runtime9scheduler14current_thread9CoreGuard8block_on28_$u7b$$u7b$closure$u7d$$u7d$28_$u7b$$u7b$closure$u7d$$u7d$17hbcfb9ec4c69b27f8E + 248
    47  conversion_oom                      0x000000010457ae38 tokio::runtime::scheduler::current_thread::Context::enter::he9d694cf711b2463 + 316
    48  conversion_oom                      0x000000010457c374 _ZN5tokio7runtime9scheduler14current_thread9CoreGuard8block_on28_$u7b$$u7b$closure$u7d$$u7d$17hdb50f69bfed5d960E + 412
    49  conversion_oom                      0x000000010457ba60 _ZN5tokio7runtime9scheduler14current_thread9CoreGuard5enter28_$u7b$$u7b$closure$u7d$$u7d$17h3f1b7684abc662c3E + 28
    50  conversion_oom                      0x00000001045736dc _ZN5tokio7runtime7context6scoped15Scoped$LT$T$GT$3set17h4ff6f128d2c84b9eE + 168
    51  conversion_oom                      0x0000000104575d7c _ZN5tokio7runtime7context13set_scheduler28_$u7b$$u7b$closure$u7d$$u7d$17h6fb4fb372555fe5cE + 52
    52  conversion_oom                      0x00000001045a9a98 _ZN3std6thread5local17LocalKey$LT$T$GT$8try_with17h818e318774406e4dE + 228
    53  conversion_oom                      0x00000001045a9164 _ZN3std6thread5local17LocalKey$LT$T$GT$4with17h5b81526c0c3c01f3E + 36
    54  conversion_oom                      0x0000000104575cb4 tokio::runtime::context::set_scheduler::h3e01471250cf1edf + 60
    55  conversion_oom                      0x000000010457b55c tokio::runtime::scheduler::current_thread::CoreGuard::enter::h343d76059f4a24a5 + 356
    56  conversion_oom                      0x000000010457bb00 tokio::runtime::scheduler::current_thread::CoreGuard::block_on::hb397b7cfb3a5fdb2 + 28
    57  conversion_oom                      0x0000000104579e28 _ZN5tokio7runtime9scheduler14current_thread13CurrentThread8block_on28_$u7b$$u7b$closure$u7d$$u7d$17ha2938297aa000fefE + 160
    58  conversion_oom                      0x0000000104595e58 tokio::runtime::context::runtime::enter_runtime::hbbfdbbd8bcbfd40e + 220
    59  conversion_oom                      0x0000000104579d58 tokio::runtime::scheduler::current_thread::CurrentThread::block_on::hd6cbed5a28e79680 + 164
    60  conversion_oom                      0x000000010459ab2c tokio::runtime::runtime::Runtime::block_on::h9fe4cdd5a4b4cd0f + 200
    61  conversion_oom                      0x00000001045a7044 _ZN13vl_convert_rs9converter11VlConverter3new28_$u7b$$u7b$closure$u7d$$u7d$17hea9479eb6b34c24bE + 120
[1]    25397 trace trap  cargo run --example conversion_oom

This originally came up with a "real" chart, but I managed to reproduce it by generating a very simple spec with 1mln data points, which is the spec in the example (below code is Elixir, but should give the idea):

graph =
  Vl.new()
  |> Vl.data_from_values(x: 1..1000000, y: 1..1000000, z: 1..1000000)
  |> Vl.mark(:point)
  |> Vl.encode_field(:x, "x", type: :quantitative)
  |> Vl.encode_field(:y, "y", type: :quantitative)
  |> Vl.encode_field(:color, "z", type: :quantitative)

The spec actually does render in the browser, but it's natural that certain size would result in conversion OOM. The question is whether this OOM is expected, and more importantly, if it could be handled more gracefully by returning an error, instead of crashing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant