Boost C++ Libraries: Ticket #8423: miller_rabin_test core dump https://svn.boost.org/trac10/ticket/8423 <p> When running the following code in Ubuntu 12.04 (gcc 4.6) with Boost 1.53.0, the program had a core-dump in miller_rabin_test(). </p> <p> The program was doing primality test on 2<sup>(2</sup>5) + 1 when it crashed. Values such as 2<sup>(2</sup>4) + 1 or 2<sup>(2</sup>6) + 1 do not cause such problems. </p> <p> Thanks in advance for looking into it. </p> <p> -Rob </p> <hr /> <p> #include &lt;iostream&gt; </p> <p> #include &lt;boost/multiprecision/cpp_int.hpp&gt; #include &lt;boost/multiprecision/miller_rabin.hpp&gt; #include &lt;boost/multiprecision/random.hpp&gt; </p> <p> namespace mp = boost::multiprecision; </p> <p> typedef mp::cpp_int BIGNUM; </p> <p> int main(int argc, char* argv[]) { </p> <blockquote> <p> <em> Test primality of 2<sup>(2</sup>5) + 1 BIGNUM num = (BIGNUM(1) &lt;&lt; (1u &lt;&lt; 5)) + 1; boost::random::mt19937 prng(clock()); </em></p> </blockquote> <blockquote> <p> std::cout &lt;&lt; "Running primality test for : " &lt;&lt; num; bool isPrime = mp::miller_rabin_test(num, 25, prng); </p> </blockquote> <blockquote> <p> std::cout &lt;&lt; ", result : " </p> <blockquote> <p> &lt;&lt; (isPrime ? "" : "not ") &lt;&lt; "prime." &lt;&lt; std::endl; </p> </blockquote> </blockquote> <blockquote> <p> return 0; </p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8423 Trac 1.4.3 anonymous Wed, 10 Apr 2013 07:19:51 GMT <link>https://svn.boost.org/trac10/ticket/8423#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8423#comment:1</guid> <description> <p> Here's the properly formatted code. Please ignore the malformed snippet above. </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/multiprecision/cpp_int.hpp&gt; #include &lt;boost/multiprecision/miller_rabin.hpp&gt; #include &lt;boost/multiprecision/random.hpp&gt; namespace mp = boost::multiprecision; typedef mp::cpp_int BIGNUM; int main(int argc, char* argv[]) { // Test primality for 2^(2^5) + 1 BIGNUM num = (BIGNUM(1) &lt;&lt; (1u &lt;&lt; 5)) + 1; boost::random::mt19937 prng(clock()); std::cout &lt;&lt; "Running primality test for : " &lt;&lt; num; bool isPrime = mp::miller_rabin_test(num, 25, prng); std::cout &lt;&lt; ", result : " &lt;&lt; (isPrime ? "" : "not ") &lt;&lt; "prime." &lt;&lt; std::endl; return 0; } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Wed, 10 Apr 2013 12:20:11 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8423#comment:2 https://svn.boost.org/trac10/ticket/8423#comment:2 <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">worksforme</span> </li> </ul> <p> Confirmed the issue was in 1.53, also that it's already been fixed for the next release. </p> Ticket stephan@… Fri, 02 Jan 2015 17:08:32 GMT <link>https://svn.boost.org/trac10/ticket/8423#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8423#comment:3</guid> <description> <p> On my 64-bit machine, it crashed for 2<sup>(2</sup>6)+1. I can confirm it's fixed in 1.54. Thanks for documenting the issue (saved me some time) and for fixing it! </p> </description> <category>Ticket</category> </item> </channel> </rss>