CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Bugs (https://www.cfd-online.com/Forums/openfoam-bugs/)
-   -   corrupted double-linked list (https://www.cfd-online.com/Forums/openfoam-bugs/66379-corrupted-double-linked-list.html)

gschaider November 28, 2018 08:17

Quote:

Originally Posted by calf.Z (Post 717096)
I have encountered the same questions.

*** Error in `coolrhoSimpleFoam': double free or corruption (!prev): 0x0000000001d2aa60 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f4484bec7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f4484bf537a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f4484bf953c]
/lib/x86_64-linux-gnu/libc.so.6(__cxa_finalize+0x9a)[0x7f4484baf36a]
/home/dyfluid/OpenFOAM/OpenFOAM-5.x/platforms/linux64GccDPInt32Opt/lib/libspecie.so(+0x1c1613)[0x7f4489ef1613]


Can anyone help me with this problem?

Thank you very mach.


That is probably the same memory being freed twice and as it seems to be a self-written solver your best bet is to compile it in Debug-mode and run it in a debugger


Just two pieces of advice:
- if you use delete in OpenFOAM-code you're probably doing something wrong
- never use a "naked" pointer but wrap it in a autoPtr and use references to it
- make sure that any references you pass around are not used after the autoPtr left scope


That is three. But the second one is a mix between the other two

calf.Z December 17, 2018 02:46

Quote:

Originally Posted by gschaider (Post 717171)
That is probably the same memory being freed twice and as it seems to be a self-written solver your best bet is to compile it in Debug-mode and run it in a debugger


Just two pieces of advice:
- if you use delete in OpenFOAM-code you're probably doing something wrong
- never use a "naked" pointer but wrap it in a autoPtr and use references to it
- make sure that any references you pass around are not used after the autoPtr left scope


That is three. But the second one is a mix between the other two


Thank you for your reply!

I compile two new libraries (userspecie and TabularThermophysicalModels) without errors, and then I compiled the official solver(rhoSimpleFoam) with the new libraries without errors. I didn't modify any code about this solver and I just linked the libraries and renamed it to coolrhoSimpleFoam.

When I use the new solver for running case,there are some errors:
*** Error in `coolrhoSimpleFoam':double free or corruption (!prev): 0x000000000193b250 ***
......

In my make/options:

...
I$(WM_PROJECT_USER_DIR)/thermophysicalModels/basic/lnInclude \
I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
...

EXE_LIBS = \
-L$(FOAM_USER_LIBBIN) -luserspecie \
-L$(FOAM_USER_LIBBIN) -lTabularThermophysicalModels \
...

I think I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ should be removed, but when I tried it, it's said that ***.H chould not be found. When I added it, it compiled successfully.

I have no idea about double free or corruption (!prev). I am wondering if you can help me with this problem.

That's very appreciated of you.

Regards,
Calf.Z

gaza December 17, 2018 02:55

Quote:

Originally Posted by calf.Z (Post 719326)
Thank you for your reply!

I compile two new libraries (userspecie and TabularThermophysicalModels) without errors, and then I compiled the official solver(rhoSimpleFoam) with the new libraries without errors. I didn't modify any code about this solver and I just linked the libraries and renamed it to coolrhoSimpleFoam.

When I use the new solver for running case,there are some errors:
*** Error in `coolrhoSimpleFoam':double free or corruption (!prev): 0x000000000193b250 ***
......

In my make/options:

...
I$(WM_PROJECT_USER_DIR)/thermophysicalModels/basic/lnInclude \
I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
...

EXE_LIBS = \
-L$(FOAM_USER_LIBBIN) -luserspecie \
-L$(FOAM_USER_LIBBIN) -lTabularThermophysicalModels \
...

I think I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ should be removed, but when I tried it, it's said that ***.H chould not be found. When I added it, it compiled successfully.

I have no idea about double free or corruption (!prev). I am wondering if you can help me with this problem.

That's very appreciated of you.

Regards,
Calf.Z


In my case it was connected with tmp object.
Are you using such objects?

calf.Z December 17, 2018 04:05

I compiled the library based on the code online and I haven’t researched the code.
And then I just used rhosimpleFoam to link the new library and renamed it to coolrhoSimpleFoam. After finishing running,double free or corruption appeared,
So I have no idea.

wyldckat December 22, 2018 10:39

Quick questions/notes @calf.Z:
  1. At the start of solver run, either before or after the initial header, sometimes OpenFOAM will state which object has been loaded as a duplicate. Since you haven't followed the instructions indicated here: https://www.cfd-online.com/Forums/op...-get-help.html - it's not possible to see what only you can see.
  2. Please indicate from where you got the "TabularThermophysicalModels" source code and which installation instructions you've followed, so that we can try and reproduce the same error. It is likely that they have a duplicate runtime name for one or more of their classes, hence the crash at the end.

calf.Z December 22, 2018 21:41

3 Attachment(s)
Quote:

Originally Posted by wyldckat (Post 719907)
Quick questions/notes @calf.Z:
  1. At the start of solver run, either before or after the initial header, sometimes OpenFOAM will state which object has been loaded as a duplicate. Since you haven't followed the instructions indicated here: https://www.cfd-online.com/Forums/op...-get-help.html - it's not possible to see what only you can see.
  2. Please indicate from where you got the "TabularThermophysicalModels" source code and which installation instructions you've followed, so that we can try and reproduce the same error. It is likely that they have a duplicate runtime name for one or more of their classes, hence the crash at the end.

I am sorry for the mistakes I made and thank you for replying me.

I have uploaded some related files. The two new libraries :libuserspecie.so and libTabularThermophysicalModels.so. were compiled without errors. I use wclean lib then wmake libso

When I linked the libraries with my solver, it also compiled without errors. I
use wclean then wmake. The options:

EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/finiteVolume/cfdTools \
-I$(WM_PROJECT_USER_DIR)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \

EXE_LIBS = \
-L$(FOAM_USER_LIBBIN) -luserspecie \
-L$(FOAM_USER_LIBBIN) -lTabularThermophysicalModels \
-lcompressibleTransportModels \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lfiniteVolume \
-lsampling \
-lmeshTools \
-lOpenFOAM \
-lfvOptions

After I ran the case, it appears: Error in `coolrhoSimpleFoam': double free or corruption (!prev): 0x000000000168e250 ***

I have no ideas about it. Thank you.

wyldckat December 23, 2018 16:17

Quick answer: I did ask you from where you had gotten the "TabularThermophysicalModels" source code... I went looking and found that you likely used the version from here: https://github.com/Yuusha0/tabulated...es/tree/v2.0.2

I then I tried to use the tutorial case "2FlatPlatesCompressible" that they provide, which didn't run as it was. The fix was simple enough: instead of modifying the solver, all I had to do was add the following block to the end of the file "system/controlDict":
Code:

libs
(
    "libuserspecie.so"
    "libTabularThermophysicalModels.so"
    "libtabularReactionThermophysicalModels.so"
);

This will make the solver load these libraries before it starts to do anything else regarding the case.

Once the solver was finished running, it did not have any error messages.

Therefore, my suggestion is that instead of you trying to compile a custom solver with this source code, instead use this strategy with the existing OpenFOAM solvers.

calf.Z December 25, 2018 02:21

Quote:

Originally Posted by wyldckat (Post 719985)
Quick answer: I did ask you from where you had gotten the "TabularThermophysicalModels" source code... I went looking and found that you likely used the version from here: https://github.com/Yuusha0/tabulated...es/tree/v2.0.2

I then I tried to use the tutorial case "2FlatPlatesCompressible" that they provide, which didn't run as it was. The fix was simple enough: instead of modifying the solver, all I had to do was add the following block to the end of the file "system/controlDict":
Code:

libs
(
    "libuserspecie.so"
    "libTabularThermophysicalModels.so"
    "libtabularReactionThermophysicalModels.so"
);

This will make the solver load these libraries before it starts to do anything else regarding the case.

Once the solver was finished running, it did not have any error messages.

Therefore, my suggestion is that instead of you trying to compile a custom solver with this source code, instead use this strategy with the existing OpenFOAM solvers.

Thank you, I have resolved the problem by the library presented in the link and the method you suggest.

thunde47 May 2, 2024 06:29

Getting the same error on my own compiled solver!


All times are GMT -4. The time now is 01:50.