Svalorzen / AI-Toolbox

A C++ framework for MDPs and POMDPs with Python bindings
GNU General Public License v3.0
647 stars 98 forks source link

Segfaults in tiger_antelope example #19

Closed alecive closed 7 years ago

alecive commented 7 years ago

Hi,

I've been trying to run the Tiger Antelope code in the example folder, but after countless time (I'd say that is runs for something like 20mins), the code segfaults. This is the terminal output:

(~/code/AI-Toolbox/examples) (master) 
[alecive@malakim]$ make
g++ -O3 -std=c++11 ./tutorialcode.cpp -o tiger_antelope -I../include -I/usr/include/eigen3 -L../build -lAIToolboxMDP

(~/code/AI-Toolbox/examples) (master) 
[alecive@malakim]$ ./tiger_antelope 
Mon Nov 14 10:57:09 2016
- Copying model...!
Mon Nov 14 11:14:25 2016
- Init solver...!
Mon Nov 14 11:14:25 2016
- Starting solver!
tiger_antelope: /usr/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:131: Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::CwiseBinaryOp(const Lhs&, const Rhs&, const BinaryOp&) [with BinaryOp = Eigen::internal::scalar_product_op<double, double>; Lhs = const Eigen::SparseMatrix<double, 1>; Rhs = const Eigen::SparseMatrix<double, 1>]: Assertion `aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols()' failed.
Aborted (core dumped)
Svalorzen commented 7 years ago

Mmmh.. weird. I've just tried it on my local machines and it works. Could you try to compile both the library and the example in debug and see what happens?

Svalorzen commented 7 years ago

@alecive Did you have any chance to check out this bug again?

alecive commented 7 years ago

Hey @Svalorzen , sorry for the delay in answering you. I just downloaded a clean version of your repo to test it again without any of my modifications. I got the same error. I then proceeded to compiling the repo in debug mode, and ran the example with gdb. Same error again:

Starting program: /home/alecive/Desktop/AI-Toolbox-master/examples/tiger_antelope 
Mon Jan  9 16:59:42 2017
- Copying model...!
Mon Jan  9 17:17:18 2017
- Init solver...!
Mon Jan  9 17:17:18 2017
- Starting solver!
tiger_antelope: /usr/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:131: Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::CwiseBinaryOp(const Lhs&, const Rhs&, const BinaryOp&) [with BinaryOp = Eigen::internal::scalar_product_op<double, double>; Lhs = const Eigen::SparseMatrix<double, 1>; Rhs = const Eigen::SparseMatrix<double, 1>]: Assertion `aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols()' failed.

Program received signal SIGABRT, Aborted.

This is some info from gdb:

(gdb) where
#0  0x00007ffff721cc37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff7220028 in __GI_abort () at abort.c:89
#2  0x00007ffff7215bf6 in __assert_fail_base (fmt=0x7ffff73663b8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x42ef68 "aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols()", 
    file=file@entry=0x42ef30 "/usr/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h", line=line@entry=131, 
    function=function@entry=0x430e40 <Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<double, double>, Eigen::SparseMatrix<double, 1, int> const, Eigen::SparseMatrix<double, 1, int> const>::CwiseBinaryOp(Eigen::SparseMatrix<double, 1, int> const&, Eigen::SparseMatrix<double, 1, int> const&, Eigen::internal::scalar_product_op<double, double> const&)::__PRETTY_FUNCTION__> "Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::CwiseBinaryOp(const Lhs&, const Rhs&, const BinaryOp&) [with BinaryOp = Eigen::internal::scalar_product_op<double, double>; Lhs = const Eigen::SparseMatrix<do"...) at assert.c:92
#3  0x00007ffff7215ca2 in __GI___assert_fail (assertion=0x42ef68 "aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols()", 
    file=0x42ef30 "/usr/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h", line=131, 
    function=0x430e40 <Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<double, double>, Eigen::SparseMatrix<double, 1, int> const, Eigen::SparseMatrix<double, 1, int> const>::CwiseBinaryOp(Eigen::SparseMatrix<double, 1, int> const&, Eigen::SparseMatrix<double, 1, int> const&, Eigen::internal::scalar_product_op<double, double> const&)::__PRETTY_FUNCTION__> "Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::CwiseBinaryOp(const Lhs&, const Rhs&, const BinaryOp&) [with BinaryOp = Eigen::internal::scalar_product_op<double, double>; Lhs = const Eigen::SparseMatrix<do"...) at assert.c:101
#4  0x0000000000402d65 in AIToolbox::MDP::ValueIterationEigen<AIToolbox::MDP::SparseModel, void>::computeImmediateRewards(AIToolbox::MDP::SparseModel const&) const ()
#5  0x00000000004039a7 in AIToolbox::MDP::ValueIterationEigen<AIToolbox::MDP::SparseModel, void>::operator()(AIToolbox::MDP::SparseModel const&) ()
#6  0x0000000000401f25 in main ()
(gdb) bt full
#0  0x00007ffff721cc37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
        resultvar = 0
        pid = 12662
        selftid = 12662
