CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   wmake Error with original Files ? (http://www.cfd-online.com/Forums/openfoam/80739-wmake-error-original-files.html)

archymedes October 5, 2010 09:24

wmake Error with original Files ?
 
Hi everybody,

I wanted to apply some changes to the dsmc module, before getting started I copied the whole opt/openfoam171/src/lagrangian/dsmc/ directory to my user directory. ../dsmc/ contains a Make directory.
without any changes to these files I've tried to wmake, everything looks fine !
then I run a test case with my library and I get a glibc error
( just changed the FILES file to put the new library {libdsmc.so} to my user directory )

Code:

OpenFoam/InflowModelTest$ *** glibc detected *** dsmcFoam: double free or corruption (fasttop): 0x0899eea0 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(+0x6b591)[0xb61ea591]
/lib/tls/i686/cmov/libc.so.6(+0x6cde8)[0xb61ebde8]
/lib/tls/i686/cmov/libc.so.6(cfree+0x6d)[0xb61eeecd]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb63d9741]
/usr/lib/libstdc++.so.6(_ZNSs4_Rep10_M_destroyERKSaIcE+0x1d)[0xb63b5c2d]
/usr/lib/libstdc++.so.6(_ZNSsD2Ev+0x4c)[0xb63b763c]
dsmcFoam(_ZN4Foam4wordD1Ev+0x1d)[0x805761d]
/lib/tls/i686/cmov/libc.so.6(__cxa_finalize+0xb8)[0xb61ae588]
/opt/openfoam171/lib/linuxGccDPOpt/libdsmc.so(+0x83a4)[0xb680f3a4]
/opt/openfoam171/lib/linuxGccDPOpt/libdsmc.so(+0x16610)[0xb681d610]
/lib/ld-linux.so.2(+0xe2a6)[0xb77122a6]
/lib/tls/i686/cmov/libc.so.6(+0x2f1bf)[0xb61ae1bf]
/lib/tls/i686/cmov/libc.so.6(+0x2f22f)[0xb61ae22f]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xee)[0xb6195bde]
dsmcFoam[0x8055001]
======= Memory map: ========
08048000-08088000 r-xp 00000000 08:05 161821    /opt/openfoam171/applications/bin/linuxGccDPOpt/dsmcFoam
08088000-08089000 r--p 00040000 08:05 161821    /opt/openfoam171/applications/bin/linuxGccDPOpt/dsmcFoam
08089000-0808a000 rw-p 00041000 08:05 161821    /opt/openfoam171/applications/bin/linuxGccDPOpt/dsmcFoam
08920000-08d56000 rw-p 00000000 00:00 0          [heap]
b4e00000-b4e21000 rw-p 00000000 00:00 0
b4e21000-b4f00000 ---p 00000000 00:00 0
b4f26000-b4f70000 r-xp 00000000 08:05 161369    /opt/openfoam171/lib/linuxGccDPOpt/libcompressibleTurbulenceModel.so
b4f70000-b4f71000 r--p 00049000 08:05 161369    /opt/openfoam171/lib/linuxGccDPOpt/libcompressibleTurbulenceModel.so
b4f71000-b4f72000 rw-p 0004a000 08:05 161369    /opt/openfoam171/lib/linuxGccDPOpt/libcompressibleTurbulenceModel.so
b4f72000-b5013000 r-xp 00000000 08:05 161361    /opt/openfoam171/lib/linuxGccDPOpt/libLESfilters.so
b5013000-b5015000 r--p 000a0000 08:05 161361    /opt/openfoam171/lib/linuxGccDPOpt/libLESfilters.so
b5015000-b5016000 rw-p 000a2000 08:05 161361    /opt/openfoam171/lib/linuxGccDPOpt/libLESfilters.so
b5016000-b503d000 r-xp 00000000 08:05 161408    /opt/openfoam171/lib/linuxGccDPOpt/libLESdeltas.so
b503d000-b503e000 r--p 00026000 08:05 161408    /opt/openfoam171/lib/linuxGccDPOpt/libLESdeltas.so
b503e000-b503f000 rw-p 00027000 08:05 161408    /opt/openfoam171/lib/linuxGccDPOpt/libLESdeltas.so
b503f000-b5088000 r-xp 00000000 08:05 161330    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleTurbulenceModel.so
b5088000-b5089000 r--p 00049000 08:05 161330    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleTurbulenceModel.so
b5089000-b508a000 rw-p 0004a000 08:05 161330    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleTurbulenceModel.so
b508a000-b51b9000 r-xp 00000000 08:05 161372    /opt/openfoam171/lib/linuxGccDPOpt/libcompressibleLESModels.so
b51b9000-b51bc000 r--p 0012f000 08:05 161372    /opt/openfoam171/lib/linuxGccDPOpt/libcompressibleLESModels.so
b51bc000-b51bd000 rw-p 00132000 08:05 161372    /opt/openfoam171/lib/linuxGccDPOpt/libcompressibleLESModels.so
b51bd000-b51be000 rw-p 00000000 00:00 0
b51be000-b53c1000 r-xp 00000000 08:05 161335    /opt/openfoam171/lib/linuxGccDPOpt/libcompressibleRASModels.so
b53c1000-b53c5000 r--p 00202000 08:05 161335    /opt/openfoam171/lib/linuxGccDPOpt/libcompressibleRASModels.so
b53c5000-b53c7000 rw-p 00206000 08:05 161335    /opt/openfoam171/lib/linuxGccDPOpt/libcompressibleRASModels.so
b53c7000-b543f000 r-xp 00000000 08:05 161358    /opt/openfoam171/lib/linuxGccDPOpt/libspecie.so
b543f000-b5441000 r--p 00077000 08:05 161358    /opt/openfoam171/lib/linuxGccDPOpt/libspecie.so
b5441000-b5442000 rw-p 00079000 08:05 161358    /opt/openfoam171/lib/linuxGccDPOpt/libspecie.so
b5442000-b54e4000 r-xp 00000000 08:05 161409    /opt/openfoam171/lib/linuxGccDPOpt/libbasicThermophysicalModels.so
b54e4000-b54e7000 r--p 000a1000 08:05 161409    /opt/openfoam171/lib/linuxGccDPOpt/libbasicThermophysicalModels.so
b54e7000-b54e8000 rw-p 000a4000 08:05 161409    /opt/openfoam171/lib/linuxGccDPOpt/libbasicThermophysicalModels.so
b54e8000-b566f000 r-xp 00000000 08:05 161360    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleLESModels.so
b566f000-b5670000 ---p 00187000 08:05 161360    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleLESModels.so
b5670000-b5674000 r--p 00187000 08:05 161360    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleLESModels.so
b5674000-b5676000 rw-p 0018b000 08:05 161360    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleLESModels.so
b5676000-b58e3000 r-xp 00000000 08:05 161404    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleRASModels.so
b58e3000-b58e4000 ---p 0026d000 08:05 161404    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleRASModels.so
b58e4000-b58e8000 r--p 0026d000 08:05 161404    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleRASModels.so
b58e8000-b58ea000 rw-p 00271000 08:05 161404    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleRASModels.so
b58ea000-b594c000 r-xp 00000000 08:05 161378    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleTransportModels.so
b594c000-b594d000 r--p 00061000 08:05 161378    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleTransportModels.so
b594d000-b594e000 rw-p 00062000 08:05 161378    /opt/openfoam171/lib/linuxGccDPOpt/libincompressibleTransportModels.so
b594e000-b59de000 r-xp 00000000 08:05 161336    /opt/openfoam171/lib/linuxGccDPOpt/libforces.so
b59de000-b59e0000 r--p 0008f000 08:05 161336    /opt/openfoam171/lib/linuxGccDPOpt/libforces.so
b59e0000-b59e1000 rw-p 00091000 08:05 161336    /opt/openfoam171/lib/linuxGccDPOpt/libforces.so
b59e1000-b5b00000 r-xp 00000000 08:05 161339    /opt/openfoam171/lib/linuxGccDPOpt/libfieldFunctionObjects.so
b5b00000-b5b03000 r--p 0011e000 08:05 161339    /opt/openfoam171/lib/linuxGccDPOpt/libfieldFunctionObjects.so
b5b03000-b5b05000 rw-p 00121000 08:05 161339    /opt/openfoam171/lib/linuxGccDPOpt/libfieldFunctionObjects.so
b5b05000-b5be9000 r-xp 00000000 08:05 161344    /opt/openfoam171/lib/linuxGccDPOpt/libsurfMesh.so
b5be9000-b5bea000 ---p 000e4000 08:05 161344    /opt/openfoam171/lib/linuxGccDPOpt/libsurfMesh.so
b5bea000-b5bec000 r--p 000e4000 08:05 161344    /opt/openfoam171/lib/linuxGccDPOpt/libsurfMesh.so
b5bec000-b5bed000 rw-p 000e6000 08:05 161344    /opt/openfoam171/lib/linuxGccDPOpt/libsurfMesh.so
b5bed000-b5e4d000 r-xp 00000000 08:05 161342    /opt/openfoam171/lib/linuxGccDPOpt/libsampling.so
b5e4d000-b5e52000 r--p 0025f000 08:05 161342    /opt/openfoam171/lib/linuxGccDPOpt/libsampling.so
b5e52000-b5e54000 rw-p 00264000 08:05 161342    /opt/openfoam171/lib/linuxGccDPOpt/libsampling.so
b5e54000-b5e55000 rw-p 00000000 00:00 0
b5e55000-b5e94000 r-xp 00000000 08:05 161367    /opt/openfoam171/lib/linuxGccDPOpt/libutilityFunctionObjects.so
b5e94000-b5e95000 r--p 0003e000 08:05 161367    /opt/openfoam171/lib/linuxGccDPOpt/libutilityFunctionObjects.so
b5e95000-b5e96000 rw-p 0003f000 08:05 161367    /opt/openfoam171/lib/linuxGccDPOpt/libutilityFunctionObjects.so
b5e96000-b5eaf000 r-xp 00000000 08:05 162439    /home/cschmitz/OpenFOAM/cschmitz-1.7.1/lib/linuxGccDPOpt/libdsmc2.so
b5eaf000-b5eb0000 ---p 00019000 08:05 162439    /home/cschmitz/OpenFOAM/cschmitz-1.7.1/lib/linuxGccDPOpt/libdsmc2.so
b5eb0000-b5eb1000 r--p 00019000 08:05 162439    /home/cschmitz/OpenFOAM/cschmitz-1.7.1/lib/linuxGccDPOpt/libdsmc2.so
b5eb1000-b5eb2000 rw-p 0001a000 08:05 162439    /home/cschmitz/OpenFOAM/cschmitz-1.7.1/lib/linuxGccDPOpt/libdsmc2.so
b5eb2000-b5ebc000 r-xp 00000000 08:05 2073      /lib/tls/i686/cmov/libnss_files-2.11.1.so
b5ebc000-b5ebd000 r--p 00009000 08:05 2073      /lib/tls/i686/cmov/libnss_files-2.11.1.so
b5ebd000-b5ebe000 rw-p 0000a000 08:05 2073      /lib/tls/i686/cmov/libnss_files-2.11.1.so
b5ed4000-b5ed6000 rw-p 00000000 00:00 0
b5ed6000-b5edd000 r-xp 00000000 08:05 2080      /lib/tls/i686/cmov/librt-2.11.1.so
b5edd000-b5ede000 r--p 00006000 08:05 2080      /lib/tls/i686/cmov/librt-2.11.1.so
b5ede000-b5edf000 rw-p 00007000 08:05 2080      /lib/tls/i686/cmov/librt-2.11.1.so
b5edf000-b5ee0000 rw-p 00000000 00:00 0
b5ee0000-b5ee1000 r-xp 00000000 08:05 83098      /usr/lib/libscotcherr-5.1.so
b5ee1000-b5ee2000 r--p 00000000 08:05 83098      /usr/lib/libscotcherr-5.1.so
b5ee2000-b5ee3000 rw-p 00001000 08:05 83098      /usr/lib/libscotcherr-5.1.so
b5ee3000-b5ee4000 r-xp 00000000 08:05 83099      /usr/lib/libscotcherrexit-5.1.so
b5ee4000-b5ee5000 r--p 00000000 08:05 83099      /usr/lib/libscotcherrexit-5.1.so
b5ee5000-b5ee6000 rw-p 00001000 08:05 83099      /usr/lib/libscotcherrexit-5.1.so
b5ee6000-b5f37000 r-xp 00000000 08:05 83091      /usr/lib/libscotch-5.1.so
b5f37000-b5f38000 r--p 00050000 08:05 83091      /usr/lib/libscotch-5.1.so
b5f38000-b5f3a000 rw-p 00051000 08:05 83091      /usr/lib/libscotch-5.1.so
b5f3a000-b5f3b000 rw-p 00000000 00:00 0
b5f3b000-b5f3f000 r-xp 00000000 08:05 161382    /opt/openfoam171/lib/linuxGccDPOpt/dummy/libparMetisDecomp.so
b5f3f000-b5f40000 r--p 00003000 08:05 161382    /opt/openfoam171/lib/linuxGccDPOpt/dummy/libparMetisDecomp.so
b5f40000-b5f41000 rw-p 00004000 08:05 161382    /opt/openfoam171/lib/linuxGccDPOpt/dummy/libparMetisDecomp.so
b5f41000-b5f45000 r-xp 00000000 08:05 161385    /opt/openfoam171/lib/linuxGccDPOpt/dummy/libmetisDecomp.so
b5f45000-b5f46000 r--p 00003000 08:05 161385    /opt/openfoam171/lib/linuxGccDPOpt/dummy/libmetisDecomp.so
b5f46000-b5f47000 rw-p 00004000 08:05 161385    /opt/openfoam171/lib/linuxGccDPOpt/dummy/libmetisDecomp.so
b5f47000-b5f48000 rw-p 00000000 00:00 0
b5f48000-b5f53000 r-xp 00000000 08:05 161377    /opt/openfoam171/lib/linuxGccDPOpt/libscotchDecomp.so
b5f53000-b5f54000 r--p 0000a000 08:05 161377    /opt/openfoam171/lib/linuxGccDPOpt/libscotchDecomp.so
b5f54000-b5f55000 rw-p 0000b000 08:05 161377    /opt/openfoam171/lib/linuxGccDPOpt/libscotchDecomp.so
b5f55000-b5f57000 r-xp 00000000 08:05 2428      /lib/tls/i686/cmov/libutil-2.11.1.so
b5f57000-b5f58000 r--p 00001000 08:05 2428      /lib/tls/i686/cmov/libutil-2.11.1.so
b5f58000-b5f59000 rw-p 00002000 08:05 2428      /lib/tls/i686/cmov/libutil-2.11.1.so
b5f59000-b5f6c000 r-xp 00000000 08:05 2070      /lib/tls/i686/cmov/libnsl-2.11.1.so
b5f6c000-b5f6d000 r--p 00012000 08:05 2070      /lib/tls/i686/cmov/libnsl-2.11.1.so
b5f6d000-b5f6e000 rw-p 00013000 08:05 2070      /lib/tls/i686/cmov/libnsl-2.11.1.so
b5f6e000-b5f70000 rw-p 00000000 00:00 0
b5f70000-b5fb5000 r-xp 00000000 08:05 159281    /usr/lib/openmpi/lib/libopen-pal.so.0.0.0
b5fb5000-b5fb6000 r--p 00044000 08:05 159281    /usr/lib/openmpi/lib/libopen-pal.so.0.0.0
b5fb6000-b5fb8000 rw-p 00045000 08:05 159281    /usr/lib/openmpi/lib/libopen-pal.so.0.0.0
b5fb8000-b5fda000 rw-p 00000000 00:00 0
b5fda000-b601c000 r-xp 00000000 08:05 159282    /usr/lib/openmpi/lib/libopen-rte.so.0.0.0
b601c000-b601d000 r--p 00041000 08:05 159282    /usr/lib/openmpi/lib/libopen-rte.so.0.0.0
b601d000-b601f000 rw-p 00042000 08:05 159282    /usr/lib/openmpi/lib/libopen-rte.so.0.0.0
b601f000-b6021000 rw-p 00000000 00:00 0
b6021000-b60a3000 r-xp 00000000 08:05 159277    /usr/lib/openmpi/lib/libmpi.so.0.0.1
b60a3000-b60a4000 r--p 00082000 08:05 159277    /usr/lib/openmpi/lib/libmpi.so.0.0.1
b60a4000-b60b1000 rw-p 00083000 08:05 159277    /usr/lib/openmpi/lib/libmpi.so.0.0.1
b60b1000-b60b9000 rw-p 00000000 00:00 0
b60b9000-b60cc000 r-xp 00000000 08:05 41531      /lib/libz.so.1.2.3.3
b60cc000-b60cd000 r--p 00012000 08:05 41531      /lib/libz.so.1.2.3.3
[1]+  Aborted                dsmcFoam > log

