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

corrupted size vs prev_size error in foam-extend4.0

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 5 Post By Daniel_Khazaei

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 16, 2018, 06:58
Default corrupted size vs prev_size error in foam-extend4.0
  #1
Senior Member
 
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21
Daniel_Khazaei will become famous soon enough
Dear foamers,


I have ported coded function object capability from foam-extend nextRelease (4.1) to 4.0!
However, not always but sometimes I get the following error when the simulation ends. Everything is working normally and it doesn't affect the result but I don't know what is wrong.

I'm running foam-extend in DEBUG mode on Ubuntu 18.10 and GCC5, here is the backtrace from GDB:

Code:
corrupted size vs. prev_size

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50    ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff2894535 in __GI_abort () at abort.c:79
#2  0x00007ffff28fb516 in __libc_message (action=action@entry=do_abort, 
    fmt=fmt@entry=0x7ffff2a1fc00 "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007ffff29023aa in malloc_printerr (
    str=str@entry=0x7ffff2a1dc9a "corrupted size vs. prev_size")
    at malloc.c:5336
#4  0x00007ffff2902574 in malloc_consolidate (
    av=av@entry=0x7ffff2a56c40 <main_arena>) at malloc.c:4442
#5  0x00007ffff290458c in _int_free (av=0x7ffff2a56c40 <main_arena>, 
    p=0x555555888b60, have_lock=<optimized out>) at malloc.c:4348
#6  0x0000555555559702 in Foam::string::~string (this=0x555555888990, 
    __in_chrg=<optimized out>)
    at /home/shadowfax/foam/foam-extend-4.0/src/foam/lnInclude/foamString.H:75
#7  0x0000555555559a08 in Foam::fileName::~fileName (this=0x555555888990, 
    __in_chrg=<optimized out>)
    at /home/shadowfax/foam/foam-extend-4.0/src/foam/lnInclude/fileName.H:70
#8  0x00007ffff733ccf2 in Foam::ITstream::~ITstream (this=0x555555888910, 
    __in_chrg=<optimized out>)
    at /home/shadowfax/foam/foam-extend-4.0/src/foam/lnInclude/ITstream.H:103
#9  0x00007ffff3649d90 in Foam::primitiveEntry::~primitiveEntry (this=
    0x5555558888d0, __in_chrg=<optimized out>) at lnInclude/primitiveEntry.H:63
#10 0x00007ffff3649dd2 in Foam::primitiveEntry::~primitiveEntry (
--Type <RET> for more, q to quit, c to continue without paging--
    this=0x5555558888d0, __in_chrg=<optimized out>)
    at lnInclude/primitiveEntry.H:63
#11 0x00007ffff364767e in Foam::ILList<Foam::DLListBase, Foam::entry>::eraseHead (this=0x555555572688) at lnInclude/ILList.C:86
#12 0x00007ffff36466a8 in Foam::ILList<Foam::DLListBase, Foam::entry>::clear (
    this=0x555555572688) at lnInclude/ILList.C:117
#13 0x00007ffff364529a in Foam::ILList<Foam::DLListBase, Foam::entry>::~ILList
    (this=0x555555572688, __in_chrg=<optimized out>) at lnInclude/ILList.C:74
#14 0x00007ffff3645054 in Foam::IDLList<Foam::entry>::~IDLList (
    this=0x555555572688, __in_chrg=<optimized out>) at lnInclude/IDLList.H:48
#15 0x00007ffff36408d2 in Foam::dictionary::~dictionary (this=0x555555572660, 
    __in_chrg=<optimized out>) at db/dictionary/dictionary.C:215
#16 0x00007ffff3649cf6 in Foam::dictionaryEntry::~dictionaryEntry (this=
    0x555555572620, __in_chrg=<optimized out>)
    at lnInclude/dictionaryEntry.H:58
#17 0x00007ffff3649d38 in Foam::dictionaryEntry::~dictionaryEntry (
    this=0x555555572620, __in_chrg=<optimized out>)
    at lnInclude/dictionaryEntry.H:58
#18 0x00007ffff364767e in Foam::ILList<Foam::DLListBase, Foam::entry>::eraseHead (this=0x555555571f98) at lnInclude/ILList.C:86
#19 0x00007ffff36466a8 in Foam::ILList<Foam::DLListBase, Foam::entry>::clear (
    this=0x555555571f98) at lnInclude/ILList.C:117
#20 0x00007ffff364529a in Foam::ILList<Foam::DLListBase, Foam::entry>::~ILList
--Type <RET> for more, q to quit, c to continue without paging--
    (this=0x555555571f98, __in_chrg=<optimized out>) at lnInclude/ILList.C:74
#21 0x00007ffff3645054 in Foam::IDLList<Foam::entry>::~IDLList (
    this=0x555555571f98, __in_chrg=<optimized out>) at lnInclude/IDLList.H:48
