From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5283 invoked by alias); 4 Jan 2015 11:59:58 -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 5223 invoked by uid 48); 4 Jan 2015 11:59:50 -0000 From: "bernd.edlinger at hotmail dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug ada/64478] Ada Exception handlers call signal-unsafe malloc/free Date: Sun, 04 Jan 2015 11:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ada X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bernd.edlinger at hotmail dot de X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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-01/txt/msg00153.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64478 --- Comment #14 from Bernd Edlinger --- hmm, ok, but how about this: --- ../gcc-trunk/gcc/testsuite/ada/acats/tests/cb/cb1010d.ada 2014-05-24 19:26:45.338568486 +0200 +++ cb1010d.adb 2015-01-04 12:55:21.458653242 +0100 @@ -29,14 +29,23 @@ -- JRK 8/30/85 WITH REPORT; USE REPORT; +WITH UNCHECKED_DEALLOCATION; PROCEDURE CB1010D IS N : INTEGER := IDENT_INT (1); M : INTEGER := IDENT_INT (0); + TYPE P IS ACCESS INTEGER; + PROCEDURE DEALLOCATE IS NEW Unchecked_Deallocation(INTEGER, P); + PROCEDURE OVERFLOW_STACK IS + X : P; BEGIN + X := new INTEGER; + X.ALL := 1; + DEALLOCATE (X); + N := N + M; IF N > M THEN -- ALWAYS TRUE. OVERFLOW_STACK; ed@w-ed:~/gnu/gcc-test$ gdb ./cb1010d GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./cb1010d...done. (gdb) r Starting program: /home/ed/gnu/gcc-test/cb1010d ,.,. CB1010D ACATS 2.5 15-01-04 12:56:58 ---- CB1010D CHECK THAT STORAGE_ERROR IS RAISED WHEN STORAGE FOR THE EXECUTION OF A SUBPROGRAM IS INSUFFICIENT. Program received signal SIGSEGV, Segmentation fault. _int_malloc (av=0x7ffff7dd3760 , bytes=4) at malloc.c:3302 3302 malloc.c: Datei oder Verzeichnis nicht gefunden. (gdb) c Continuing. ^C Program received signal SIGINT, Interrupt. __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 95 ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Datei oder Verzeichnis nicht gefunden. (gdb) q A debugging session is active. Inferior 1 [process 9469] will be killed. Quit anyway? (y or n) y ed@w-ed:~/gnu/gcc-test$ LANG=C ed@w-ed:~/gnu/gcc-test$ gdb ./cb1010d GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./cb1010d...done. (gdb) r Starting program: /home/ed/gnu/gcc-test/cb1010d ,.,. CB1010D ACATS 2.5 15-01-04 12:57:19 ---- CB1010D CHECK THAT STORAGE_ERROR IS RAISED WHEN STORAGE FOR THE EXECUTION OF A SUBPROGRAM IS INSUFFICIENT. Program received signal SIGSEGV, Segmentation fault. _int_malloc (av=0x7ffff7dd3760 , bytes=4) at malloc.c:3302 3302 malloc.c: No such file or directory. (gdb) c Continuing. ^C Program received signal SIGINT, Interrupt. __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 95 ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: No such file or directory. (gdb) bt #0 __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 #1 0x00007ffff7a9984a in _L_lock_12779 () at malloc.c:5206 #2 0x00007ffff7a97225 in __GI___libc_malloc (bytes=704) at malloc.c:2887 #3 0x0000000000415881 in <__gnat_malloc> (size=size@entry=704) at s-memory.adb:92 #4 0x000000000041d480 in system.exceptions.machine.new_occurrence () at s-excmac.ads:183 #5 0x0000000000409843 in ada.exceptions.exception_propagation.allocate_occurrence () at a-exexpr.adb:188 #6 0x000000000040a6b5 in ada.exceptions.create_occurrence_from_signal_handler (e=0x636b60 , m=(const system__address) 0x429350) at a-except.adb:1058 #7 0x000000000040a702 in ada.exceptions.raise_from_signal_handler ( e=, m=) at a-except.adb:1093 #8 #9 _int_malloc (av=0x7ffff7dd3760 , bytes=4) at malloc.c:3302 #10 0x00007ffff7a97230 in __GI___libc_malloc (bytes=4) at malloc.c:2891 #11 0x0000000000415881 in <__gnat_malloc> (size=) at s-memory.adb:92 #12 0x0000000000407237 in cb1010d.overflow_stack () at cb1010d.adb:45 #13 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #14 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #15 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #16 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #17 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #18 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #19 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #20 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #21 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #22 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #23 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #24 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #25 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #26 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #27 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #28 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #29 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 #30 0x00000000004072be in cb1010d.overflow_stack () at cb1010d.adb:51 Deadlock: the exception is synchronous, but within malloc...