CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Bugs

SegFault due to illegal readwrites

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 10, 2007, 07:20
Default Hi, In template
  #1
msg30
Guest
 
Posts: n/a
Hi,

In

template<class>
List<t>::List(const List<t>& a)
:UList<t>(NULL, a.size_)
{}

from

Foam::Field<foam::vector<double> >::Field(Foam::Field<foam::vector<double> > const&)

from

Foam::Field<foam::vector<double> >::Field(Foam::Field<foam::vector<double> > const&)

I have illegal reads for what I guess is the first vector (three illegal reads in the first loop iteration, all others are fine)

It is called with an internal surface vector field from autoMap() (all previous scalar fields are fine)

I have so far no idea where it comes from as the begin() member function "should" return the correct pointer I would have thought.

The only thing that confuses me so far is that you instantiate if with a field:

from the copy constructor
Field<type> fCpy(*this); // around line 490 in Field.C

template<class>
Field<type>::Field(const Field<type>& f)
:
refCount(),
List<type>(f) // here f is no list but List has no copy constructor form a field and in actual fact the copy constructor from a list is used
{...}


Then later in the code there are (of course more serious) illegal writes. But I guess they have the same origin and I want to fix this first before I look at them and from a correctness point of view there is no difference between illegal reads or writes, both pests which should not be there.

I still need to learn a bit more about your coding and am at the moment a bit stuck as it seems difficult to attach gdb properly to these bits of code but will keep you posted. I would greatly appreciate any hints if you have even a vague idea what could be going on.

Cheers,

Markus
  Reply With Quote

Old   December 10, 2007, 09:32
Default Have you tried running your co
  #2
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 22
henry is on a distinguished road
Have you tried running your code in valgrind?
henry is offline   Reply With Quote

Old   December 10, 2007, 10:15
Default Hi Henry, thanks for the
  #3
msg30
Guest
 
Posts: n/a
Hi Henry,


thanks for the quick reply!

Yes, thats how I got closer to the real issue. The code only segFaults much later, but valgrind shows it right away. It is a small mesh, 2x2x2, first time step. This one runs without segFault, but if I either run more timesteps and/or increase the mesh it will eventually segFault.

Here is some of the valgrind output:

==2677==
==2677== Invalid read of size 8
==2677== at 0x433695: Foam::Field<foam::vector<double> >::Field(Foam::Field<foam::vector<double> > const&) (in /home/markus/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/simpleFOAM )
==2677== by 0x43ABD9: Foam::Field<foam::vector<double> >::autoMap(Foam::FieldMapper const&) (in /home/markus/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/simpleFOAM )
==2677== by 0x578B0F6: Foam::MapInternalField<foam::vector<double>, Foam::fvMeshMapper, Foam::surfaceMesh>::operator()(Foam::Field<foam::v ector<double> >&, Foam::fvMeshMapper const&) const (MapFvSurfaceField.H:85)
==2677== by 0x578B2F0: void Foam::MapGeometricFields<foam::vector<double>, Foam::fvsPatchField, Foam::fvMeshMapper, Foam::surfaceMesh>(Foam::fvMeshMapper const&) (MapGeometricFields.H:113)
==2677== by 0x577C3DF: Foam::fvMesh::mapFields(Foam::mapPolyMesh const&) (fvMesh.C:371)
==2677== by 0x577C340: Foam::fvMesh::updateMesh(Foam::mapPolyMesh const&) (fvMesh.C:453)
==2677== by 0x82332C0: Foam::polyTopoChanger::changeMesh(bool, bool) (polyTopoChanger.C:282)
==2677== by 0x9A2FE0A: Foam::movingConeTopoFvMesh::update() (movingConeTopoFvMesh.C:364)
==2677== by 0x42CE18: main (in /home/markus/OpenFOAM/OpenFOAM-1.4.1/applications/bin/linux64GccDPOpt/simpleFOAM )
==2677== Address 0x9CED2D0 is 0 bytes inside a block of size 864 free'd
==2677== at 0x4C212A9: operator delete[](void*) (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==2677== by 0x57633BF: Foam::List<foam::vector<double> >::~List() (List.C:324)
==2677== by 0x576347A: Foam::Field<foam::vector<double> >::~Field() (Field.H:83)
==2677== by 0x5B73C10: void Foam::deleteDemandDrivenData<foam::field<foam::vec tor<double> >*>(Foam::Field<foam::vector<double> >*&) (demandDrivenData.H:45)
==2677== by 0x6878E17: Foam::primitiveMesh::clearGeom() (primitiveMeshClear.C:149)
==2677== by 0x6878E2E: Foam::primitiveMesh::clearAll() (primitiveMeshClear.C:199)
==2677== by 0x6875FED: Foam::primitiveMesh::reset(int, int, int, int, Foam::Field<foam::vector<double> > const&, Foam::List<foam::face> const&, Foam::List<int> const&, Foam::List<int> const&) (primitiveMesh.C:154)
==2677== by 0x6874945: Foam::polyMesh::initMesh() (polyMeshCalcFaceCells.C:175)
==2677== by 0x685EABF: Foam::polyMesh::resetPrimitives(int, Foam::Field<foam::vector<double> > const&, Foam::List<foam::face> const&, Foam::List<int> const&, Foam::List<int> const&, Foam::List<int> const&, Foam::List<int> const&, bool) (polyMesh.C:679)
==2677== by 0x82404F7: Foam::polyTopoChange::changeMesh(Foam::polyMesh&, bool, bool) (polyTopoChange.C:2684)
==2677== by 0x823327E: Foam::polyTopoChanger::changeMesh(bool, bool) (polyTopoChanger.C:279)
==2677== by 0x9A2FE0A: Foam::movingConeTopoFvMesh::update() (movingConeTopoFvMesh.C:364)

(Note, some of the line numbers may be out by a couple of lines due to debug statements / explaining comments inserted by me into the code)
  Reply With Quote

Old   December 12, 2007, 08:08
Default Could it be that you collapse
  #4
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Could it be that you collapse your mesh down to zero thickness? Looks like the problem is in mapping a surface field (e.g. phi). If you have a small testcase we can try it over here.
mattijs is offline   Reply With Quote

Old   December 12, 2007, 13:44
Default Dear Mattijs, Maybe I am do
  #5
msg30
Guest
 
Posts: n/a
Dear Mattijs,

Maybe I am doing something stupid before it comes to the segFault. Before I potentially waste more of your time, you posted a refinement mesh modifier in

http://www.cfd-online.com/cgi-bin/Op...w.cgi?126/6124

If I understand it right, then, in order to use that, we have to construct our own TopoFvMesh, along the lines of movingConeTopoFvMesh for example, just without the movement, right? As you had the mesh modifier, do you have the TopoFvMesh for it as well? Maybe the source of my troubles lies there ....

Many thanks for your time!

Regards,

Markus
  Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
error:perl syntax errors detected ,illegal divisio sivaramakrishnaiah CFX 0 April 30, 2008 07:04
error "illegal facets" urgent sivaji CFX 0 June 15, 2006 02:53
Illegal segmentation error in gambit Rob FLUENT 1 February 21, 2005 08:31


All times are GMT -4. The time now is 11:28.