JS engine now crashes if a juce::var outlives the juce::JavascriptEngine

Repro here: juce_bugs/JSFunctionLifetime/Source/Main.cpp at c9caead4a49db49995d29692e6ab6dae5a0cd303 · FigBug/juce_bugs · GitHub

Code:

juce::var fn;

{
    juce::JavascriptEngine engine;

    auto err = juce::Result::ok();
    fn = engine.evaluate ("(function (x) { return x * 2; })", &err);
}

fn = juce::var(); // kaboom
  • This did not happen with the old juce JS engine
  • Nowhere in docs or breaking changes does it say engine needs to outlive the juce::var

Thank you for reporting.

1 Like