with original library everything is fine.
with library made from original code i get this error. I suppose somethings wrong with the compiler ?

I use the newest ubuntu lucid and OF 171.

Thanks for any comments !

cheers,
Archy

wyldckat October 5, 2010 10:32

Hi Archy,

According to the end of the output you posted, you are still using the original application:
Quote:

Code:

/opt/openfoam171/applications/bin/linuxGccDPOpt/dsmcFoam

And near the top you have this:
Quote:

Code:

/opt/openfoam171/lib/linuxGccDPOpt/libdsmc.so

This means that you're getting some weird pseudo-merge between two libraries:
Quote:

Code:

*** glibc detected *** dsmcFoam: double free or corruption (fasttop): 0x0899eea0 ***

Somehow, that merge seems to have lead to some weird double memory release.

So, basically, there are two possible solutions:
  1. Also build your own mydsmcFoam and tell it to link to your modified library.
  2. Modify your libdsmc2 to use other class names, thus creating a new type of object that doesn't name clash with the original! Then use the dictionary to tell dsmcFoam to use the new class/type name (I'm assuming it's possible, similarly as with creating new boundary types).
Best regards,
Bruno

wyldckat October 5, 2010 11:22

Hello again Archy,

I've just saw you sent me an email, but I rather reply here if you don't mind ;)

