ALPSCore / CT-HYB

ALPS Hybridization Expansion Matrix Code
GNU General Public License v2.0
16 stars 13 forks source link

Tutorials fail: Segmentation fault #21

Closed t-mertz closed 6 years ago

t-mertz commented 6 years ago

I installed ALPSCore v2.1.0 with Boost 1.58.0 and the newest Eigen from GitHub, make test passes all tests.

Now I cloned CT-HYB and compiled with g++ 5.4.0, which I was only able to do by adding set(CMAKE_CXX_STANDARD 11) to the top of CT-HYB/CMakeLists.txt. Again, make test passes both tests, although this first failed with a segfault, but somehow worked after checking out v1.0.1 and then v1.0.2 again. However, I am not overly confident with tags in git, so I may have done something weird there. Right now I get

$ git status
HEAD detached at v1.0.2
nothing to commit, working directory clean

Running the code with any one of the tutorial inputs fails immediately printing the following error message:

$ /home/mertz/CODES/alpscore/CT-HYB/install/bin/hybmat input.ini
[grundtal:14680] *** Process received signal ***
[grundtal:14680] Signal: Segmentation fault (11)
[grundtal:14680] Signal code: Address not mapped (1)
[grundtal:14680] Failing at address: 0x44000098
[grundtal:14680] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x354b0)[0x149a54cbf4b0]
[grundtal:14680] [ 1] /usr/lib/libmpi.so.12(MPI_Comm_rank+0x3e)[0x149a556422de]
[grundtal:14680] [ 2] /home/mertz/CODES/alpscore/CT-HYB/install/lib/libalpscore_cthyb.so(_ZN4alps5cthyb12MatrixSolverISt7complexIdEE5solveERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0xb9)[0x149a56c7f569]
[grundtal:14680] [ 3] /home/mertz/CODES/alpscore/CT-HYB/install/bin/hybmat(main+0x269)[0x411969]
[grundtal:14680] [ 4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x149a54caa830]
[grundtal:14680] [ 5] /home/mertz/CODES/alpscore/CT-HYB/install/bin/hybmat(_start+0x29)[0x412439]
[grundtal:14680] *** End of error message ***

Does anyone know what I have done wrong?

shinaoka commented 6 years ago

Hi, thank you for the feedback!

Let me first see how you compiled ALPSCore libraries and CT-HYB. Did you compile ALPSCore with C++11?

We need to use the same C++ standard for the ALPSCore and CT-HYB.

shinaoka commented 6 years ago

Why did you set this?

set(CMAKE_CXX_STANDARD 11)

In my environments, I use C++11 or 14 to compile CT-HYB. But, I want to keep the CT-HYB compatible with C++03 as long as possible. Did you find some issue?

t-mertz commented 6 years ago

Hi, I didn't change anything when compiling ALPSCore. In the CMakeCache.txt it says ALPS_CXX_STD:STRING=c++03, and this is also displayed when I run cmake.

I have now vigorously tried to reproduce the compile error that made me use c++11, but even after removing the setting it still worked. However, when I checkout master instead of v1.0.2 and try to compile I get compile errors that suggest that there is something incompatible with c++03.

Namely, the problem is in src/impurity_init.ipp lines 365 and 420, where std::ifstream(std::string) is called. The solution that I found was that this is only defined in c++11 and above. In c++03 one would have to add *.c_str() as there is no constructor overload that takes std::string. This seems to be fixed in v1.0.2, but if I understand correctly not in v1.0.3.

On v1.0.2 I am now compiling without c++11 and will then check again. Am I right in assuming that one is supposed to build from on of the tags and not branch master?

shinaoka commented 6 years ago

Hi,

The problem was the incompatibility between the CXX standards used for compiling ALPSCore libraries and ALPSCore/CT-HYB. The CT-HYB is linked to ALPSCore libraries. So, they must be compiled with the same C++ compiler and the same C++ standard ABI compatibility.

Actually, the implementation of std::string may be different between C++03 and C++11. This is why you got a very weird crash when a std::string object was touched.

If you get any compilation errors, please post them. Then, I will help you.

t-mertz commented 6 years ago

Thanks a lot for the help. After cleaning and recompiling everything works now. For ALPSCore I had specified to use mpich, which invokes /usr/bin/g++ instead of /usr/bin/c++, which has been used for CT-HYB.