scipr-lab / libsnark

C++ library for zkSNARKs
Other
1.82k stars 583 forks source link

Make check fails on MacOS Mojave #153

Open mathcrypto opened 5 years ago

mathcrypto commented 5 years ago

I tried running tests using the command make check but tests fail and this is the error I get

43% tests passed, 13 tests failed out of 23

Total Test time (real) =  55.17 sec

The following tests FAILED:
      2 - gadgetlib1_simple_test (Child aborted)
      3 - gadgetlib1_r1cs_ppzksnark_verifier_gadget_test (Child aborted)
      7 - gadgetlib2_integration_test (Child aborted)
     10 - relations_qap_test (Child aborted)
     11 - relations_sap_test (Child aborted)
     12 - relations_ssp_test (Child aborted)
     13 - zk_proof_systems_bacs_ppzksnark_test (Child aborted)
     14 - zk_proof_systems_r1cs_ppzksnark_test (Child aborted)
     15 - zk_proof_systems_r1cs_se_ppzksnark_test (Child aborted)
     16 - zk_proof_systems_r1cs_gg_ppzksnark_test (Child aborted)
     17 - zk_proof_systems_ram_ppzksnark_test (Child aborted)
     18 - zk_proof_systems_tbcs_ppzksnark_test (Child aborted)
     19 - zk_proof_systems_uscs_ppzksnark_test (Child aborted)
Errors while running CTest
make[3]: *** [CMakeFiles/check] Error 8
make[2]: *** [CMakeFiles/check.dir/all] Error 2
make[1]: *** [CMakeFiles/check.dir/rule] Error 2
make: *** [check] Error 2
dtebbs commented 5 years ago

I'm seeing the same issue. When running gadgetlib1_simple_test directly I get:

[==========] Running 1 test from 1 test case.                                                                                                
[----------] Global test environment set-up.                                                                                                 
[----------] 1 test from gadgetLib1                                                                                                          
[ RUN      ] gadgetLib1.Integration                                                                                                          
(enter) Call to run_r1cs_ppzksnark              [             ] (121605.2400s x0.00 from start)                                              

================================================================================                                                             
R1CS ppzkSNARK Generator
================================================================================

  (enter) Call to r1cs_ppzksnark_generator      [             ] (121605.2400s x0.00 from start)
    (enter) Call to r1cs_constraint_system::swap_AB_if_beneficial       [             ] (121605.2401s x0.00 from start)
      (enter) Estimate densities                        [             ] (121605.2401s x0.00 from start)
        * Non-zero A-count (estimate): 99
        * Non-zero B-count (estimate): 99
      (leave) Estimate densities                        [0.0000s x1.10] (121605.2401s x0.00 from start)
      Swap is not beneficial, not performing
    (leave) Call to r1cs_constraint_system::swap_AB_if_beneficial       [0.0000s x0.99] (121605.2401s x0.00 from start)
    (enter) Call to r1cs_to_qap_instance_map_with_evaluation    [             ] (121605.2401s x0.00 from start)
libc++abi.dylib: terminating with uncaught exception of type std::invalid_argument: libff::get_root_of_unity: expected n == (1u << logn)
Abort trap: 6

Seems to be related to std::invalid_argument exceptions (and presumably others) not being caught, at least for this test.

