Skip to content

Conversation

bjodah
Copy link
Contributor

@bjodah bjodah commented Nov 27, 2022

When building symengine with boostmp, I get a test failure in symengine.py's test suite. This is due to integer division in boost's multiprecision library throws, and we never catch the c++ excpetion, leading to the exit of the CPython process. I suspect we need to pass a policy somewhere, but first I want to reproduce the error in our CI run.

TODO:

  • fix our use of boost's mulitprecision integer so that it does not throw for division-by-zero.

Stack trace:

gdb backtrace
tests/test_ntheory.py::test_divides                                                                      
Thread 1 "python3" received signal SIGABRT, Aborted.                                                     
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350246400) at ./nptl/pthread_kill.c:44  
44      ./nptl/pthread_kill.c: No such file or directory.                                                
(gdb) bt                                                                                                 
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737350246400) at ./nptl/pthread_kill.c:
44                                                                                                       
#1  __pthread_kill_internal (signo=6, threadid=140737350246400) at ./nptl/pthread_kill.c:78              
#2  __GI___pthread_kill (threadid=140737350246400, signo=signo@entry=6) at ./nptl/pthread_kill.c:89      
#3  0x00007ffff7c8d476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26                    
#4  0x00007ffff7c737f3 in __GI_abort () at ./stdlib/abort.c:79                                           
#5  0x00007ffff41eebbe in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6                                
#6  0x00007ffff41fa24c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6                                
#7  0x00007ffff41fa2b7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6                  
#8  0x00007ffff41fa518 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6                       
#9  0x00007ffff4c905c4 in boost::throw_exception (e=..., loc=...) at /usr/include/bo
ost/throw_exception.hpp:171                                                                              
#10 0x00007ffff4caa75a in boost::multiprecision::backends::divide_unsigned_helper >, boost::multiprecision::backends::cpp_int_backend
<0u, 0u, (boost::multiprecision::cpp_integer_type)1, (boost::multiprecision::cpp_int_check_type)0, std::a
llocator > > (result=0x0, x=..., y=0, r=...) at /usr/include/boost/multiprecision/cpp
_int/divide.hpp:339                                                                                      
#11 0x00007ffff4c9fd3e in boost::multiprecision::backends::divide_unsigned_helper >, boost::multiprecision::backends::cpp_int_backend
<0u, 0u, (boost::multiprecision::cpp_integer_type)1, (boost::multiprecision::cpp_int_check_type)0, std::a
llocator >, boost::multiprecision::backends::cpp_int_backend<0u, 0u, (boost::multipre
cision::cpp_integer_type)1, (boost::multiprecision::cpp_int_check_type)0, std::allocator > > (result=0x0, x=..., y=..., r=...) at /usr/include/boost/multiprecision/cpp_int/divide.hpp:73     
#12 0x00007ffff4d7f2c0 in boost::multiprecision::backends::eval_modulus<0u, 0u, (boost::multiprecision::c
pp_integer_type)1, (boost::multiprecision::cpp_int_check_type)0, std::allocator, 0u, 
0u, (boost::multiprecision::cpp_integer_type)1, (boost::multiprecision::cpp_int_check_type)0, std::alloca
tor, 0u, 0u, (boost::multiprecision::cpp_integer_type)1, (boost::multiprecision::cpp_
int_check_type)0, std::allocator > (result=..., a=..., b=...) at /usr/include/boost/m
ultiprecision/cpp_int/divide.hpp:532                                                                     
#13 0x00007ffff4effcf4 in boost::multiprecision::operator% > > (a=..., b=...) at /usr/include/boost/multiprecision/detail/no_et_ops.h
pp:176                                                                                                   
#14 0x00007ffff4f97908 in SymEngine::mp_divisible_p (a=..., b=...) at //symengine-d21cfe1ed57168f2b4e0d5b
e854632814387a3f1/symengine/mp_class.h:993                                                               
#15 0x00007ffff4f88c44 in SymEngine::divides (a=..., b=...) at /symengine-d21cfe1ed57168f2b4e0d5be8546328
14387a3f1/symengine/ntheory.cpp:163                                                                      
#16 0x00007ffff570e5a7 in __pyx_pf_9symengine_3lib_17symengine_wrapper_138divides (__pyx_self=0x0, __pyx_
v_a=0x7ffff78600d0, __pyx_v_b=0x7ffff78600d0) at /opt/symengine.py-74867351ed7ffb2f2e97f5807976b54953c0b7
1d/build/lib.linux-x86_64-cpython-310/symengine/lib/symengine_wrapper.cpp:110638
the exception being thrown
#10 0x00007ffff4caa75a in boost::multiprecision::backends::divide_unsigned_helper >, boost::multiprecision::backends::cpp_int_backend<0u, 0u, (boost::multiprecision::cpp_integer_type)1, (boost::multiprecision::cpp_int_check_type)0, std::allocator > > (result=0x0, x=..., y=0, r=...) at /usr/include/boost/multiprecision/cpp_int/divide.hpp:339
339           BOOST_THROW_EXCEPTION(std::overflow_error("Integer Division by zero."))

@bjodah bjodah force-pushed the add-boostmp-to-test-matrix branch from 1797bb1 to a3eb61a Compare November 27, 2022 17:31
@bjodah bjodah merged commit 560bafb into symengine:master Jan 16, 2023
@bjodah
Copy link
Contributor Author

bjodah commented Jan 16, 2023

I hope a self merge was OK here (nothing too controversial), this brings master (more) up to date with (c++) symengine.

@bjodah bjodah deleted the add-boostmp-to-test-matrix branch February 4, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant