From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7801 invoked by alias); 5 Sep 2015 07:22:51 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 7746 invoked by uid 48); 5 Sep 2015 07:22:46 -0000 From: "Joost.VandeVondele at mat dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/67457] New: segfault in libbacktrace Date: Sat, 05 Sep 2015 07:22:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Joost.VandeVondele at mat dot ethz.ch X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-09/txt/msg00398.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67457 Bug ID: 67457 Summary: segfault in libbacktrace Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: Joost.VandeVondele at mat dot ethz.ch Target Milestone: --- gfortran on trunk uses libbacktrace to print backtraces on error. In an out-of-memory situation, libbacktrace will fail to print a backtrace and segfault instead. While having something like a backtrace would be nice (and other compilers seem to manage), I guess that's difficult. For the segfault gdb print this: Starting program: /data/vjoost/gnu/bugs/a.out Operating system error: Cannot allocate memory Allocation would exceed memory limit Error termination. Backtrace: Could not print backtrace: mmap: Cannot allocate memory Could not print backtrace: mmap: Cannot allocate memory Could not print backtrace: mmap: Cannot allocate memory Program received signal SIGSEGV, Segmentation fault. backtrace_free_locked (state=0x7ffff7ecc000, size=3912, addr=0x20b7) at ../../../gcc/libbacktrace/mmap.c:75 75 p->size = size; (gdb) bt #0 backtrace_free_locked (state=0x7ffff7ecc000, size=3912, addr=0x20b7) at ../../../gcc/libbacktrace/mmap.c:75 #1 backtrace_free (state=0x7ffff7ecc000, addr=0x20b7, size=3912, error_callback=, data=) at ../../../gcc/libbacktrace/mmap.c:199 #2 0x00007ffff7fcd077 in backtrace_alloc (state=state@entry=0x7ffff7ecc000, size=size@entry=8376, error_callback=error_callback@entry=0x7ffff7ee8cd0 , data=data@entry=0x7fffffffde90) at ../../../gcc/libbacktrace/mmap.c:148 #3 0x00007ffff7fcc7f8 in elf_initialize_syminfo (sdata=0x7ffff7ec0620, data=0x7fffffffde90, error_callback=0x7ffff7ee8cd0 , strtab_size=, strtab=, symtab_size=, symtab_data=0x7ffff7eb5088 "", base_address=140737352400896, state=0x7ffff7ecc000) at ../../../gcc/libbacktrace/elf.c:380 #4 elf_add (state=, descriptor=, base_address=140737352400896, error_callback=, data=0x7fffffffde90, fileline_fn=fileline_fn@entry=0x7fffffffd998, found_sym=0x7fffffffda70, found_dwarf=0x7fffffffd994, exe=0) at ../../../gcc/libbacktrace/elf.c:748 #5 0x00007ffff7fccc67 in phdr_callback (info=0x7fffffffd9e0, size=, pdata=0x7fffffffda80) at ../../../gcc/libbacktrace/elf.c:903 #6 0x0000003ba4b26726 in dl_iterate_phdr () from /lib64/libc.so.6 #7 0x00007ffff7fccd30 in backtrace_initialize (state=state@entry=0x7ffff7ecc000, descriptor=, error_callback=error_callback@entry=0x7ffff7ee8cd0 , data=data@entry=0x7fffffffde90, fileline_fn=fileline_fn@entry=0x7fffffffdb08) at ../../../gcc/libbacktrace/elf.c:944 #8 0x00007ffff7fcb8b4 in fileline_initialize (state=state@entry=0x7ffff7ecc000, error_callback=error_callback@entry=0x7ffff7ee8cd0 , data=data@entry=0x7fffffffde90) at ../../../gcc/libbacktrace/fileline.c:136 #9 0x00007ffff7fcb992 in backtrace_pcinfo (state=0x7ffff7ecc000, pc=140737352994313, callback=0x7ffff7ee8b10 , error_callback=0x7ffff7ee8cd0 , data=0x7fffffffde90) at ../../../gcc/libbacktrace/fileline.c:170 #10 0x00007ffff7fcbe61 in unwind (context=, vdata=0x7fffffffde50) at ../../../gcc/libbacktrace/backtrace.c:83 #11 0x00007ffff7ea8439 in _Unwind_Backtrace (trace=trace@entry=0x7ffff7fcbe10 , trace_argument=trace_argument@entry=0x7fffffffde50) at ../../../gcc/libgcc/unwind.inc:295 #12 0x00007ffff7fcbeb5 in backtrace_full (state=state@entry=0x7ffff7ecc000, skip=skip@entry=0, callback=callback@entry=0x7ffff7ee8b10 , error_callback=error_callback@entry=0x7ffff7ee8cd0 , data=data@entry=0x7fffffffde90) at ../../../gcc/libbacktrace/backtrace.c:106 #13 0x00007ffff7ee8e0a in _gfortrani_show_backtrace (in_signal_handler=in_signal_handler@entry=false) at ../../../gcc/libgfortran/runtime/backtrace.c:156 #14 0x00007ffff7ee9906 in _gfortrani_exit_error (status=status@entry=1) at ../../../gcc/libgfortran/runtime/error.c:196 #15 0x00007ffff7ee9b03 in _gfortrani_os_error (message=0x400a28 "Allocation would exceed memory limit") at ../../../gcc/libgfortran/runtime/error.c:348 #16 0x000000000040081e in foomod::foo (a=..., n=0) at test_1.f90:7 #17 0x00000000004008c0 in MAIN__ () at test_1.f90:16 Testcase: > cat test_1.f90 MODULE foomod CONTAINS SUBROUTINE foo(a,N) INTEGER, DIMENSION(:), POINTER :: a INTEGER :: N ALLOCATE(a(N)) a=0 END SUBROUTINE END MODULE foomod USE foomod INTEGER, DIMENSION(:), POINTER :: a INTEGER :: N DO CALL foo(a,N) ENDDO END > gfortran -g test_1.f90 > ulimit -v 1000000 > ./a.out Operating system error: Cannot allocate memory Allocation would exceed memory limit Error termination. Backtrace: Could not print backtrace: mmap: Cannot allocate memory Could not print backtrace: mmap: Cannot allocate memory Could not print backtrace: mmap: Cannot allocate memory Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: Segmentation fault