Crashing after loading font - fatal at fatalSignalHandler

Hello,

The plugin compiles and installs well but Rack crashes when trying to add a module ( right after loading a font in the stack trace below). I am guessing it is because it doesn’t like the plugin (TestRackPlug). This is strange as it worked well last time I compiled and loaded & I am sure that nothing has changed (due to use of git).

Does anyone know what Fatal signal 11 means or can you offer any other advice?

OS - MacOs 10.15.7
Rack - Rack-2.git.042a9ce0-mac
SDK - Rack-SDK-2.git.042a9ce0-mac

...stuff...
[0.593 info src/window/Svg.cpp:28 loadFile] Loaded SVG /Users/me/Documents/Rack2/plugins/Fundamental/res/VCA-1.svg
[0.594 info src/window/Svg.cpp:28 loadFile] Loaded SVG /Applications/VCV Rack 2.app/Contents/Resources/res/ComponentLibrary/Plug.svg
[0.594 info src/window/Svg.cpp:28 loadFile] Loaded SVG /Applications/VCV Rack 2.app/Contents/Resources/res/ComponentLibrary/PlugPort.svg
[0.594 info adapters/standalone.cpp:229 main] Running window
[0.629 info src/window/Window.cpp:38 loadFile] Loaded font /Applications/VCV Rack 2.app/Contents/Resources/res/fonts/ShareTechMono-Regular.ttf
[0.630 info src/window/Window.cpp:38 loadFile] Loaded font /Users/me/Documents/Rack2/plugins/Fundamental/res/sudo/Sudo.ttf
[3.374 info src/window/Svg.cpp:28 loadFile] Loaded SVG /Users/me/Documents/Rack2/plugins/TestRackPlug/res/Gain.svg
[3.374 info src/window/Svg.cpp:28 loadFile] Loaded SVG /Applications/VCV Rack 2.app/Contents/Resources/res/ComponentLibrary/ScrewBlack.svg
[3.378 info src/window/Svg.cpp:28 loadFile] Loaded SVG /Users/me/Documents/Rack2/plugins/TestRackPlug/res/Swerver.svg
[3.378 info src/window/Svg.cpp:28 loadFile] Loaded SVG /Applications/VCV Rack 2.app/Contents/Resources/res/ComponentLibrary/MediumLight.svg
[3.382 info src/window/Svg.cpp:28 loadFile] Loaded SVG /Users/me/Documents/Rack2/plugins/TestRackPlug/res/Tremolo.svg
[3.386 info src/window/Svg.cpp:28 loadFile] Loaded SVG /Users/me/Documents/Rack2/plugins/TestRackPlug/res/TestOscillator.svg
[3.386 info src/window/Window.cpp:38 loadFile] Loaded font /Users/me/Documents/Rack2/plugins/TestRackPlug/res/Segment7Standard.ttf
[3.391 fatal adapters/standalone.cpp:49 fatalSignalHandler] Fatal signal 11. Stack trace:
26: 1   Rack                                0x00000001046b730d _ZL18fatalSignalHandleri + 45
25: 2   libsystem_platform.dylib            0x00007fff72cd55fd _sigtramp + 29
24: 3   ???                                 0x0000000000000009 0x0 + 9
23: 4   libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
22: 5   libRack.dylib                       0x000000010478b7c1 _ZN4rack3app12ModuleWidget4drawERKNS_6widget6Widget8DrawArgsE + 97
21: 6   libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
20: 7   libRack.dylib                       0x00000001047f0657 _ZN4rack6widget17FramebufferWidget15drawFramebufferEv + 199
19: 8   libRack.dylib                       0x00000001047f03ee _ZN4rack6widget17FramebufferWidget6renderENS_4math3VecES3_NS2_4RectE + 1118
18: 9   libRack.dylib                       0x00000001047efe40 _ZN4rack6widget17FramebufferWidget4drawERKNS0_6Widget8DrawArgsE + 528
17: 10  libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
16: 11  libRack.dylib                       0x00000001047f21d1 _ZN4rack6widget10ZoomWidget4drawERKNS0_6Widget8DrawArgsE + 129
15: 12  libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
14: 13  libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
13: 14  libRack.dylib                       0x00000001047778ea _ZN4rack3app7browser8ModelBox4drawERKNS_6widget6Widget8DrawArgsE + 346
12: 15  libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
11: 16  libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
10: 17  libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
9: 18  libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
8: 19  libRack.dylib                       0x00000001047ead24 _ZN4rack2ui12ScrollWidget4drawERKNS_6widget6Widget8DrawArgsE + 52
7: 20  libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
6: 21  libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
5: 22  libRack.dylib                       0x00000001047f1dc6 _ZN4rack6widget6Widget4drawERKNS1_8DrawArgsE + 374
4: 23  libRack.dylib                       0x00000001047f68dc _ZN4rack6window6Window4stepEv + 1836
3: 24  libRack.dylib                       0x00000001047f6198 _ZN4rack6window6Window3runEv + 40
2: 25  Rack                                0x00000001046b6f06 main + 2774
1: 26  libdyld.dylib                       0x00007fff72adccc9 start + 1
0: 27  ???                                 0x0000000000000001 0x0 + 1

