Author Topic: Segmentation fault - invalid memory reference.  (Read 10443 times)

bck230

  • New Member
  • *
  • Posts: 6
Segmentation fault - invalid memory reference.
« on: June 22, 2021, 01:00:02 AM »
Dear all,

I used Feappv to do a project simulating the effect on the stent resulting from the impulse of the artery.
A user macro is applied to read mesh data generated by gmsh. This works well.
I can plot the mesh of the stent in the plot window of feappv.
But when I take a boundary and force as a test, feappv will crash after tang,,1.
And terminal returns the error: Segmentation fault - invalid memory reference.
I searched the past posts regarding the issue, and try to use valgrind to run it again to see where the problem is.
Then I found that the problem is at these lines in the 2 respective files.
The first is when loading mesh data. Feappv didn't crash but valgrind say there's some issue in "bjac3d.f:53"

==3146== Invalid read of size 16
==3146==    at 0x17403A: bjac3d_ (bjac3d.f:53)
==3146==    by 0x170FCF: ckbrk8_ (ckbrk8.f:69)
==3146==    by 0x2088F3: pform_ (pform.f:215)
==3146==    by 0x195EDF: formfe_ (formfe.f:63)
==3146==    by 0x1E1FE9: pmacr1_ (pmacr1.f:732)
==3146==    by 0x1763CE: pmacr_ (pmacr.f:373)
==3146==    by 0x10D2EC: pcontr_ (pcontr.f:533)
==3146==    by 0x10B762: feappv (feappv.f:130)
==3146==    by 0x10B762: main (feappv.f:135)
==3146==  Address 0x5c87fd0 is 0 bytes after a block of size 96 alloc'd
==3146==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3146==    by 0x1FDF27: setmem_ (setmem.f:81)
==3146==    by 0x1D78F9: usetmem_ (usetmem.f:53)
==3146==    by 0x1BDD06: ualloc_ (ualloc.f:57)
==3146==    by 0x173B71: palloc_ (palloc.f:684)
==3146==    by 0x171EAF: pnewprob_ (pnewprob.f:456)
==3146==    by 0x10C7BE: pcontr_ (pcontr.f:409)
==3146==    by 0x10B762: feappv (feappv.f:130)
==3146==    by 0x10B762: main (feappv.f:135)


And when I command tang,,1, it would crash and return this error:
   List  4  Command  1> tang,,1
 *Command   1 * tang                v:   1.00       0.00       0.00
                                                           t=    65.88     0.95
==3148== Warning: set address range perms: large range [0x59c9d040, 0xd6d7bfc0) (undefined)
==3148== Invalid read of size 8
==3148==    at 0x2325AA: dasble_ (dasble.f:100)
==3148==    by 0x208B36: pform_ (pform.f:321)
==3148==    by 0x195EDF: formfe_ (formfe.f:63)
==3148==    by 0x1E25DC: pmacr1_ (pmacr1.f:275)
==3148==    by 0x1763CE: pmacr_ (pmacr.f:373)
==3148==    by 0x10D2EC: pcontr_ (pcontr.f:533)
==3148==    by 0x10B762: feappv (feappv.f:130)
==3148==    by 0x10B762: main (feappv.f:135)
==3148==  Address 0x3f0904240 is not stack'd, malloc'd or (recently) free'd
==3148==

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

I was wondering if there is a limit for the number of mesh elements.
There are almost 200k elements in the mesh file.
I'm not sure if it's the reason resulting in the error.

Any responses will be highly appreciated.
Thank you for your reading.
Sorry the mesh file can't exceed by 5000KB, so I can't post mesh file here.

Best,
Ruei-Bo
« Last Edit: June 22, 2021, 01:23:58 AM by bck230 »

Prof. R.L. Taylor

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 2647
Re: Segmentation fault - invalid memory reference.
« Reply #1 on: June 22, 2021, 07:04:19 AM »
There seems to be an error  in bjac3d looping to 8 when you are using 4-node tets(?).

In the module ./elements/solid3d/solid3d.f  add a check on number of element nodes

if (nel .eq. 8 ) then
  call ckbrk8  ....
elseif(nel .eq. 4 ) then
   call cktets(n_el, ix, xl, ndm , nel, shp3)
endif

It would be good to add a check on tets being valid as above.  The routine seems to exist.

You may want to try using OPTI to improve the tangent size.  You may be out of memory with 200K in 3-d???

Could be something else.  Does everything work with a smaller problem?



« Last Edit: June 22, 2021, 11:12:26 AM by Prof. S. Govindjee »

bck230

  • New Member
  • *
  • Posts: 6
Re: Segmentation fault - invalid memory reference.
« Reply #2 on: June 24, 2021, 08:58:28 PM »
Dear Professor Taylor,

Thank you for your answer.
I modified the solid3d.f and it didn't return an error anymore.
And it can solve the tang,,1 now. I still try to set up a radial load on it.
Then I try to use a smaller mesh of the stent to try.
There are only around 20000 elements this time.
But It returned "Insufficient storage to allocate TANG1".
I searched the forum and put OPTI and DIREct, SPARse before tang,,1.
Valgrind will crash directly when using direct, sparse, and so do Feappv without valgrind.

error message is as followed:
==100== Invalid write of size 8
==100==    at 0x4842964: memset (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==100==    by 0x1FA175: iters_ (iters.f:47)
==100==    by 0x1768BE: pmacr_ (pmacr.f:373)
==100==    by 0x10D2EC: pcontr_ (pcontr.f:533)
==100==    by 0x10B762: feappv (feappv.f:130)
==100==    by 0x10B762: main (feappv.f:135)
==100==  Address 0x5cd9a80 is 0 bytes inside a block of size 4 alloc'd
==100==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==100==    by 0x1FE7E7: setmem_ (setmem.f:81)
==100==    by 0x1D81B9: usetmem_ (usetmem.f:53)
==100==    by 0x1BE5C6: ualloc_ (ualloc.f:57)
==100==    by 0x173B71: palloc_ (palloc.f:684)
==100==    by 0x1FA15A: iters_ (iters.f:46)
==100==    by 0x1768BE: pmacr_ (pmacr.f:373)
==100==    by 0x10D2EC: pcontr_ (pcontr.f:533)
==100==    by 0x10B762: feappv (feappv.f:130)
==100==    by 0x10B762: main (feappv.f:135)


But since the original mesh worked, I will try to implement that.
Thank you for your reply!

Best,
Ruei-Bo Chen

Prof. R.L. Taylor

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 2647
Re: Segmentation fault - invalid memory reference.
« Reply #3 on: June 25, 2021, 06:27:58 AM »
FEAPpv does not include the sparse solver.  The only options are the profile solver.  The OPTI is only intended for use with the profile solver as sparse solvers have their own optimization included.

Only FEAP has options for use of a sparse solver.