forbidden memory area access (libCoolProp.so.6)

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
niuniuaba
Posts: 18
Joined: Mon May 17, 2021 10:22 am

forbidden memory area access (libCoolProp.so.6)

Post by niuniuaba »

Hi there,

I am trying out code_saturne 7.2.0 and run into error when define fluid property with CoolProp. By the way, the fluid is just 'Water'.

Code: Select all


command: 
 ./cs_solver --trace --logp --mpi

***************************************************************

                                  (R)
                      Code_Saturne

                      Version 7.2.0


  Copyright (C) 1998-2022 EDF S.A., France

  build Mon 17 Oct 2022 01:44:43 PM CST

  The Code_Saturne CFD tool  is free software;
  you can redistribute it and/or modify it under the terms
  of the GNU General Public License as published by the
  Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  The Code_Saturne CFD tool is distributed in the hope that
  it will be useful, but WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A
  PARTICULAR PURPOSE.  See the GNU General Public License
  for more details.

***************************************************************


Local case configuration:

  Date:                Mon 17 Oct 2022 01:48:59 PM CST
  System:              Linux 5.15.0-50-generic (Ubuntu 22.04.1 LTS)
  Machine:             qe
  Processor:           model name	: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Memory:              15652 MB
  User:                wing (wing)
  Directory:           /home/wing/Data/CAE/Pipe/pipeSaturne/Case1/RESU/20221017-1348
  MPI ranks:           4 (appnum attribute: 0)
  OpenMP threads:      2
  Processors/node:     12

  Compilers used for build:
    C compiler:        gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
    C++ compiler:      g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0
    Fortran compiler:  GNU Fortran (Ubuntu 11.2.0-19ubuntu1) 11.2.0

  MPI version: 3.1 (Open MPI 4.1.2)
  OpenMP version: 4.5

  External libraries:
    PT-SCOTCH 6.1.2

  I/O read method:     collective MPI-IO (explicit offsets)
  I/O write method:    collective MPI-IO (explicit offsets)
  I/O rank step:        1


===============================================================

                   CALCULATION PREPARATION
                   =======================


 ===========================================================



SIGSEGV signal (forbidden memory area access) intercepted!

Call stack:
   1: 0x7f5d48b3cfa6 <_ZN8CoolProp16_PropsSI_outputsERSt10shared_ptrINS_13AbstractStat> (libCoolProp.so.6)

I noticed that 'cs_meg_volume_function.c' is not generated. And if I change fluid property method to 'user_material' and set properties manually the calculation executed as expected. It's probably a CoolProp issue but I cannot find an answer on their github site yet and I hope there is some hint here.

Thanks in advance.
Yvan Fournier
Posts: 4157
Joined: Mon Feb 20, 2012 3:25 pm

Re: forbidden memory area access (libCoolProp.so.6)

Post by Yvan Fournier »

Hello,

I'll run a test soon to see if the issue is in code_saturne or Coolprop, and keep you updated in a few days at most.

Regards,

Yvan
niuniuaba
Posts: 18
Joined: Mon May 17, 2021 10:22 am

Re: forbidden memory area access (libCoolProp.so.6)

Post by niuniuaba »

Hello Yvan,

Thank you for your quick response. Here is some information for reference:
Ubuntu 22.04, gcc 11.2.0, OpenMPI 4.1.2, CoolProp 6.4.1 downloaded from sourceforge.net and built by

Code: Select all

cmake -DCOOLPROP_INSTALL_PREFIX=/home/wing/Apps/CoolProp -DCOOLPROP_SHARED_LIBRARY=ON
Best regards,
niuniuaba
Yvan Fournier
Posts: 4157
Joined: Mon Feb 20, 2012 3:25 pm

Re: forbidden memory area access (libCoolProp.so.6)

Post by Yvan Fournier »

Hello,

I can reproduce the error on a simple case, with uniform material properties (meaning code_saturne calls Coolprop only on a size 1 array of values, and then applies the result to all cells).

Checking under a debugger, it seems the arguments passed to CoolProp are OK, as shown in this debugger screenshot:
coolprop_gdb_capture.png
So this should be reproducible on a simple C++ example, providing the same inputs (useful for a CoolProp bug report).
My build of CoolProp is an older 6.1.1-dev version, and is not a debug build, but this is probably the same issu you observed with 6.4.1...

Perhaps the other back-ends than "HEOS" might provide better results...

So it seems a CoolProp bug-report might be needed...

Regarding 'cs_meg_volume_function.c' not being generated, this is strange. At least on my test build (master branch), they are generated (I did not test with v7.2.0).

Best regards,

Yvan
niuniuaba
Posts: 18
Joined: Mon May 17, 2021 10:22 am

Re: forbidden memory area access (libCoolProp.so.6)

Post by niuniuaba »

Hello,

