View Issue Details

IDProjectCategoryView StatusLast Update
0001393OpenFOAMBugpublic2014-12-28 14:46
Reporteruser994Assigned Tohenry  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
PlatformIntel CoreOSDebian GNU/Linux Jessie (amd64)OS VersionJessie/testing
Summary0001393: reconstructPar crashes in tutorials cyclone and wingMotion2D_pimpleDyMFoam
DescriptionOpenFoam-2.3.x git snapshot 03.09.2014 compiled with clang-3.5. Logs attached.

By the way, in
tutorials/lagrangian/MPPICFoam/cyclone/Allrun
something like
runApplication reconstructPar
is missing.
TagsNo tags attached.

Activities

user994

2014-09-07 19:31

 

user994

2014-09-07 19:32

 

user4

2014-09-08 11:41

 

log.reconstructPar_bit (5,471 bytes)

user4

2014-09-08 11:42

  ~0003224

I cannot replicate this. Did you compile from sources? Are you using a supported g++ version? Attached (part of) my output of reconstructPar of wingMotion2D_pimpleDyMFoam.

user4

2014-09-08 11:45

  ~0003225

Sorry, overlooked your clang-3.5 specification. Does it work for you with other clang/g++ versions?

user994

2014-09-09 16:33

  ~0003230

In June I used g++-4.9 and there were no problems.

Good, I've compiled a debug version with clang-3.5 and reconstructPar seems to work. Then I've compiled a "-g -O2" version. There is a lot of warnings during build. An example is attached. And here is a backtrace:

gursky@hpprobook:~/OpenFOAM/gursky-2.3.x/run/tutorials/lagrangian/MPPICFoam/cyclone$ gdb reconstructPar
GNU gdb (Debian 7.7.1+dfsg-3) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from reconstructPar...done.
(gdb) r
Starting program: /home/gursky/projects/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64ClangDPOpt/bin/reconstructPar
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 2.3.x
Exec : /home/gursky/projects/OpenFOAM/OpenFOAM-2.3.x/platforms/linux64ClangDPOpt/bin/reconstructPar
Date : Sep 09 2014
Time : 15:01:45
Host : "hpprobook"
PID : 19631
Case : /home/gursky/OpenFOAM/gursky-2.3.x/run/tutorials/lagrangian/MPPICFoam/cyclone
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time



Reconstructing fields for mesh region0

Time = 0.1

Reconstructing FV fields

    Reconstructing volScalarField::DimensionedInternalFields

        kinematicCloud:UCoeff

    Reconstructing volVectorField::DimensionedInternalFields

        kinematicCloud:UTrans

    Reconstructing volScalarFields

        k.air

