SeisSol / PUMGen

Mesh generation for SeisSol
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

Segmentation Fault when Converting .neu File with PumGen #74

Closed draguve closed 4 months ago

draguve commented 4 months ago

I encountered an issue while attempting to convert a .neu file generated with SimModeler v2024.0-240519 using PumGen. This (faults_250.zip) is the file i used for testing.

I compiled pumgen without simmetrix support using the following library versions:

The program crashes during the conversion process with the following error output:

(base) 017552119@cos-bmadden-dt:~/Faults/test_simple_500_0.15_8AR$ ./pumgen faults_250.neu test
Fri Jul 12 15:06:25, Info: No filtering enabled (contiguous storage)
Fri Jul 12 15:06:25, Info: Using 32-bit integer boundary type conditions, or 8 bit per face (i32).
Fri Jul 12 15:06:25, Info: Using Gambit mesh
Fri Jul 12 15:06:25, Warn: Gambit format does not seem to have a fixed boundary line length. Trying with variable line length
Fri Jul 12 15:06:25, Info: Read vertex coordinates
Fri Jul 12 15:06:25, Info: Reading vertices part 1 of 1
Fri Jul 12 15:06:26, Info: Read cell vertices
Fri Jul 12 15:06:26, Info: Reading elements part 1 of 1
Fri Jul 12 15:06:28, Info: Read cell groups
Fri Jul 12 15:06:28, Info: Reading group information part 1 of 1
Fri Jul 12 15:06:29, Info: Read boundary conditions
Fri Jul 12 15:06:29, Info: Reading boundary conditions part 1 of 1
[cos-bmadden-dt:1370791] *** Process received signal ***
[cos-bmadden-dt:1370791] Signal: Segmentation fault (11)
[cos-bmadden-dt:1370791] Signal code: Address not mapped (1)
[cos-bmadden-dt:1370791] Failing at address: 0x278
[cos-bmadden-dt:1370791] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7f6e2dd11520]
[cos-bmadden-dt:1370791] [ 1] ./pumgen(+0x16375)[0x5562c0004375]
[cos-bmadden-dt:1370791] [ 2] ./pumgen(+0x16c15)[0x5562c0004c15]
[cos-bmadden-dt:1370791] [ 3] ./pumgen(+0x1904f)[0x5562c000704f]
[cos-bmadden-dt:1370791] [ 4] ./pumgen(+0x976f)[0x5562bfff776f]
[cos-bmadden-dt:1370791] [ 5] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x7f6e2dcf8d90]
[cos-bmadden-dt:1370791] [ 6] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7f6e2dcf8e40]
[cos-bmadden-dt:1370791] [ 7] ./pumgen(+0xc025)[0x5562bfffa025]
[cos-bmadden-dt:1370791] *** End of error message ***
Segmentation fault (core dumped)

Upon running the program with gdb, I obtained the following backtrace:

Thread 1 "pumgen" received signal SIGSEGV, Segmentation fault.
0x000055555556a375 in int& std::vector<int, std::allocator<int> >::emplace_back<int>(int&&) ()
(gdb) backtrace
#0  0x000055555556a375 in int& std::vector<int, std::allocator<int> >::emplace_back<int>(int&&) ()
#1  0x000055555556ac15 in puml::ParallelGambitReader::readBoundaries(int*) ()
#2  0x000055555556d04f in SerialMeshFile<puml::ParallelGambitReader>::open(char const*) ()
#3  0x000055555555d76f in main ()

I also built a debug version instead of a release, and it seems to crash at a different location with a heap overflow