#22 0x00007ffff36408d2 in Foam::dictionary::~dictionary (this=0x555555571f70, 
    __in_chrg=<optimized out>) at db/dictionary/dictionary.C:215
#23 0x00007ffff3640912 in Foam::dictionary::~dictionary (this=0x555555571f70, 
    __in_chrg=<optimized out>) at db/dictionary/dictionary.C:218
#24 0x00007ffff3539c63 in Foam::debug::deleteControlDictPtr::~deleteControlDictPtr (this=0x7ffff3f46750 <Foam::debug::deleteControlDictPtr_>, 
    __in_chrg=<optimized out>) at lnInclude/debug.C:84
#25 0x00007ffff28b6a77 in __cxa_finalize (d=0x7ffff3f45800)
    at cxa_finalize.c:83
#26 0x00007ffff352f223 in __do_global_dtors_aux ()
   from /home/shadowfax/foam/foam-extend-4.0/lib/linux64GccDPDebug/libfoam.so
#27 0x00007fffffffb900 in ?? ()
#28 0x00007ffff7fe3d16 in _dl_fini () at dl-fini.c:138
and here is the controlDict, if I remove the coded function object then this error disappears:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  1.7.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     interfluidFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         0.04;

deltaT          2e-7;

writeControl    adjustableRunTime;

writeInterval   0.001;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression uncompressed;

timeFormat      general;

timePrecision   10;

runTimeModifiable yes;

adjustTimeStep  on;

maxCo           0.1;

maxAlphaCo      0.1;

maxFourier      0.4;

maxDeltaT       5e-5;

InfoSwitches
{
    allowSystemOperations 1;
}

//- Global vars for funky/groovy
functions
(
    DataSummary
    {
    functionObjectLibs ("libutilityFunctionObjects.so");
    type         coded;
    redirectType     DataSummary;
    outputControl     timeStep;
    outputInterval     100;
    code
    #{
        const volVectorField& U = mesh().lookupObject<volVectorField>("U");
        const volScalarField magU = mag(U);
        const scalar U_par_avg = gSum(magU.internalField()*mesh().V()) / gSum(mesh().V());

        const volScalarField& Q_pc = mesh().lookupObject<volScalarField>("pChEnergy");
        const scalar Q_pcInt = gSum(-mesh().V()*Q_pc.internalField());

        //- Finally print out results:
        //- Get t
        scalar t = mesh().time().value();
        scalar dt = mesh().time().deltaTValue();

        //- Now write out data:
        if( Pstream::master() == true )
        {
        std::ofstream fs;
        fs.open ("DataSummary.dat", std::fstream::app);
        fs.precision(8);
        fs << t << "\t" << dt << "\t" << U_par_avg << "\t" << Q_pcInt << "\n";
        fs.close();
        }
    #};

    codeInclude
    #{
        #include <fstream>
    #};
    }
);

// ************************************************************************* //
Regards,
D. Khazaei
Daniel_Khazaei is offline   Reply With Quote

Old   November 22, 2018, 06:09
Default
  #2
Senior Member
 
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21
Daniel_Khazaei will become famous soon enough
found the solution for anyone interested:

I was using a few modified versions of foam-extend boundary condition (e.g. movingWallVelocity, gradientEnthalpy) with same name and structure of the original ones! Although I was compiling those modified version within different library with different library name, but I was using the same name inside C and H files for those modified versions...

that caused double free or memory corruption when objects were going to be destroyed at the end of the simulation, as there were two instances of functions with the same name in the memory!

Regards,
Danial Khazaei
Daniel_Khazaei is offline   Reply With Quote

Old   May 5, 2022, 05:14
Default
  #3
Member
 
Join Date: Nov 2020
Posts: 53
Rep Power: 5
mikulo is on a distinguished road
Quote:
Originally Posted by Daniel_Khazaei View Post
found the solution for anyone interested:

I was using a few modified versions of foam-extend boundary condition (e.g. movingWallVelocity, gradientEnthalpy) with same name and structure of the original ones! Although I was compiling those modified version within different library with different library name, but I was using the same name inside C and H files for those modified versions...

that caused double free or memory corruption when objects were going to be destroyed at the end of the simulation, as there were two instances of functions with the same name in the memory!

Regards,
Danial Khazaei
Hello Danial,

Would you mind elaborate further with what you said about the same name inside C and H files even it is from a different library??

Regards,
Mike
mikulo is offline   Reply With Quote

Reply


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
SimpleFoam cannot open include file Marija OpenFOAM Running, Solving & CFD 1 October 28, 2020 11:35
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 05:18
is internalField(U) equivalent to zeroGradient? immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 02:27
Phase locked average in run time panara OpenFOAM 2 February 20, 2008 15:37
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55


All times are GMT -4. The time now is 10:57.