Program received signal SIGSEGV, Segmentation fault.
Foam::fvPatchField<double>::fvPatchField (this=0x1207800, ptf=..., p=..., iF=..., mapper=...) at lnInclude/fvPatchField.C:101
101 if (&iF && iF.size())
(gdb) bt full
#0 Foam::fvPatchField<double>::fvPatchField (this=0x1207800, ptf=..., p=..., iF=..., mapper=...) at lnInclude/fvPatchField.C:101
No locals.
#1 0x00007ffff6be4759 in Foam::fixedValueFvPatchField<double>::fixedValueFvPatchField (this=0x1207800, ptf=warning: can't find linker symbol for virtual table for `Foam::fixedValueFvPatchField<double>' value
warning: found `std::string::_Rep::_S_empty_rep_storage' instead
..., p=..., iF=..., mapper=...)
    at fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C:68
No locals.
#2 0x00007ffff6be4708 in Foam::fvPatchField<double>::addpatchMapperConstructorToTable<Foam::fixedValueFvPatchField<double> >::New (ptf=..., p=..., iF=..., m=...)
    at lnInclude/fvPatchField.H:132
No locals.
#3 0x00000000004f2422 in Foam::fvPatchField<double>::New (ptf=..., p=..., iF=..., pfMapper=...)
    at /home/gursky/projects/OpenFOAM/OpenFOAM-2.3.x/src/finiteVolume/lnInclude/fvPatchFieldNew.C:217
No locals.
#4 0x00000000004f1760 in Foam::fvFieldReconstructor::reconstructFvVolumeField<double> (this=0x7fffffffb578, fieldIoObject=..., procFields=...)
    at /home/gursky/projects/OpenFOAM/OpenFOAM-2.3.x/src/parallel/reconstruct/reconstruct/lnInclude/fvFieldReconstructorReconstructFields.C:170
        curPatchStart = <optimized out>
        procI = <optimized out>
#5 0x00000000004f0fd2 in Foam::fvFieldReconstructor::reconstructFvVolumeField<double> (this=0x7fffffffb578, fieldIoObject=...)
    at /home/gursky/projects/OpenFOAM/OpenFOAM-2.3.x/src/parallel/reconstruct/reconstruct/lnInclude/fvFieldReconstructorReconstructFields.C:339
        procFields = <optimized out>
#6 0x0000000000442086 in Foam::fvFieldReconstructor::reconstructFvVolumeFields<double> (this=0x7fffffffb578, objects=..., selectedFields=...)
    at /home/gursky/projects/OpenFOAM/OpenFOAM-2.3.x/src/parallel/reconstruct/reconstruct/lnInclude/fvFieldReconstructorReconstructFields.C:656
        fieldClassName = <optimized out>
        fields = <optimized out>
#7 0x000000000043a6e0 in main (argc=<optimized out>, argv=<optimized out>) at reconstructPar.C:409
        procStat = <optimized out>
        meshStat = <optimized out>
        regionName = <optimized out>
(gdb)

user994

2014-09-09 16:34

 

user4

2014-09-25 16:02

  ~0003239

We can repeat this. Looks like it is due to a very strict interpretation of null references in the optimiser.

user994

2014-09-26 19:44

  ~0003240

Yes, I've written a minimal test case. It is attached.

Thus all checks of values passed by references being null are not legal. But the main problem is that somewhere in the code instead of an object a null is actually passed by reference.

user994

2014-09-26 19:44

 

test_pass_null_obj_by_ref.cpp (1,894 bytes)   
// OK: g++-4.9 -Wall -g -O3 -o test test.cpp
// OK: clang++-3.4 -Wall -g -O3 -o test test.cpp

// OK  : clang++-3.5 -Wall -g -o test test.cpp
// FAIL: clang++-3.5 -Wall -g -O1 -o test test.cpp
/*
test.cpp:57:14: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true
      [-Wundefined-bool-conversion]
        if (&foo && foo.method())
             ^~~ ~~
1 warning generated.
*/

#include <iostream>
#include <cstdlib>

struct Foo{
        int *data;

        Foo();
        ~Foo();
        bool method() const;
};

Foo::Foo()
{
        const int len = 100;
        data = new int[len];
        for (int i=0; i<len; i++) data[i]=0;
        std::cout << "Foo constructor" << std::endl;
}

Foo::~Foo()
{
        delete[] data;
        std::cout << "Foo destructor" << std::endl;
}

bool Foo::method() const
{
        std::cout << "Foo::method(): foo object supposed to exist, really?" << std::endl
                  << "accessing foo::data[1]..." << std::endl;
        std::cout << "data[1]=" << data[1] << std::endl;
        return true;
}

const Foo&
nullFoo()
{
        Foo* nullFoo = NULL;
        return static_cast<const Foo&>(*nullFoo);
}

void
test(const Foo& foo)
{
        if (&foo && foo.method())
                std::cout << "foo exists and method() OK" << std::endl;
        else
                std::cout << "foo doesn't exist, OK" << std::endl;
}

int main(int argc, char* argv[])
{
        int useNullFoo = 1;

        if (argc == 2)
                useNullFoo = atoi(argv[1]);

        std::cout << "Usage: test [0/1]" << std::endl
                  << "       0 create object" << std::endl
                  << "       1 \"create\" null object (default)" << std::endl;

        if (useNullFoo)
                test(nullFoo());
        else
                test(Foo());

        return 0;
}

test_pass_null_obj_by_ref.cpp (1,894 bytes)   

henry

2014-12-28 14:46

manager   ~0003366

The handling for references to NULL has been changed in Clang-3.5 which required substantial changes to the way in which OpenFOAM creates and checks null objects.

Resolved by commit 3dd3e6157ccc3bb6d6a1b2208deb7eca92784929
in https://github.com/OpenFOAM/OpenFOAM-dev

Issue History

Date Modified Username Field Change
2014-09-07 19:31 user994 New Issue
2014-09-07 19:31 user994 File Added: cyclone.log.reconstructPar
2014-09-07 19:32 user994 File Added: wingMotion2D_pimpleDyMFoam.log.reconstructPar
2014-09-08 11:41 user4 File Added: log.reconstructPar_bit
2014-09-08 11:42 user4 Note Added: 0003224
2014-09-08 11:45 user4 Note Added: 0003225
2014-09-09 16:33 user994 Note Added: 0003230
2014-09-09 16:34 user994 File Added: reconstrcutPar-warnings-example.txt
2014-09-25 16:02 user4 Note Added: 0003239
2014-09-26 19:44 user994 Note Added: 0003240
2014-09-26 19:44 user994 File Added: test_pass_null_obj_by_ref.cpp
2014-12-28 14:46 henry Note Added: 0003366
2014-12-28 14:46 henry Status new => closed
2014-12-28 14:46 henry Assigned To => henry
2014-12-28 14:46 henry Resolution open => fixed