Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests using EXPECT_THROW fail on macOS with Apple Silicon M3 #945

Open
1 task done
hmenke opened this issue Jun 13, 2024 · 2 comments
Open
1 task done

Tests using EXPECT_THROW fail on macOS with Apple Silicon M3 #945

hmenke opened this issue Jun 13, 2024 · 2 comments

Comments

@hmenke
Copy link
Member

hmenke commented Jun 13, 2024

Prerequisites

Description

Tests that use EXPECT_THROW fail on macOS with Apple Silicon M3. Upon catch the tests segfault (aka bus error on macOS) somewhere in libunwind when encountering the autib instruction.

$ lldb /Users/timapple/code/triqs/triqs.build/test/c++/gfs/gf_density
(lldb) target create "/Users/timapple/code/triqs/triqs.build/test/c++/gfs/gf_density"
Current executable set to '/Users/timapple/code/triqs/triqs.build/test/c++/gfs/gf_density' (arm64).
(lldb) r
Process 48083 launched: '/Users/timapple/code/triqs/triqs.build/test/c++/gfs/gf_density' (arm64)
[==========] Running 4 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 4 tests from Gf
[ RUN      ] Gf.DensityFermion
[       OK ] Gf.DensityFermion (2 ms)
[ RUN      ] Gf.DensityBoson
[       OK ] Gf.DensityBoson (1 ms)
[ RUN      ] Gf.Density_with_not_all_moments
Process 48083 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=261, address=0xdac11410)
    frame #0: 0x000000019518ba58 libunwind.dylib`_Unwind_GetIP + 224
libunwind.dylib`:
->  0x19518ba58 <+224>: autib  x16, x0
    0x19518ba5c <+228>: mov    x17, x16
    0x19518ba60 <+232>: xpaci  x17
    0x19518ba64 <+236>: cmp    x16, x17
Target 0: (gf_density) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=261, address=0xdac11410)
  * frame #0: 0x000000019518ba58 libunwind.dylib`_Unwind_GetIP + 224
    frame #1: 0x00000001888cbc7c libc++abi.dylib`__gxx_personality_v0 + 588
    frame #2: 0x0000000100530930 libunwind.1.dylib`unwind_phase2 + 388
    frame #3: 0x0000000100530b68 libunwind.1.dylib`_Unwind_Resume + 100
    frame #4: 0x0000000100e682f8 libtriqs.3.3.dylib`triqs::gfs::density(g=gf_const_view<triqs::mesh::imfreq, triqs::gfs::matrix_valued, nda::C_stride_layout> @ 0x000000016fdfd9a8, known_moments=nda::array_const_view<dcomplex, 3> @ 0x000000016fdfd968) at density.cpp:35:7
    frame #5: 0x0000000100e65be4 libtriqs.3.3.dylib`triqs::gfs::density(g=gf_const_view<triqs::mesh::imfreq, triqs::gfs::matrix_valued, nda::C_stride_layout> @ 0x000000016fdfe248, known_moments=nda::array_const_view<dcomplex, 3> @ 0x000000016fdfe208) at density.cpp:40:42
    frame #6: 0x0000000100e82520 libtriqs.3.3.dylib`triqs::gfs::density(g=gf_const_view<triqs::mesh::imfreq, triqs::gfs::scalar_valued, nda::C_stride_layout> @ 0x000000016fdfe788, known_moments=nda::array_const_view<dcomplex, 1> @ 0x000000016fdfe760) at density.cpp:126:16
    frame #7: 0x0000000100008e80 gf_density`Gf_Density_with_not_all_moments_Test::TestBody(this=0x0000600000365c90) at gf_density.cpp:69:3
    frame #8: 0x00000001006f8a10 libgtest.1.14.0.dylib`void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(object=0x0000600000365c90, method=0x00000000000000010000000000000020, location="the test body") at gtest.cc:2635:10
    frame #9: 0x00000001006b5dfc libgtest.1.14.0.dylib`void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(object=0x0000600000365c90, method=0x00000000000000010000000000000020, location="the test body") at gtest.cc:2671:14
    frame #10: 0x00000001006b5d4c libgtest.1.14.0.dylib`testing::Test::Run(this=0x0000600000365c90) at gtest.cc:2710:5
    frame #11: 0x00000001006b6c00 libgtest.1.14.0.dylib`testing::TestInfo::Run(this=0x000000014071d580) at gtest.cc:2856:11
    frame #12: 0x00000001006b7dcc libgtest.1.14.0.dylib`testing::TestSuite::Run(this=0x000000014071d350) at gtest.cc:3034:30
    frame #13: 0x00000001006c6114 libgtest.1.14.0.dylib`testing::internal::UnitTestImpl::RunAllTests(this=0x000000014071d0a0) at gtest.cc:5964:44
    frame #14: 0x00000001007036f8 libgtest.1.14.0.dylib`bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(object=0x000000014071d0a0, method=(libgtest.1.14.0.dylib`testing::internal::UnitTestImpl::RunAllTests() at gtest.cc:5841), location="auxiliary test code (environments or event listeners)") at gtest.cc:2635:10
    frame #15: 0x00000001006c5af0 libgtest.1.14.0.dylib`bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(object=0x000000014071d0a0, method=(libgtest.1.14.0.dylib`testing::internal::UnitTestImpl::RunAllTests() at gtest.cc:5841), location="auxiliary test code (environments or event listeners)") at gtest.cc:2671:14
    frame #16: 0x00000001006c59e8 libgtest.1.14.0.dylib`testing::UnitTest::Run(this=0x0000000100720140) at gtest.cc:5543:10
    frame #17: 0x0000000100031cb0 gf_density`RUN_ALL_TESTS() at gtest.h:2334:73
    frame #18: 0x0000000100031c44 gf_density`main(argc=1, argv=0x000000016fdff4b8) at gf_density.cpp:93:1
    frame #19: 0x00000001885910e0 dyld`start + 2360