Just today Anton Kidess updated the tutorial "How to add temperature to icoFoam". You can see the related thread to this update: http://www.cfd-online.com/Forums/ope...ver-wmake.html

So modifying dsmcFoam should be done along similar lines :) Actually, you've already got some experience, when you changed the libdsmc library to be built into your user folder! It's similar to do for applications. And in the Make/options file, tell it to link to "-ldsmc2" instead of "-ldsmc".

Best regards and good luck!
Bruno

archymedes October 5, 2010 11:53

Hi Bruno,

i am not recompiling to a new dsmcFoam executable but only to obtain a new libdsmc2.so library, which should replace the original libdsmc.so .

wmake libso works and produces the new libdsmc2.so in my $FOAM_USER_LIBBIN folder

but when I try to use this library by adding
lib ("libdsmc2.so");
in the controlDict I get the above mentioned glibc Error.

But i think I understand your suggestion now, which is to compile a new myDsmcFoam executable as a whole and use this.

I'll try that!

thanks,
claus

wyldckat October 5, 2010 12:22

Hi Claus,

Quote:

Originally Posted by archymedes (Post 277915)
i am not recompiling to a new dsmcFoam executable but only to obtain a new libdsmc2.so library, which should replace the original libdsmc.so .

wmake libso works and produces the new libdsmc2.so in my $FOAM_USER_LIBBIN folder

