Auval segmentation fault

 

 

Ok - strange one here.  Might be more an auval issue than a juce one, but still ......

 

I've got an audiounit (which seems fine in any host I try) ... but fails auval with:

 

Test MIDI

/usr/bin/auval: line 11: 44369 Segmentation fault: 11  arch -x86_64 /usr/bin/auvaltool "$@"

 

Now .... if I remove this little bit (juce the setName() part) from the processBlock ....

 

    
    if (myMidiLearners.size() == 0) return;

    for (int i=0; i < myMidiLearners.size(); i++)    {

        myMidiLearners[i]->setName("test"); // commenting out this line makes auval pass

    }

then it's fine.

 

Now .... the midiLearners array is an array of pointers to (fairly) simple objects.

It doesn't actually matter what function I call on those objects (hence the "test" above).  The objects are totally valid (or else I would presumably get a bad access error), but something about accessing the items in an array screws everything up??

 

Totally confused on this one .... must be missing something simple?

 

 

 

 

 

 

Seems pretty clear that your pointers are either null or pointing to junk. Auval may be calling things in your plugin in an order that you're not expecting.

 

 

Ahh no, I see the issue.

 

I was incorrectly initializing the object that contains the array (it's suppose to be a refCounted static object to be shared between plugin instances).

 

I was calling the normal constructor, and so creating more than one Midimanager.

 

Now I'm rewriting it to use something like the singleton pattern, as I understand it.

 typedef ReferenceCountedObjectPtr<MidiManager> Ptr;

 static Ptr myPtr;

 static Ptr getInstance() {

        if (myPtr->getReferenceCount() == 0) return new MidiManager();
        else return myPtr;
  }

    

 and in the CPP file, instantiate the static object ...

MidiManager::Ptr MidiManager::myPtr = new MidiManager();

 

 

Kinda new territory for me .... reading up on it now, but any quick tips would be appreciated.

 

 

 

 

ok - seems to be working.  Good little trick, those shared static refCounted pointers :)

Wow, lots of problems with that code!

Maybe a SharedResourcePointer does what you need?