#1  0x00007ffff7220028 in __GI_abort () at abort.c:89
        save_stage = 2
        act = {__sigaction_handler = {sa_handler = 0x7fffffffc3d2, sa_sigaction = 0x7fffffffc3d2}, sa_mask = {__val = {140737340909828, 4386608, 131, 4294967295, 
              140737339553107, 4294967296, 140737488336720, 4294948784, 4230933, 140737488336880, 0, 0, 0, 21474836480, 140737354096640, 140737340924856}}, 
          sa_flags = 4386664, 
          sa_restorer = 0x430e40 <Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<double, double>, Eigen::SparseMatrix<double, 1, int> const, Eigen::SparseMatrix<double, 1, int> const>::CwiseBinaryOp(Eigen::SparseMatrix<double, 1, int> const&, Eigen::SparseMatrix<double, 1, int> const&, Eigen::internal::scalar_product_op<double, double> const&)::__PRETTY_FUNCTION__>}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007ffff7215bf6 in __assert_fail_base (fmt=0x7ffff73663b8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x42ef68 "aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols()", 
    file=file@entry=0x42ef30 "/usr/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h", line=line@entry=131, 
    function=function@entry=0x430e40 <Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<double, double>, Eigen::SparseMatrix<double, 1, int> const, Eigen::SparseMatrix<double, 1, int> const>::CwiseBinaryOp(Eigen::SparseMatrix<double, 1, int> const&, Eigen::SparseMatrix<double, 1, int> const&, Eigen::internal::scalar_product_op<double, double> const&)::__PRETTY_FUNCTION__> "Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::CwiseBinaryOp(const Lhs&, const Rhs&, const BinaryOp&) [with BinaryOp = Eigen::internal::scalar_product_op<double, double>; Lhs = const Eigen::SparseMatrix<do"...) at assert.c:92
        str = 0xac747b0 "tiger_antelope: /usr/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h:131: Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::CwiseBinaryOp(const Lhs&, const Rhs&, const BinaryOp&) [with BinaryOp = Eigen::interna"...
        total = 4096
#3  0x00007ffff7215ca2 in __GI___assert_fail (assertion=0x42ef68 "aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols()", 
    file=0x42ef30 "/usr/include/eigen3/Eigen/src/Core/CwiseBinaryOp.h", line=131, 
    function=0x430e40 <Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<double, double>, Eigen::SparseMatrix<double, 1, int> const, Eigen::SparseMatrix<double, 1, int> const>::CwiseBinaryOp(Eigen::SparseMatrix<double, 1, int> const&, Eigen::SparseMatrix<double, 1, int> const&, Eigen::internal::scalar_product_op<double, double> const&)::__PRETTY_FUNCTION__> "Eigen::CwiseBinaryOp<BinaryOp, Lhs, Rhs>::CwiseBinaryOp(const Lhs&, const Rhs&, const BinaryOp&) [with BinaryOp = Eigen::internal::sca---Type <return> to continue, or q <return> to quit---
lar_product_op<double, double>; Lhs = const Eigen::SparseMatrix<do"...) at assert.c:101
No locals.
#4  0x0000000000402d65 in AIToolbox::MDP::ValueIterationEigen<AIToolbox::MDP::SparseModel, void>::computeImmediateRewards(AIToolbox::MDP::SparseModel const&) const ()
No symbol table info available.
#5  0x00000000004039a7 in AIToolbox::MDP::ValueIterationEigen<AIToolbox::MDP::SparseModel, void>::operator()(AIToolbox::MDP::SparseModel const&) ()
No symbol table info available.
#6  0x0000000000401f25 in main ()
No symbol table info available.

Please tell me if you need any further info!

Svalorzen commented 7 years ago

Unfortunately I can't seem to reproduce this. I've also checked the line which is supposedly crashing your program, and it looks correct. There's only a single coefficient wise multiplication, and it is done on matrices which are surely of the same dimension, so the failed assert shouldn't really trigger (if it did, nothing would work ever).

Could it be that you have a weird Eigen version with some bug? Is there any way you could try updating your Eigen library (maybe checkout the newest version by hand and use that) and let me know if that fixes the problem?

In any case, if you could tell me your OS and Eigen library version that'd be swell.

alecive commented 7 years ago

What version are you currently using? I'm on 3.3.0, downloaded from the website and compiled manually.

And I'm on Ubuntu 14.04. Yes it's old, but the robot I'm using is forcing me to use that version.

Svalorzen commented 7 years ago

I'm using the default ones for Ubuntu 16.04 (3.3 but a bit alpha I believe). I'll try to use the official ones. It seems strange though. Are you also on Ubuntu?

alecive commented 7 years ago

Yes sorry I edited the message before. I'm on Ubuntu 14.04 and I cannot upgrade due to issues with my robot.

Svalorzen commented 7 years ago

Hey, sorry for the very late response. The library has gotten a bit of a makeover so this may be irrelevant now.

I'm now on Ubuntu 17.04. I've tested again, both in release and debug the example by using the newly released Eigen 3.3.4 downloaded from tar.gz. I've not found this problem, so I've no idea what it could be.

Can you reproduce it still?

alecive commented 7 years ago

Let's close the issue, as it is so far in the past that has little relevance at this point. I am still on Ubuntu 14.04, which makes things probably difficult to reproduce with latest releases.