Boost Lockfree Stack causes crash on construction


#1

Hello,

I’m trying to have a lockfree stack I can work with. I’ve been trying to get Boost’s to work with JUCE-
http://www.boost.org/doc/libs/1_53_0/doc/html/boost/lockfree/stack.html

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?


#2

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


#3

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.


#4

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


#5

Are you specifying the capacity in the template arguments? If not, you will very likely have run-time errors. See http://www.boost.org/doc/libs/1_61_0/doc/html/lockfree.html#lockfree.introduction___motivation.data_structure_configuration


#6

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- http://www.boost.org/doc/libs/1_54_0/doc/html/lockfree/examples.html

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.


#7

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…