ChasteGuides/TroubleShooting

Troubleshooting

This pages stores a list of common problem and issues that occasionally crop up, together with their solutions. Please update problems and solutions if needed, and add new problems as they crop up.

Table of Contents

  1. Troubleshooting
  2. Chaste (Running Tests)
    1. An exception occurs but the exception message is not shown
    2. The directory output was written to seems empty
    3. Strange error about semget and setnum
    4. Running an already compiled test executable manually (instead of compiling …
    5. Appear to get incorrect answers when solving a PDE
  3. Scons errors
    1. No SConstruct file found
    2. IndexError: string index out of range
    3. "Found dependency cycle(s)"
  4. PyCml errors
    1. ConfigurationError: No transmembrane potential found; check your …
    2. ConfigurationError: No stimulus current found; you'll have trouble …
    3. TranslationError: Cannot convert ionic current from amps to uA/cm2
  5. Compilation and linking errors
    1. The compiler complains that a variable has not been defined when it …
    2. Get a mental, extremely long, set of compilation errors, appears to be …
    3. Undefined reference errors on linking
    4. A "comparison between signed and unsigned integer expressions" error …
    5. "Error: void <YOUR_TEST_CLASS>::<YOUR_TEST_METHOD>() is private"
    6. Compiler says c_vector or c_matrix was not declared (perhaps even if …
    7. Get a "Assertion 'petsc_is_initialised' failed" error
    8. "Fatal error; unknown error handler. May be MPI call before MPI_INIT. …
    9. Boost/serialization/vector.hpp
    10. glibc detected free(): invalid pointer
    11. Invalid application of 'sizeof' to incomplete type …
    12. "function definition does not declare parameters"
    13. "error: expected primary-expression before '>' token"
  6. Other
    1. 'A repository hook failed' error message when trying to commit

Chaste (Running Tests)

An exception occurs but the exception message is not shown

Add throw (Exception) after the method declaration in the failing test, i.e.

    void TestSomething() throw (Exception)
    {
        // test
    }

The directory output was written to seems empty

If, in a terminal, you are in an output directory, and rerun a test that involves that directory being wiped and recreated, the terminal might act as if there's nothing in the directory, i.e. an ls displays no files. Just cd out and back into the directory again.

Strange error about semget and setnum

Problem: The following error message occurs when running a test

Running 9 testssemget failed for setnum =  0

This happens occasionally due to shortcomings in MPICH. Rerun the test. If that fails run the MPICH cleanipcs script, e.g. by doing:

~/mpi/sbin/cleanipcs

Running an already compiled test executable manually (instead of compiling and running with scons) fails

Some environment variables are setup by the SCons scripts, you need to export them yourself.

cdchaste
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/lib
./component/build/whatever/TestXRunner

Also, if files are output to the current directory rather than /tmp/chaste/testoutput/, also do

export CHASTE_TEST_OUTPUT=/tmp/chaste/testoutput/

(or /tmp/whatever/testoutput).

Appear to get incorrect answers when solving a PDE

If you try to solve a simple PDE with Neumann boundary conditions, with a known solution, but appear to get incorrect answers, you may have done one of two things incorrectly. For the elliptic PDE "du/dt = div (D grad_u) + f", where D is a matrix, the Neumann boundary condition that you specify (using BoundaryConditionsContainer and ConstBoundaryConditions etc) is the value of "(D grad_u) dot n" (where n is the unit outward facing normal), not the value of du/dn and not du/dx in 1D. In particular, in 1D, on the left-hand side n=-1 and you need to specify "-D du/dx", not just du/dx. See UserTutorials/SolvingLinearPdes for an example.

Scons errors

No SConstruct file found

The following error

scons: *** No SConstruct file found.
File "/usr/lib/scons/SCons/Script/Main.py", line 825, in _main

is, as it says, due to no SConstruct file found and probably because you are in the wrong directory - you should run scons from the main Chaste directory.

IndexError: string index out of range

If you get the following error

scons  test_suite=heart/test/bidomain/TestBidomainProblem.hpp 
IndexError: string index out of range:
  File "/usr/lib/scons/SCons/Script/Main.py", line 1171:
    _exec_main(parser, values)
  File "/usr/lib/scons/SCons/Script/Main.py", line 1144:
    _main(parser)
  File "/usr/lib/scons/SCons/Script/Main.py", line 880:
    if a[0] == '-':

it could be because of the two spaces (!!!) between "scons" and "test_suite=" in "scons test_suite=heart/test/bidomain/TestBidomainProblem.hpp" (only an issue if running scons through eclipse).

"Found dependency cycle(s)"

scons: done building targets.

scons: *** Found dependency cycle(s):
  Internal Error: no cycle found for node global/build/debug/src/Version.o (<SCons.Node.FS.File instance at 0xdacc20>) in state executed

File "/usr/lib64/python2.5/site-packages/SCons/Taskmaster.py", line 797, in cleanup

If scons throws an error saying it has found a dependency cycle it probably has conflicting versions of things lying around and a clean build (scons -c) seems to sort it out.

PyCml errors

ConfigurationError: No transmembrane potential found; check your configuration

This occurs when PyCml cannot determine which variable in the model represents the transmembrane potential. You can either add a for_model stanza to the PyCml config file or, better, annotate the CellML file to specify the variable. See ChasteGuides/CodeGenerationFromCellML for more information on how to do this, in particular the section on Model annotation with RDF.

ConfigurationError: No stimulus current found; you'll have trouble generating Chaste code

PyCml needs to know which variable in the model represents the stimulus current in order to replace the model's stimulus with the one defined by Chaste. You should annotate the relevant variable as described here. If the model doesn't have a stimulus (e.g. a sino-atrial node model) then annotate the model itself accordingly.

TranslationError: Cannot convert ionic current from amps to uA/cm2 without knowing which variable in the cell model represents the membrane capacitance

Some cell models give ionic currents in units of amps (or microamps etc.) whereas Chaste expects amps normalised by area (microamps per centimetre squared). In order to convert between the two, PyCml needs to use the membrane capacitance from the model, and hence needs to know which variable represents this. You should annotate the relevant variable as described here.

Compilation and linking errors

The compiler complains that a variable has not been defined when it clearly has been, in a base class

If class A and class B are both templated, and B<DIM> inherits from A<DIM>, then the compiler won't be able to locate variables defined in the base class if used in the child unless the base is specified. The solution is to write this-> before the variable in question. i.e.

template<int DIM>
class A
{
public:
  double x;
};
template<int DIM>
class B : public A<DIM>
{
  void run()
  {
    std::cout << x;
  }
};

won't compile, whereas

template<int DIM>
class A
{
public:
  double x;
};
template<int DIM>
class B : public A<DIM>
{
  void run()
  {
    std::cout << this->x;
  }
};

will do. See AccessingMemberVariablesInTemplatedSuperclasses.

Get a mental, extremely long, set of compilation errors, appears to be something to do with Boost (mpl or ublas)

Try putting

#include "UblasIncludes.hpp"

as the first include in the source file being compiled (generally either a cpp file or the test being run).

It may be that the ublas include needs to come after any serialization include; I'm not sure.

Undefined reference errors on linking

Problem: Undefined reference errors on linking, such as:

undefined reference to `Node<1u>::AddElement(unsigned int)'

This may mean that you are using a templated class which has been written using Explicit Instantiation, and you are using a value for one of the template parameters for which there isn't an instantiation. Not all classes are instantiated for all dimensions in order to reduce compilation time. Look at the bottom of the cpp file for the class in question (e.g. Node.cpp in the example above) and check if there is a line like

template class Node<1>;

at the bottom of the file. Add the missing dimension if not.

Note that for some classes (e.g. BoundaryConditionsContainer) the situation is more complex, since we don't just template over dimension. In such cases there should be a file named like BoundaryConditionsContainerImplementation.hpp which you can include, either in the hpp file (if you do not provide a cpp) or in your cpp file (and add further explicit instantiations there). See StaticAndDynamicPolymorphism#Explicitinstantiation for more info.

A "comparison between signed and unsigned integer expressions" error (possibly) in a file in the CxxTest folder

The following error (or actually, warning, which is then taken as an error)

cxxtest/cxxtest/TestSuite.h: In function 'bool CxxTest::equals(X, Y) [with X = long unsigned int, Y = int]':
cxxtest/cxxtest/TestSuite.h:58:   instantiated from 'void CxxTest::doAssertEquals(const char*, unsigned int, const char*, X, const char*, Y, const char*) [with X = long unsigned int, Y = int]'
.<FILE_NAME>:<LINE_NUMBER>   instantiated from here
cxxtest/cxxtest/TestSuite.h:49: warning: comparison between signed and unsigned integer expressions

is usually due to a comparison between an unsigned variable and a hardcoded number (taken as an int by the compiler) in a TS_ASSERT_EQUALS, for example

unsigned my_var = 10;
TS_ASSERT_EQUALS(my_var, 10);

To tell the compiler to treat the (second) 10 as an unsigned, do the following

TS_ASSERT_EQUALS(my_var, 10u);

"Error: void <YOUR_TEST_CLASS>::<YOUR_TEST_METHOD>() is private"

Remember all test methods need to be declared as public.

Compiler says c_vector or c_matrix was not declared (perhaps even if you are including <boost/numeric/ublas/matrix.hpp>)

These are ublas vectors and matrices. Do

#include "UblasIncludes.hpp"

Note that it is not enough to do

#include <boost/numeric/ublas/matrix.hpp>

as then you would have to write boost::numeric::ublas::c_matrix<double,2,2> instead of c_matrix<double,2,2>.

Get a "Assertion 'petsc_is_initialised' failed" error

If the following is printed

global/src/DistributedVector.cpp:47: static void DistributedVector::CheckForPetsc(): Assertion `petsc_is_initialised' failed.

it is probably because you have forgotten to do

#include "PetscSetupAndFinalize.hpp"

in your test.

"Fatal error; unknown error handler. May be MPI call before MPI_INIT. Error message is MPI_COMM_RANK and code is 197"

You may have included PetscSetupAndFinalize.hpp in a source file - it should only be included in test files (and must be included in all tests files that use PETSc).

Boost/serialization/vector.hpp

Note: this error should no longer occur, as we include a workaround within Chaste.

(#1024) If you see this:

/usr/include/boost/serialization/vector.hpp:126: error: redefinition of 'struct boost::serialization::implementation_level<std::vector<long int, std::allocator<long int> > >'
/usr/include/boost/serialization/vector.hpp:126: error: previous definition of 'struct boost::serialization::implementation_level<std::vector<long int, std::allocator<long int> > >'
/usr/include/boost/serialization/vector.hpp:126: error: redefinition of 'struct boost::serialization::implementation_level<std::vector<long unsigned int, std::allocator<long unsigned int> > >'
/usr/include/boost/serialization/vector.hpp:126: error: previous definition of 'struct boost::serialization::implementation_level<std::vector<long unsigned int, std::allocator<long unsigned int> > >'
scons: building terminated because of errors.

put

#include <climits>

before

#include "boost/serialization/vector.hpp"

glibc detected free(): invalid pointer

If you get an error starting something like:

** glibc detected *** heart/build/debug/mechanics/TestCardiacElectroMechanicsProblemRunner: free(): invalid pointer: 0x00000000019ff758 ***
======= Backtrace: =========
/lib/libc.so.6[0x7f32485ae08a]
/lib/libc.so.6(cfree+0x8c)[0x7f32485b1c1c]

then it may be because you haven't included a virtual destructor in the base class of your inheritance hierarchy, and you're deleting a derived class via a pointer of base class type. Another situation that may provoke this error is when you make use of CellwiseData but forget to call ReallocateMemory().

Invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>'

If you get this error

/usr/include/boost/archive/detail/oserializer.hpp:566: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' 

then you need to archive a const pointer to your object instead of just a pointer, e.g. instead of

Electrodes<3>* p_electrodes = new Electrodes<3>(mesh,false,1,0,10,magnitude,duration);
output_arch << p_electrodes;

put

Electrodes<3>* const p_electrodes = new Electrodes<3>(mesh,false,1,0,10,magnitude,duration);
output_arch << p_electrodes;

"function definition does not declare parameters"

If you get this sort of error:

cell_based/src/tissue/cell/TissueCell.cpp:172: error: function definition does not declare parameters
scons: *** [cell_based/build/debug/src/tissue/cell/TissueCell.os] Error 1
scons: building terminated because of errors.

then the relevant function definition is incorrectly typed. Check you have two colons, e.g. TissueCell::AddCell().

"error: expected primary-expression before '>' token"

If you are trying to call a method that is templated, like this:

if (cell_iter->rGetCellPropertyCollection().HasProperty<CellLabel>())

but get this sort of error:

error: expected primary-expression before '>' token
error: expected primary-expression before ')' token

then this may be because the compiler doesn't know that the method is a template itself, and so parses the < character as "less than" and gets confused later on. In this case, you need to explicitly tell the compiler that the method is a template so that it parses < as the opening bracket of a template parameter list, like this:

if (cell_iter->rGetCellPropertyCollection().template HasProperty<CellLabel>())

Other

'A repository hook failed' error message when trying to commit

If, when you try to commit changes to the repository, SVN gives the error message

A repository hook failed
svn: Commit failed (details follow):
svn: 'pre-commit' hook failed with error output:
Branch or project commit with no indication in log message

this is because, when committing to your project (or a branch), you must start the commit message with the project (or branch) name in square brackets, eg [JohnD] implemented ...