but when I try to use this library by adding
lib ("libdsmc2.so");
in the controlDict I get the above mentioned glibc Error.

Exactly like I said: you were making dsmcFoam to load both libdsmc.so and libdsmc2.so into the dsmcFoam memory space. And you expected that the second one would replace the first one, but that cannot happen in the way things are made to work. The original dsmcFoam is hard coded to use libdsmc.so.

I've checked the settings.sh file in OpenFOAM-1.7.0/etc and saw something interesting: you should be able to give the same as of the original library. In other words, you can rename your custom library from libdsmc2 to libdsmc, because the search order defined in the settings.sh file is "User libraries first, OpenFOAM's second"! (See the environment variable LD_LIBRARY_PATH). And you won't need to do "lib ("libdsmc.so");", because the dsmcFoam is already hardcoded to load it.


The other few ways for youto replace this library are (I wrote this before checking the settings.sh file :rolleyes:):
  • Remove libdsmc.so from OpenFOAM's folder and replace with yours, but it has to have the exact same name.
  • Or copy the whole OpenFOAM binary library folder into your user folder and change the path for it in the environment variable LD_LIBRARY_PATH. This way, the original application binaries would use your local OpenFOAM libraries.
  • Or like I said before, the new library has to have a new class name, in order for it not to clash with the original one. And then define via one of the case's dictionary files to tell it to use the new class, on top of that forced library loading.
Other than all of these above, you'll have to build a modified dsmcFoam :(

The reason why simple replacing isn't allowed is usually for security reasons. Nonetheless, you could also try to use the LD_PRELOAD (if I'm not mistaken) environment variable to tell the system to pre-load the desired library before the other libraries are loaded. But again, this isn't a very secure solution and could lead to other problems down the road, assuming of course you won't get the same problem.

Best regards,
Bruno

archymedes October 18, 2010 07:20

Solution
 
Jep thats it. I've used the library two times and therefore freed the memory 2 times which lead to the error.

Thanks for your Help Bruno !!!
Cheers,
Claus


All times are GMT -4. The time now is 04:03.