From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5348 invoked by alias); 3 Jan 2015 11:11:11 -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 5311 invoked by uid 48); 3 Jan 2015 11:11:04 -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: Sat, 03 Jan 2015 11:11: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: UNCONFIRMED 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_status resolution 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/msg00101.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64478 Bernd Edlinger changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID |--- --- Comment #12 from Bernd Edlinger --- Andrew, please stop setting this bug to INVALID all the time that is not really funny any more. And I don't see, why this cant be fixed at all, there are only one or two memory allocations that have to be be pre-allocated in some kind of signal safe memory pool. Just to prove the concept I changed the test case c380004 to do some memory allocations while waiting for the asynchronous signal. --- ../gcc-trunk/gcc/testsuite/ada/acats/tests/c3/c380004.a 2014-05-24 19:26:48.763568674 +0200 +++ c380004.adb 2015-01-03 11:41:04.198306842 +0100 @@ -36,6 +36,7 @@ --! with Report; use Report; +with Unchecked_Deallocation; procedure C380004 is type Rec (D1, D2 : Positive) is @@ -180,7 +181,9 @@ end; end Check; - + type P is access Rec; + procedure Deallocate is new Unchecked_Deallocation(Rec, P); + pp : P; begin Test ("C380004", "Check evaluation of discriminant expressions " & @@ -190,6 +193,11 @@ Comment ("Discriminant-dependent entry families for task types"); + for I in 1..1000000000 loop + pp := new Rec(1,2); + Deallocate(pp); + end loop; +-- delay 60.0; F1_Poe := 18; usually I get this: ed@w-ed:~/gnu/gcc-test$ ./c380004 & [1] 21589 ed@w-ed:~/gnu/gcc-test$ ,.,. C380004 ACATS 2.5 15-01-03 11:45:42 ---- C380004 Check evaluation of discriminant expressions when the constraint depends on a discriminant, and the discriminants have defaults - discriminant-dependententry families and protected components. - C380004 Discriminant-dependent entry families for task types. ed@w-ed:~/gnu/gcc-test$ killall -SIGSEGV c380004 * C380004 Unexpected exception. **** C380004 FAILED ****************************. ed@w-ed:~/gnu/gcc-test$ [1]+ Fertig ./c380004 ed@w-ed:~/gnu/gcc-test$ but after several re-tries the killed process freezes: ed@w-ed:~/gnu/gcc-test$ ./c380004 & [1] 21592 ed@w-ed:~/gnu/gcc-test$ ,.,. C380004 ACATS 2.5 15-01-03 11:45:46 ---- C380004 Check evaluation of discriminant expressions when the constraint depends on a discriminant, and the discriminants have defaults - discriminant-dependententry families and protected components. - C380004 Discriminant-dependent entry families for task types. ed@w-ed:~/gnu/gcc-test$ ed@w-ed:~/gnu/gcc-test$ killall -SIGSEGV c380004 ed@w-ed:~/gnu/gcc-test$ ed@w-ed:~/gnu/gcc-test$ ed@w-ed:~/gnu/gcc-test$ ps PID TTY TIME CMD 2244 pts/0 00:00:00 bash 21592 pts/0 00:00:01 c380004 21596 pts/0 00:00:00 ps ed@w-ed:~/gnu/gcc-test$ sudo bash [sudo] password for ed: root@w-ed:~/gnu/gcc-test# gdb 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". (gdb) attach 21592 Attaching to process 21592 Reading symbols from /home/ed/gnu/gcc-test/c380004...done. Reading symbols from /lib/x86_64-linux-gnu/libpthread.so.0...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libpthread-2.19.so...done. done. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Loaded symbols for /lib/x86_64-linux-gnu/libpthread.so.0 Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.19.so...done. done. Loaded symbols for /lib/x86_64-linux-gnu/libc.so.6 Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/ld-2.19.so...done. done. Loaded symbols for /lib64/ld-linux-x86-64.so.2 __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) bt #0 __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 #1 0x00007f3549a8d84a in _L_lock_12779 () from /lib/x86_64-linux-gnu/libc.so.6 #2 0x00007f3549a8b225 in __GI___libc_malloc (bytes=704) at malloc.c:2887 #3 0x00000000004310d1 in <__gnat_malloc> (size=size@entry=704) at s-memory.adb:92 #4 0x0000000000439c70 in system.exceptions.machine.new_occurrence () at s-excmac.ads:183 #5 0x00000000004242c1 in ada.exceptions.exception_propagation.allocate_occurrence () at a-exexpr.adb:188 #6 0x000000000042521c in ada.exceptions.raise_with_location_and_msg ( e=0x65c8e0 , f=f@entry=(const system__address) 0x4437a0, l=l@entry=139, c=c@entry=0, m=m@entry=(const system__address) 0x444260) at a-except.adb:1159 #7 0x00000000004251fa in <__gnat_raise_storage_error_msg> ( file=file@entry=(const system__address) 0x4437a0, line=line@entry=139, msg=msg@entry=(const system__address) 0x444260) at a-except.adb:1144 #8 0x00000000004254bf in <__gnat_rcheck_SE_Explicit_Raise> ( file=file@entry=(const system__address) 0x4437a0, line=line@entry=139) at a-except.adb:1438 #9 0x0000000000421388 in system.interrupt_management.notify_exception ( signo=11, siginfo=, ucontext=(const system__address) 0x664540) at s-intman.adb:139 ---Type to continue, or q to quit--- #10 #11 0x00007f3549a88db0 in _int_malloc (av=0x7f3549dc7760 , bytes=8) at malloc.c:3355 #12 0x00007f3549a8b230 in __GI___libc_malloc (bytes=8) at malloc.c:2891 #13 0x00000000004310d1 in <__gnat_malloc> (size=) at s-memory.adb:92 #14 0x0000000000408117 in c380004 () at c380004.adb:197 (gdb)