Segmentation fault, which can happen (in a very loose sense!) non-deterministically; that might explain why you’re seeing it now and not before even with no apparent code change.

On a quick glance it’s probably not related to the font load, I think that’s probably just the last loadFile log line before Rack starts the loop.

Are you set up with a debugger? If not, the simplest thing to do would be to include DEBUG() or INFO() calls in your plugin to see how far you get. If you can isolate what’s happening just before the crash it may make the bug more apparent.

1 Like

Oh, no fun. No, haven’t actually set up a proper development environment yet (trying to be quick does not usually pay off and yet…).

Will give that a try tomorrow. Thanks!

1 Like

Does your draw method look like this: (from VCV Manual - Migrating v1 Plugins to v2)

void draw(const DrawArgs& args) override {
	std::shared_ptr<Font> font = APP->window->loadFont(fontPath);
	if (font) {
		nvgFontFaceId(args.vg, font->handle);
		...
	}
}

Notice the if (font) { block, I had to add this to a migrated module to stop it crashing.

1 Like

Edit: I thought that I had it, but the module crashes every time unless I had it loaded before. In that case, it works but I can’t remove it and add a new instance without Rack crashing. I see that the font has loaded but then Rack crashes with a message that appears to be the same as the first that I put in this thread.

[6.837 fatal adapters/standalone.cpp:49 fatalSignalHandler] Fatal signal 11.

I had some info here before, but I am replacing it with some the module code in the hope that it makes it easier for others to reproduce.

The module writes different numbers to two different instances of TestDisplayWidget .

#include "plugin.hpp"

struct Test : Module
{
    enum ParamId
    {
        TEST_PARAM,
        PARAMS_LEN
    };
    enum InputId
    {
        INPUTS_LEN
    };
    enum OutputId
    {
        OUTPUTS_LEN
    };
    enum LightId
    {
        LIGHTS_LEN
    };

    float disp_one;
    float disp_two;

    Test()
    {
        config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);
        configParam(TEST_PARAM, 0.f, 1.f, 0.f, "");
    }

    void process(const ProcessArgs& args) override
    {
        disp_one = params[TEST_PARAM].getValue();
        disp_two = disp_one + 0.5;
    }
};

struct TestDisplayWidget : Widget
{
    Test* m;
    int t = 0;

    TestDisplayWidget(Test* module, int type)
    {
        m = module;
        t = type;
    }

    void draw(const DrawArgs& args) override
    {
        std::shared_ptr<Font> font = APP->window->loadFont(
            asset::plugin(pluginInstance, "res/fonts/Segment7Standard.ttf"));

        if (font)
        {
            INFO("draw() -> SUCCESS -> font loaded!");

            char display_string[10];

            if (t == 0)
            {
                snprintf(display_string,
                         sizeof display_string,
                         "%f",
                         (double) m->disp_one);
            }
            else
            {
                snprintf(display_string,
                         sizeof display_string,
                         "%f",
                         (double) m->disp_two);
            }

            nvgFontSize(args.vg, 12);
            nvgFontFaceId(args.vg, font->handle);
            nvgTextLetterSpacing(args.vg, 1);

            nvgBeginPath(args.vg);
            nvgFillColor(args.vg, nvgRGBA(0x00, 0x00, 0x00, 0xff));

            nvgText(args.vg, 0, 0, display_string, NULL);
        }
        else
        {
            INFO("draw() -> FAIL -> font not loaded!");
        }
    }
};

struct TestWidget : ModuleWidget
{
    TestWidget(Test* module)
    {
        setModule(module);
        setPanel(createPanel(asset::plugin(pluginInstance, "res/Test.svg")));

        addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
        addChild(
            createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
        addChild(createWidget<ScrewSilver>(
            Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
        addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH,
                                               RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));

        addParam(createParam<RoundBlackKnob>(
            mm2px(Vec(26.73, 40.492)), module, Test::TEST_PARAM));

        float xD1 = 10.941 + 10.0;
        float yD1 = 78.376 + 4.6;
        TestDisplayWidget* display1 = new TestDisplayWidget(module, 0);
        display1->box.pos = mm2px(Vec(xD1, yD1));
        addChild(display1);

        float xD2 = 10.941 + 10.0;
        float yD2 = 86.537 + 4.6;
        TestDisplayWidget* display2 = new TestDisplayWidget(module, 1);
        display2->box.pos = mm2px(Vec(xD2, yD2));
        addChild(display2);
    }
};

Model* modelTest = createModel<Test, TestWidget>("Test");

Side note, but confusing while trying to solve this -

Following the advise & using this, the font is not found.

std::shared_ptr<Font> font =
            APP->window->loadFont("res/fonts/Segment7Standard.ttf");

In Fundamental the advice does not seem to be followed in the Vis module.

1 Like

You need to store the fontPath first like:

std::string fontPath = “res/fonts/Segment7Standard.ttf”;

Then in your draw code you should have something like:

std::shared_ptr font = APP->window->loadFont(asset::plugin(pluginInstance, fontPath));

1 Like

Hi @steve. Thank you for that. Ultimately, it was as simple as it seemed it should have been. I made the mistake of creating it in the wrong place.