Test for issue 568 doesn't work in Release mode (assertions off)

Issue #739 resolved
Jørgen Dokken created an issue

The test relies on dolfin_assert causing a dolfin_error which becomes a Python RuntimeError. In release mode the tested code path will segfault instead of raising an exception.

Either the code path in MeshEntity.h must be rewritten (causing a potential slowdown in Release mode) or the test must be removed, at least from Release mode builds.

Comments (14)

  1. Jan Blechta

    How do we reproduce it? I think you might have an old master. The test passes on buildbot and you can reproduce it

    fenicsproject run quay.io/fenicsproject_dev/dolfin:master
    cd ~/build/src/dolfin/test/unit/python/mesh
    py.test test_cell.py -k 568
    
  2. Jørgen Dokken reporter

    I used fully updated master branch for this test. I installed all dependencies for FEniCS with Hashdist (option 2) and cloned FEniCS master. Then I enabled testing and built FEniCS. The by typing

    make run_unittests
    

    in the build directory this error will occur.

  3. Johannes Ring

    I reproduced this earlier today using fenics-install.sh and this HashDist profile. This is a build with DOLFIN built in Release mode.

  4. Jan Blechta

    New test_issue_568 is probably incorrect with -DNDEBUG. @trlandet, does

       with pytest.raises(RuntimeError):
            cell.facet_area(0)
    

    on dolfin_assert? If it is the case it must be removed or run conditionally when -DDEBUG.

  5. Tormod Landet

    The test relies on dolfin_assert. The initial fix used "if(...){dolfin_error(...)}", but this was changed to dolfin_assert due to speed considerations.

    I tried briefly to introspect dolfin, dolfin.cpp and dolfin.compilemodule to find a way to get the build flags, but was not successful. How does instant/dijitso know whether to build extensions in Debug or Release mode? This was not so clear from the compilemodule code.

    If there is no obvious way to check for Debug mode (i.e. assertions cause dolfin_error), then the test must be removed. The fix is still there in Debug mode at least.

  6. Jan Blechta

    Could you use this function

    has_debug = compile_extension_module(
    """bool has_debug() {
    #ifdef DEBUG
    return true;
    #else
    return false;
    #endif
    }
    """).has_debug
    

    for now and file an issue to add has_debug to dolfin.cpp.common and assign to me?

  7. Log in to comment