Boost Lockfree Stack causes crash on construction


I’m trying to have a lockfree stack I can work with. I’ve been trying to get Boost’s to work with JUCE-

My project will compile fine, but if I so much as construct a stack (ex: boost::lockfree::stack<int> midiPitchStack; ) the plug-in will cause its host to crash upon being scanned. For example, the sample plug-in host crashes on startup even without my plug-in being instantiated; same happens with Ableton Live.

Any ideas? Or suggestions of other good lockfree LIFOs?

You know juce already has a lock-free FIFO? AbstractFIFO is the class.

I’d seen that in the API, though I was specifically looking for a LIFO. With some thought into the logic I’m using, though, I may be able to make the included FIFO work.

Sorry, I misread your post as FIFO, not LIFO…

Are you specifying the capacity in the template arguments? If not, you will very likely have run-time errors. See

trying boost::lockfree::stack<int> MIDIPitchStack(128); won’t even compile- saying “Expected Parameter Declarator” and that there’s a missing right parenthesis. I’m not sure why this is; and it is how the stack was constructed in the example here-

When I was doing just ‘boost::lockfree::stack MIDIPitchStack;’ I tried calling its method reserve() to do my allocation, in the prepareToPlay method of my audio plugin; it would compile, but leaving that in or commenting it out does not fix the crashing.

I think the example might be outdated. I just tested this, and if you specify neither a capacity nor an allocator in the template parameters (not constructor parameters), it will cause a runtime error. I haven’t used boost::lockfree with allocators, so I’m not sure how they are used. However, if you’d like to give it a spin with a fixed capacity (e.g. boost::lockfree::capacity<512>) and don’t give any arguments in the constructor, I believe it should work.

EDIT: you can use backticks (`like this`) to write code, and the < > symbols won’t be stripped out…