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

Segmentation fault on Ubuntu 16.04 #182

Open
joaocandre opened this issue Apr 18, 2018 · 14 comments
Open

Segmentation fault on Ubuntu 16.04 #182

joaocandre opened this issue Apr 18, 2018 · 14 comments

Comments

@joaocandre
Copy link
Contributor

joaocandre commented Apr 18, 2018

I'm trying to compile the sample code on a machine with Ubuntu 16.04 LTS (GCC 5.4.0) but it's throwing a segmentation fault error at runtime. The issue seems to be Eigen-related, but I've tried with several Eigen versions and I can't understand the issue. It is strange because on an Arch Linux machine, with the latest gcc version (7.3.1), there is no issue.

Error trace from valgrind:

==21993== Memcheck, a memory error detector
==21993== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==21993== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==21993== Command: ./example
==21993==
==21993==
==21993== Process terminating with default action of signal 11 (SIGSEGV)
==21993== General Protection Fault
==21993== at 0x5027980: _mm256_store_pd (avxintrin.h:842)
==21993== by 0x5027980: pstore<double, __vector(4) double> (PacketMath.h:244)
==21993== by 0x5027980: pstoret<double, __vector(4) double, 32> (GenericPacketMath.h:486)
==21993== by 0x5027980: assignPacket<32, __vector(4) double> (AssignmentFunctors.h:28)
==21993== by 0x5027980: assignPacket<32, 32, __vector(4) double> (AssignEvaluator.h:598)
==21993== by 0x5027980: run (AssignEvaluator.h:386)
==21993== by 0x5027980: call_dense_assignment_loop<Eigen::Matrix<double, -1, 1>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1> >, Eigen::internal::assign_op<double> > (AssignEvaluator.h:653)
==21993== by 0x5027980: run (AssignEvaluator.h:790)
==21993== by 0x5027980: void Eigen::internal::call_assignment_no_alias<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >, Eigen::internal::assign_op<double> >(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::internal::assign_op<double> const&) (AssignEvaluator.h:747)
==21993== by 0x5091FDD: call_assignment<Eigen::Matrix<double, -1, 1>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1> >, Eigen::internal::assign_op<double> > (AssignEvaluator.h:712)
==21993== by 0x5091FDD: call_assignment<Eigen::Matrix<double, -1, 1>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1> > > (AssignEvaluator.h:693)
==21993== by 0x5091FDD: _set<Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1> > > (PlainObjectBase.h:682)
==21993== by 0x5091FDD: operator=<Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1> > > (Matrix.h:225)
==21993== by 0x5091FDD: libcmaes::CMAParameters<libcmaes::GenoPheno<libcmaes::NoBoundStrategy, libcmaes::NoScalingStrategy> >::initialize_parameters() (cmaparameters.cc:77)
==21993== by 0x5092EAD: libcmaes::CMAParameters<libcmaes::GenoPheno<libcmaes::NoBoundStrategy, libcmaes::NoScalingStrategy> >::CMAParameters(std::vector<double, std::allocator<double> > const&, double const&, int const&, unsigned long const&, libcmaes::GenoPheno<libcmaes::NoBoundStrategy, libcmaes::NoScalingStrategy> const&) (cmaparameters.cc:48)
==21993== by 0x41254D: main (in /home/**/example)
==21993==
==21993== HEAP SUMMARY:
==21993== in use at exit: 89,536 bytes in 186 blocks
==21993== total heap usage: 247 allocs, 61 frees, 127,352 bytes allocated
==21993==
==21993== LEAK SUMMARY:
==21993== definitely lost: 0 bytes in 0 blocks
==21993== indirectly lost: 0 bytes in 0 blocks
==21993== possibly lost: 0 bytes in 0 blocks
==21993== still reachable: 89,536 bytes in 186 blocks
==21993== suppressed: 0 bytes in 0 blocks
==21993== Rerun with --leak-check=full to see details of leaked memory
==21993==
==21993== For counts of detected and suppressed errors, rerun with: -v
==21993== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)

@joaocandre
Copy link
Contributor Author

joaocandre commented Apr 18, 2018

I've managed to install gcc-7 and attempted to compile, but the issue remains.

@beniz
Copy link
Collaborator

beniz commented Apr 18, 2018

Hi, I've just ran a build on Ubuntu 16.04 and it runs fine. What exact test are you running that gives you a crash ?

@joaocandre
Copy link
Contributor Author

@beniz The sample code on the front page (fsphere()). I straight used the same code, compiled with g ++ 'pkg-config --cflags eigen3 libcmaes' sample_code.cpp 'pkg-config --libs libcmaes'. I've come across with reports on Eigen issues with dynamic memory on StackOverflow which I suspect may be causing this.

@beniz
Copy link
Collaborator

beniz commented Apr 18, 2018

Can you try the examples in tests, typically test_functions ?

@joaocandre
Copy link
Contributor Author

joaocandre commented Apr 18, 2018

Calling ./test_functions --dim 30 --lambda 100 --max_iter 120 --fname fsphere I get Illegal instruction (core dumped)

@beniz
Copy link
Collaborator

beniz commented Apr 18, 2018

And calling test_functions alone ?

@joaocandre
Copy link
Contributor Author

The same happens.

@beniz
Copy link
Collaborator

beniz commented Apr 18, 2018

Works for me. Do an ldd on you test_functions to report the linked libs, though this may not report eigen stuff. I'll look at it later on more in depth. If your version on arch works you might be able to compare the ldd output and get some information there.

@beniz
Copy link
Collaborator

beniz commented Apr 18, 2018

Also report your full build log in a gist

@beniz
Copy link
Collaborator

beniz commented Apr 19, 2018

Tried from scratch this morning and it works for me on a 16.04lts.

@joaocandre
Copy link
Contributor Author

Linked libraries on both systems look to be the same. Difference is solely that on Arch the library was installed/compiled from the AUR (though I assume it relies on the same compilation scripts). I'm compiling with make following the instructions, everything seems to compile ok.

Compilation log: https://gist.github.com/joaocandre/742365dcb18735b24c81eaecf2f93638

@joaocandre
Copy link
Contributor Author

Not sure if relevant, but the libcmaes.so.0.0.0 file in Arch is 6.3 Mb, while on Ubuntu 16.04 93Mb. That's a staggering difference.

@joaocandre
Copy link
Contributor Author

I've found that everything works when I compile with CMake, generating a 6Mb shared object. I guess there is something wrong with the Makefile!

@beniz
Copy link
Collaborator

beniz commented May 3, 2018

See whether #183 fixes your issue as well.

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

2 participants