[Bug ada/64478] Ada Exception handlers call signal-unsafe malloc/free

bernd.edlinger at hotmail dot de gcc-bugzilla@gcc.gnu.org
Sun Jan 4 11:59:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64478

--- Comment #14 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
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 <http://gnu.org/licenses/gpl.html>
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:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
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 <main_arena>, 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 <http://gnu.org/licenses/gpl.html>
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:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
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 <main_arena>, 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 <storage_error>, m=(const system__address) 0x429350)
    at a-except.adb:1058
#7  0x000000000040a702 in ada.exceptions.raise_from_signal_handler (
    e=<optimized out>, m=<optimized out>) at a-except.adb:1093
#8  <signal handler called>
#9  _int_malloc (av=0x7ffff7dd3760 <main_arena>, bytes=4) at malloc.c:3302
#10 0x00007ffff7a97230 in __GI___libc_malloc (bytes=4) at malloc.c:2891
#11 0x0000000000415881 in <__gnat_malloc> (size=<optimized out>)
    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...



More information about the Gcc-bugs mailing list