I confirmed that the same build of CoolProp works properly in CS-7.0.0. I prepared debug versions of CS and CoolProp and now get some more information:

Code: Select all

SIGSEGV signal (forbidden memory area access) intercepted!

Call stack:
   1: 0x7fd701a49520 <+0x42520>                       (libc.so.6)
   2: 0x7fd7004b561d <_ZN8CoolProp16_PropsSI_outputsERSt10shared_ptrINS_13AbstractStatYý9'V> (libCoolProp.so.6)
   3: 0x7fd7004b6e4e <_ZN8CoolProp13_PropsSImultiERKSt6vectorINSt7__cxx1112basic_strinYý9'V>> (libCoolProp.so.6)
   4: 0x7fd7004b7432 <_ZN8CoolProp12PropsSImultiERKSt6vectorINSt7__cxx1112basic_stringYý9'V>>> (libCoolProp.so.6)
   5: 0x7fd70213271d <cs_phys_prop_coolprop+0x80e>    (libsaturne-7.2.so)
   6: 0x7fd701f18379 <cs_phys_prop_compute+0x2ca>     (libsaturne-7.2.so)
   7: 0x7fd702b8f8f1 <cs_gui_physical_properties+0x3c4> (libsaturne-7.2.so)
   8: 0x7fd701fdfe89 <iniusi_+0x523>                  (libsaturne-7.2.so)
   9: 0x7fd701fdf38f <initi1_+0x116>                  (libsaturne-7.2.so)
  10: 0x7fd7036627ab <+0x57ab>                        (libcs_solver-7.2.so)
  11: 0x7fd703662e71 <main+0x154>                     (libcs_solver-7.2.so)
  12: 0x7fd701a30d90 <+0x29d90>                       (libc.so.6)
  13: 0x7fd701a30e40 <__libc_start_main+0x80>         (libc.so.6)
  14: 0x562737e2a0a5 <_start+0x25>                    (cs_solver)
End of stack
And if I run cs_solver from inside gdb I get this:

Code: Select all

(gdb) r
Starting program: /home/wing/Data/CAE/Pipe/pipeSaturne/Case1/RESU/7.2/cs_solver 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff36cf640 (LWP 216351)]
[New Thread 0x7ffff2ece640 (LWP 216352)]
[New Thread 0x7ffff26cd640 (LWP 216353)]
[New Thread 0x7ffff1ecc640 (LWP 216354)]
[New Thread 0x7ffff16cb640 (LWP 216355)]
[New Thread 0x7ffff0eca640 (LWP 216356)]
[New Thread 0x7ffff06c9640 (LWP 216357)]
[New Thread 0x7fffefec8640 (LWP 216358)]
[New Thread 0x7fffef6c7640 (LWP 216359)]
[New Thread 0x7fffeeec6640 (LWP 216360)]
[New Thread 0x7fffee6c5640 (LWP 216361)]

Thread 1 "cs_solver" received signal SIGSEGV, Segmentation fault.
CoolProp::_PropsSI_outputs (State=std::shared_ptr<CoolProp::AbstractState> (use count 1, weak count 0) = {...}, output_parameters=std::vector of length 1, capacity 1 = {...}, input_pair=CoolProp::PT_INPUTS, in1=std::vector of length 0, capacity 0, in2=std::vector of length 0, capacity 0, IO=std::vector of length 1, capacity 1 = {...}) at /home/wing/Downloads/CoolProp.sources/src/CoolProp.cpp:381
381	                    State->update(input_pair, in1[i], in2[i]);
I don't know how to dig deeper because I am not familiar with debugging. Any tips or general description of doing it in gdb will be appreciated.
Could it be the way of calling coolprop from CS? I noticed that cs_coolprop code in 7.3/7.2 is slightly different from that of 7.0.

Best regards,
niuniuaba
Yvan Fournier
Posts: 4157
Joined: Mon Feb 20, 2012 3:25 pm

Re: forbidden memory area access (libCoolProp.so.6)

Post by Yvan Fournier »

Hello,

Thanks for the detailed feedback.
I'll check with v7.0. The changes betwen v7.9 and v7.2 were intended to allow the user to set some CoolProp settings, but thereight be a side effect.

I'll check if reverting to the v7.0 code in v7.2 (not using the additional argument) solves the issue or not, and keep you updated.

Best regards,

Yvan
niuniuaba
Posts: 18
Joined: Mon May 17, 2021 10:22 am

Re: forbidden memory area access (libCoolProp.so.6)

Post by niuniuaba »

Hello,

I confirmed that regression to code from 7.0 resolves the issue. More specifically, I replaced cs_coolprop.hxx, cs_coolprop.cxx, cs_physical_properties.h and cs_physical_properties.c from 7.0 then 7.2 compiled successfully and the calculation executed as expected (both from command line and gui). Don't know if there is any side effect though.

Best regards
Post Reply