Crash in Ardour7 with juce::Label() constructor?

Hello,
i am using JUCE 7 for a plugin, and ardour 7.2.0 as a host for this plugin.

  1. In the Editor, i create an object:
    auto t = new juce::Label();
    this makes Erreur de segmentation (core dumped) in ardour7.
  2. However if i replace it by
    auto t = new juce::Label(" “,” ");
    it is fine. (no error).

This error 1) does not append when i use the plugin with the “juce host” neither with the StandAlone version of the plugin.

I have a similar error with the constructor
auto t = new juce::ComboBox();
and for the moment i don’t know how to repare it?

Do you have an idea where these errors come from?
Thanks,
Frédéric.

There’s not enough code in your example to be sure one way or another, however the use of
new rather than using class members suggests that you may be having issues with c++ memory mangement.

Perhaps post a snippet showing the whole lifecycle of your juce::Label including how you are then accessing it and disposing of it?

Hello, thanks for your answer.
I have identified a little bit better when there is an error:
this is when i used two plugins of Juce together in the same host.

Below is the code and also the full Project to download if you want to test:
(i am with Ubuntu 22.04.2 LTS )
For example these two plugins, that are identical but with different names and if i use them in Juce Plugin-Host, there is a crash with output error message:

JUCE v7.0.5
message 1
[2]+ Erreur de segmentation (core dumped)

If i use only a single plugin, then i works fine and gives the output messages:
JUCE v7.0.5
message 1
message 2
message 3
message 4
message 1
message 2
message 3
message 4
message 1
message 2
message 3
message 4

Projects to download

Directory of the two projects Test and Test2

Code of PluginEditor.h

#pragma once

#include <JuceHeader.h>
#include "./PluginProcessor.h"

using namespace juce;
using namespace std;

//=============================================
class Page : public juce::Component 
{
 public:


    juce::Label *C = nullptr;


	Page()
		{
			cout<<"message 1"<<endl;
			C = new juce::Label();
			cout<<"message 2"<<endl;
			C->setText("Text", juce::dontSendNotification);
			addAndMakeVisible (C);
		}
	
   ~Page()
		{
			cout<<"message 4"<<endl;
			delete C;
		}

    void resized() override
		{
			cout<<"message 3"<<endl;
			C->setBounds (12, 10, 128, 20 ); //  (x, y, width, height)
		}

    void paint(juce::Graphics& g) override
		{
		}

JUCE_LEAK_DETECTOR (Page)
};


//==============================================================================
class Editor  : public juce::AudioProcessorEditor
{
public:

	//-----------

	Page  * page = nullptr; 

	Editor (Processor&);
    ~Editor() override;

    void paint (juce::Graphics&) override;
    void resized() override;

private:
    Processor& processor;

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Editor)
};


Make sure your symbol list is hidden.

Thanks for you reply.
But i am not enough expert to understand what it means.
I have just completed some code, starting from what Projucer gave to me.

Does it mean that:

  1. i have to compile with option -fvisibility=hidden on linux gcc?
  2. or do something else in the code?

Then on Macos is there a similar problem to take care? what do i have to do?
Thanks,
Frederic.

See

Yes it crashes with ardour7 and also with AudioPluginHost . How to check if the symbol list is correctly hidden? I suppose it should be so by default, but may be not on my system?

The link gives the answer as well:


Ok, so, apparently the issue is with a ton of exposed symbols. Building with cmake seems to be fine. If you want to build with Projucer instead, you need to add these flags:

-fvisibility=hidden
-fvisibility-inlines-hidden
-Wl,--no-undefined

Yes, sorry i didn’t understood that was a link. I try put them and check.

Is it the same for gcc, for Xcode and for Visual studio?

No idea. I use CMake

Thanks to everybody in this topic. I confirm, that the problem is solved as suggested above:

To summarize, if we build with Projucer, we need to add these flags for the compiler:

-fvisibility=hidden
-fvisibility-inlines-hidden
-Wl,--no-undefined

(why this is not by default for beginners like me?)

Hello, in my plugin i have to code in C (not C++). The compiler says

cc1: warning: command-line option ‘-fvisibility-inlines-hidden’ is valid for C++/ObjC++ but not for C
Compiling chorus_par.c

I wonder if it explains why my plugin does not work well when i have two plugins and different midi tracks. (May be there is another cause).
Do you know what is the option equivalent to ‘-fvisibility-inlines-hidden’ but for C code?

(I am sorry but i don’t understand very weel what all that means. I just try to debug my plugin that has a problem when two plugins run together)