(lldb) f 4
frame #4: 0x0000000100e682f8 libtriqs.3.3.dylib`triqs::gfs::density(g=gf_const_view<triqs::mesh::imfreq, triqs::gfs::matrix_valued, nda::C_stride_layout> @ 0x000000016fdfd9a8, known_moments=nda::array_const_view<dcomplex, 3> @ 0x000000016fdfd968) at density.cpp:35:7
   32    nda::matrix<dcomplex> density(gf_const_view<imfreq> g, array_const_view<dcomplex, 3> known_moments) {
   33  
   34      if (g.mesh().positive_only())
-> 35        TRIQS_RUNTIME_ERROR << "density is only implemented for g(i omega_n) with full mesh (positive and negative frequencies)";
   36  
   37      nda::array_const_view<dcomplex, 3> mom_123;
   38  
(lldb) f 7
frame #7: 0x0000000100008e80 gf_density`Gf_Density_with_not_all_moments_Test::TestBody(this=0x0000600000365c90) at gf_density.cpp:69:3
   66    triqs::clef::placeholder<0> om_;
   67  
   68    G(om_) << 1.0;
-> 69    EXPECT_THROW(triqs::gfs::density(G), triqs::runtime_error);
   70  
   71    G(om_) << om_;
   72    EXPECT_THROW(triqs::gfs::density(G), triqs::runtime_error);

Steps to Reproduce

  1. Compile TRIQS on an M3 Mac
  2. ctest -R '^gf_density$'

Expected behavior: No bus error.

Actual behavior: bus error

Versions

706967b

Formatting

Please use markdown in your issue message. A useful summary of commands can be found here.

Additional Information

As a workaround one can configure TRIQS with

$ LDFLAGS=-ld_classic cmake ...

As to why that works I have no idea.

@MichiMeix

@nanshengmath
Copy link

nanshengmath commented Jul 11, 2024

I'm using an M1 Mac and encountered the following issues when installing TRIQS:

The following tests FAILED:
	 30 - h5_file (SIGTRAP)
	 31 - h5_group (SIGTRAP)
	 42 - Py_archive (SIGTRAP)
	 58 - nda_bound_check (SIGTRAP)
	 91 - nda_str_indices (SIGTRAP)
	106 - imtime_ops (SIGTRAP)
	113 - atom_diag_h5 (SIGTRAP)
	141 - fourier_matsubara (SIGTRAP)
	145 - g_tau_mul (SIGTRAP)
	149 - gf_density (SIGTRAP)
	200 - different_moves_mc_np2 (Failed)
	202 - different_moves_mc_np3 (Failed)
	203 - different_moves_mc_np4 (Failed)
	206 - extractors_test (SIGTRAP)
	213 - histograms2 (SIGTRAP)
	235 - real_or_complex (SIGTRAP)
	267 - py_bug_tight_binding (SIGTRAP)

LDFLAGS=-ld_classic cmake ... solves the problem too.

A similar thing goes for triqs_nevalinna and LDFLAGS=-ld_classic cmake ... also solves the problem.

@Thoemi09
Copy link
Contributor

I can reproduce the issue on my Mac with an M2 chip if I do the exports as suggested in Step 7 in the docs. It seems to be an issue of the Xcode version, since they introduced a new linker with Xcode 15 (see here).

I don't really understand what the problem is but the following works for me (assuming the exports in Step 7 have been done):

  • Use the old linker, i.e.
export LDFLAGS=-ld_classic
cmake ...
  • Use the default (new) linker but unset LIBRARY_PATH, i.e.
unset LIBRARY_PATH
cmake ...
  • Use the default (new) linker together with llvm's libc++, i.e.
export LDFLAGS="-L$(brew --prefix)/opt/llvm/lib/c++ -Wl,-rpath,$(brew --prefix)/opt/llvm/lib/c++"
cmake ...

-ld_classic will be deprecated and removed in future Xcode versions (see here). Maybe we should advertise the third option?

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

No branches or pull requests

3 participants