The backtrace from lldb is

  * frame #0: 0x00007fff643cf2c6 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff6448abf1 libsystem_pthread.dylib`pthread_kill + 284
    frame #2: 0x00007fff643396a6 libsystem_c.dylib`abort + 127
    frame #3: 0x00007fff61515641 libc++abi.dylib`abort_message + 231
    frame #4: 0x00007fff615157c7 libc++abi.dylib`default_terminate_handler() + 243
    frame #5: 0x00007fff62ac8eeb libobjc.A.dylib`_objc_terminate() + 105
    frame #6: 0x00007fff6152119e libc++abi.dylib`std::__terminate(void (*)()) + 8
    frame #7: 0x00007fff61520f86 libc++abi.dylib`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 27
    frame #8: 0x00007fff61513f99 libc++abi.dylib`__cxa_throw + 113
    frame #9: 0x000000010001ccf6 gadgetlib1_simple_test`std::__1::enable_if<!(std::is_same<libff::Fp_model<4l, libff::bn128_modulus_r>, libff::Double>::value), libff::Fp_model<4l, libff::bn128_modulus_r> >::type libff::get_root_of_unity<libff::Fp_model<4l, libff::bn128_modulus_r> >(n=100) at field_utils.tcc:0:33
    frame #10: 0x000000010001c522 gadgetlib1_simple_test`libfqfft::basic_radix2_domain<libff::Fp_model<4l, libff::bn128_modulus_r> >::basic_radix2_domain(this=0x0000000100502440, m=100) at basic_radix2_domain.tcc:36:19
    frame #11: 0x000000010001bf0c gadgetlib1_simple_test`std::__1::shared_ptr<libfqfft::evaluation_domain<libff::Fp_model<4l, libff::bn128_modulus_r> > > libfqfft::get_evaluation_domain<libff::Fp_model<4l, libff::bn128_modulus_r> >(unsigned long) [inlined] libfqfft::basic_radix2_domain<libff::Fp_model<4l, libff::bn128_modulus_r> >::basic_radix2_domain(this=<unavailable>, m=<unavailable>) at basic_radix2_domain.tcc:27:1
    frame #12: 0x000000010001bf01 gadgetlib1_simple_test`std::__1::shared_ptr<libfqfft::evaluation_domain<libff::Fp_model<4l, libff::bn128_modulus_r> > > libfqfft::get_evaluation_domain<libff::Fp_model<4l, libff::bn128_modulus_r> >(min_size=100) at get_evaluation_domain.tcc:41
    frame #13: 0x0000000100015ec5 gadgetlib1_simple_test`libsnark::qap_instance_evaluation<libff::Fp_model<4l, libff::bn128_modulus_r> > libsnark::r1cs_to_qap_instance_map_with_evaluation<libff::Fp_model<4l, libff::bn128_modulus_r> >(cs=0x00007ffeefbfcb50, t=0x00007ffeefbfcf80) at r1cs_to_qap.tcc:110:74
    frame #14: 0x0000000100008ba6 gadgetlib1_simple_test`libsnark::r1cs_ppzksnark_keypair<libff::bn128_pp> libsnark::r1cs_ppzksnark_generator<libff::bn128_pp>(cs=<unavailable>) at r1cs_ppzksnark.tcc:254:57
    frame #15: 0x0000000100003267 gadgetlib1_simple_test`bool libsnark::run_r1cs_ppzksnark<libff::bn128_pp>(example=0x00007ffeefbff1f0, test_serialization=false) at run_r1cs_ppzksnark.tcc:70:43
    frame #16: 0x0000000100002005 gadgetlib1_simple_test`(anonymous namespace)::gadgetLib1_Integration_Test::TestBody(this=<unavailable>) at gadgetlib1_test.cpp:24:22
    frame #17: 0x00000001000e8b28 gadgetlib1_simple_test`void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) [inlined] void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(method=<unavailable>, location=<unavailable>)(), char const*) at gtest.cc:2401:10
    frame #18: 0x00000001000e8b18 gadgetlib1_simple_test`void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(object=<unavailable>, method=<unavailable>, location="the test body")(), char const*) at gtest.cc:2437
    frame #19: 0x00000001000e8a76 gadgetlib1_simple_test`testing::Test::Run(this=0x00007ffeefbff360) at gtest.cc:2475:5
    frame #20: 0x00000001000ea697 gadgetlib1_simple_test`testing::TestInfo::Run(this=<unavailable>) at gtest.cc:2651:11
    frame #21: 0x00000001000eaf07 gadgetlib1_simple_test`testing::TestCase::Run(this=0x00000001006008d0) at gtest.cc:2769:28
    frame #22: 0x00000001000f3eea gadgetlib1_simple_test`testing::internal::UnitTestImpl::RunAllTests(this=0x0000000100600670) at gtest.cc:4642:43
    frame #23: 0x00000001000f35b8 gadgetlib1_simple_test`bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) [inlined] bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(method=<unavailable>, location=<unavailable>)(), char const*) at gtest.cc:2401:10
    frame #24: 0x00000001000f35a8 gadgetlib1_simple_test`bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(object=<unavailable>, method=<unavailable>, location="auxiliary test code (environments or event listeners)")(), char const*) at gtest.cc:2437
    frame #25: 0x00000001000f3526 gadgetlib1_simple_test`testing::UnitTest::Run(this=0x000000010011d828) at gtest.cc:4256:10
    frame #26: 0x0000000100001f01 gadgetlib1_simple_test`main [inlined] RUN_ALL_TESTS() at gtest.h:2314:46
    frame #27: 0x0000000100001ef4 gadgetlib1_simple_test`main(argc=1, argv=<unavailable>) at gadgetlib1_test.cpp:32
    frame #28: 0x00007fff642943d5 libdyld.dylib`start + 1

After googling a bit it sounds like this can be caused by exceptions thrown beween dylibs with duplicated type info for exceptions. I tried changing the compile flags, and even tried catch(...) instead of catch(const std::invalid_argument &), but surprisingly even this didn't work for me.