(base) 017552119@cos-bmadden-dt:~/Faults/test_simple_500_0.15_8AR$ ~/PUMGen/pumgen/debug-build/pumgen faults_250.neu test
Fri Jul 12 15:31:27, Info:  No filtering enabled (contiguous storage)
Fri Jul 12 15:31:27, Info:  Using 32-bit integer boundary type conditions, or 8 bit per face (i32).
Fri Jul 12 15:31:27, Info:  Using Gambit mesh
Fri Jul 12 15:31:27, Warn:  Gambit format does not seem to have a fixed boundary line length. Trying with variable line length
Fri Jul 12 15:31:27, Warn:  Gambit format does not seem to have a fixed boundary line length. Trying with variable line length
Fri Jul 12 15:31:27, Warn:  Gambit format does not seem to have a fixed boundary line length. Trying with variable line length
Fri Jul 12 15:31:27, Info:  Read vertex coordinates
Fri Jul 12 15:31:27, Info:  Reading vertices part 1 of 1
Fri Jul 12 15:31:29, Info:  Read cell vertices
Fri Jul 12 15:31:29, Info:  Reading elements part 1 of 1
Fri Jul 12 15:31:32, Info:  Read cell groups
Fri Jul 12 15:31:32, Info:  Reading group information part 1 of 1
=================================================================
==1374651==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60400004f7b8 at pc 0x55ec870c54e2 bp 0x7ffd2eb949a0 sp 0x7ffd2eb94990
READ of size 8 at 0x60400004f7b8 thread T0
    #0 0x55ec870c54e1 in puml::GambitReader::readGroups(unsigned long, unsigned long, puml::ElementGroup*) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x2c4e1)
    #1 0x55ec870c77cd in puml::ParallelGambitReader::readGroups(int*) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x2e7cd)
    #2 0x55ec870dee22 in SerialMeshFile<puml::ParallelGambitReader>::open(char const*) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x45e22)
    #3 0x55ec870d3a76 in SerialMeshFile<puml::ParallelGambitReader>::SerialMeshFile(char const*, int, ompi_communicator_t*) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x3aa76)
    #4 0x55ec870abbe9 in main /home/017552119/PUMGen/pumgen/src/pumgen.cpp:319
    #5 0x7f9f391e9d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #6 0x7f9f391e9e3f in __libc_start_main_impl ../csu/libc-start.c:392
    #7 0x55ec870a7bc4 in _start (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0xebc4)

0x60400004f7b8 is located 0 bytes to the right of 40-byte region [0x60400004f790,0x60400004f7b8)
allocated by thread T0 here:
    #0 0x7f9f39fff1e7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x55ec870fb9ad in __gnu_cxx::new_allocator<puml::GambitReader::GroupSection>::allocate(unsigned long, void const*) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x629ad)
    #2 0x55ec870f2eec in std::allocator_traits<std::allocator<puml::GambitReader::GroupSection> >::allocate(std::allocator<puml::GambitReader::GroupSection>&, unsigned long) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x59eec)
    #3 0x55ec870e86f9 in std::_Vector_base<puml::GambitReader::GroupSection, std::allocator<puml::GambitReader::GroupSection> >::_M_allocate(unsigned long) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x4f6f9)
    #4 0x55ec870da431 in std::vector<puml::GambitReader::GroupSection, std::allocator<puml::GambitReader::GroupSection> >::_M_default_append(unsigned long) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x41431)
    #5 0x55ec870cec10 in std::vector<puml::GambitReader::GroupSection, std::allocator<puml::GambitReader::GroupSection> >::resize(unsigned long) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x35c10)
    #6 0x55ec870c1a15 in puml::GambitReader::open(char const*) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x28a15)
    #7 0x55ec870dc404 in ParallelMeshReader<puml::GambitReader>::open(char const*) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x43404)
    #8 0x55ec870de9a6 in SerialMeshFile<puml::ParallelGambitReader>::open(char const*) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x459a6)
    #9 0x55ec870d3a76 in SerialMeshFile<puml::ParallelGambitReader>::SerialMeshFile(char const*, int, ompi_communicator_t*) (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x3aa76)
    #10 0x55ec870abbe9 in main /home/017552119/PUMGen/pumgen/src/pumgen.cpp:319
    #11 0x7f9f391e9d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: heap-buffer-overflow (/home/017552119/PUMGen/pumgen/debug-build/pumgen+0x2c4e1) in puml::GambitReader::readGroups(unsigned long, unsigned long, puml::ElementGroup*)
Shadow bytes around the buggy address:
  0x0c0880001ea0: fa fa 00 00 00 00 00 00 fa fa 00 00 00 00 00 00
  0x0c0880001eb0: fa fa 00 00 00 00 00 00 fa fa 00 00 00 00 00 00
  0x0c0880001ec0: fa fa 00 00 00 00 00 00 fa fa 00 00 00 00 00 00
  0x0c0880001ed0: fa fa 00 00 00 00 00 00 fa fa fd fd fd fd fd fd
  0x0c0880001ee0: fa fa fd fd fd fd fd fd fa fa fd fd fd fd fd fd
=>0x0c0880001ef0: fa fa 00 00 00 00 00[fa]fa fa fd fd fd fd fd fd
  0x0c0880001f00: fa fa fd fd fd fd fd fd fa fa fa fa fa fa fa fa
  0x0c0880001f10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880001f20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880001f30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880001f40: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==1374651==ABORTING

Has anyone else encountered a similar error? If so, do you have any suggestions or ideas on what I could try to resolve this issue?

davschneller commented 4 months ago

Thank you for your issue and the builds; I'm gonna look into the reason for why that is happening. While that is going on—you could try using PUMgen v1.0.1 .

draguve commented 4 months ago

Thank you for the suggestion! I tried using PUMgen v1.0.1, and it worked perfectly. Please let me know if there's anything I can do to assist further.