Boost C++ Libraries: Ticket #7767: lockfree queue allocation problem https://svn.boost.org/trac10/ticket/7767 <p> The default constructor of boost::lockfree::queue&lt;int&gt;<br /> try to allocate 0xffffffffffffffff elements for pool. </p> <p> Revision: 81719, queue.hpp, line 154 </p> <pre class="wiki"> pool(node_allocator(), capacity) </pre><p> "capacity" is 0xffffffffffffffff in my environment(VS 2012 Express for Desktop). </p> <p> The other constructors works fine. </p> <p> The problem occurred on both of 32bit and 64bit.<br /> (in 32bit, the "capacity" was 0xffffffff) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7767 Trac 1.4.3 timblechmann Wed, 05 Dec 2012 09:54:23 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7767#comment:1 https://svn.boost.org/trac10/ticket/7767#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> not a bug: you have not configured the queue to have a capacity that is specified at compile time, so you should not use the default constructor. there is a run-time assertion, but unfortunately that fires after the memory pool is constructed with -1, which is a bit confusing. let me see, if i can improve that a bit ... </p> Ticket pn.suzuki.kojiro@… Wed, 05 Dec 2012 10:36:53 GMT <link>https://svn.boost.org/trac10/ticket/7767#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7767#comment:2</guid> <description> <p> Why don't you split implementation by have_capacity? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>timblechmann</dc:creator> <pubDate>Wed, 05 Dec 2012 10:45:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7767#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7767#comment:3</guid> <description> <p> possible, but increases the complexity of the code as one would need an additional abstraction layer. </p> </description> <category>Ticket</category> </item> <item> <author>pn.suzuki.kojiro@…</author> <pubDate>Wed, 05 Dec 2012 15:03:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7767#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7767#comment:4</guid> <description> <p> I don't understand yet, why can't I use the default constructor in this case?<br /> I thought that the default constructor should constructs empty queue with empty pool. </p> <pre class="wiki"> pool(node_allocator(), has_capacity ? capacity : 0) </pre><p> Does this code have a problem? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>timblechmann</dc:creator> <pubDate>Wed, 05 Dec 2012 15:07:27 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7767#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7767#comment:5</guid> <description> <p> if you don't specify a capacity, internal nodes have to be allocated during push() or pop() ... since memory allocation is not lock-free the data-structure is not lock-free anymore ... </p> </description> <category>Ticket</category> </item> <item> <author>Kojiro Suzuki <pn.suzuki.kojiro@…></author> <pubDate>Wed, 05 Dec 2012 15:20:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7767#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7767#comment:6</guid> <description> <p> Thank you for your answers, I understand it now. </p> <p> I have an idea.<br /> If you use the the previous code, and leave the assertion,<br /> it generates assertion without trying to allocate huge elements. </p> <pre class="wiki"> queue(void): head_(tagged_node_handle(0, 0)), tail_(tagged_node_handle(0, 0)), pool(node_allocator(), has_capacity ? capacity : 0) // add this { BOOST_ASSERT(has_capacity); // and leave this initialize(); } </pre> </description> <category>Ticket</category> </item> </channel> </rss>