Created attachment 42630 [details] The source reprising the bug Extract attached bug.zip into an empty directory. Run make compile ./obj/simple_test The command simple_test hangs. The most wonderful thing is that if I do not compile it (as "make compile" does) as an .a library imported when linking simple_test, but put all source into a single directory and run "gnatmake simple_test", then the error does not happen (but Program_Error is raised as it should be accordingly the docs, because pragma Unreserve_All_Interrupts is not in effect in this example code). Another weird thing that it happens with SIGINT but not with SIGTERM nor with SIGCHLD. The bug also does not happen if I remove "with Ada.Text_IO;". GCC 7.2.0.
Please provide a standalone reproducer without project file.
You should state what OS you’re using. After fixing the problems with the GPRs (withing projects that don’t necessarily exist on the user’s machine), PE is correctly raised on darwin 16.7.0 with GCC 7.1.0.
GCC 7.2.0, Debian Linux 4.13.0. Eric Botcazou: I can't make a standalone reproducer without project file, because the bug appears only when I compile in two stages: creating an .a library and then linking with this library.
If I remove `with "ahven";` from spawn_tests.gpr the bug disappears. Seems to do something with elaboration order. I also deleted `with "anet";` from spawn_common.gpr without any effect on the bug. I will attach bug2.zip without `with "anet";` (but with `with "ahven";`).
Created attachment 42633 [details] The source reprising the bug without "ainet" Needs "ahven" to reprise the bug.
I found that the presence of the bug depends on presense `-lahven` in the linker command. Adding -lahven leads to the bug, removing it removes the bug. Weird?
There is an easier way to reprise the bug: Copy all source files into a directory and run: gnatmake simple_test -largs -lahven ./simple_test To reprise the bug, you need Ahven installed. I will attach source files in gnatchop format.
Created attachment 42634 [details] Sources in gnatchop format Run gnatchop all.chop to extract the sources.
Seems to me your problem is with the Ahven library rather than with GCC, so the person to investigate it should be the Ahven maintainer.
I notified the Ahven author. However, the bug is quite weird: Isn't linking with a library just no-op if no functions from the library are called? I wonder how the bug may depend on linking with it. So I feel it is a GCC bug. I also did a quick search in Ahven sources about interrupts and signals and found nothing. So how can it be an Ahven bug?
Debian libahven27 package version 2.6-1.2.
I can reproduce the problem on Fedora 26 (x86_64) with Fedora's gcc. Linking libahven.so to simple_test dynamically causes the program to get stuck (infinite loop / dead lock?). Compiling Ahven from source code as a part of simple_test does not cause any problems. I would say the problem is either in GCC or in related components (binutils, glibc, etc.). % gcc -v Using built-in specs. COLLECT_GCC=/usr/bin/gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC) % Backtrace when the problem happens: % gdb ./simple_test GNU gdb (GDB) Fedora 8.0.1-30.fc26 Copyright (C) 2017 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-redhat-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 ./simple_test...(no debugging symbols found)...done. (gdb) run Starting program: /home/tkoskine/tmp/victor-bug2/src/simple_test [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x7ffff648f700 (LWP 5685)] [Thread 0x7ffff648f700 (LWP 5685) exited] ^C Thread 1 "simple_test" received signal SIGINT, Interrupt. 0x0000000000454675 in system.file_io.check_file_open () (gdb) bt #0 0x0000000000454675 in system.file_io.check_file_open () #1 0x0000000000451039 in ada.text_io.terminate_line () #2 0x0000000000455b2c in system.file_io.close () #3 0x0000000000455e43 in system.file_io.finalize () #4 0x000000000045623a in system.file_io.finalize_body () #5 0x000000000042e3b4 in ada_main.finalize_library () #6 0x00000000004395b6 in system.tasking.stages.finalize_global_tasks () #7 0x000000000042e3df in adafinal () #8 0x000000000042e8ee in main () #9 0x00007ffff73a688a in __libc_start_main (main=0x42e898 <main>, argc=1, argv=0x7fffffffe158, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe148) at ../csu/libc-start.c:295 #10 0x000000000042e2aa in _start () (gdb) stepi 0x0000000000451039 in ada.text_io.terminate_line () (gdb) 0x000000000045103c in ada.text_io.terminate_line () (gdb) 0x0000000000454e40 in system.file_io.mode () (gdb) 0x0000000000454e43 in system.file_io.mode () (gdb) 0x0000000000454e45 in system.file_io.mode () (gdb) 0x0000000000454e49 in system.file_io.mode () (gdb) 0x0000000000451041 in ada.text_io.terminate_line () (gdb) 0x0000000000451043 in ada.text_io.terminate_line () (gdb) 0x000000000045106d in ada.text_io.terminate_line () (gdb) 0x000000000045106e in ada.text_io.terminate_line () (gdb) 0x0000000000455b2c in system.file_io.close () (gdb) 0x0000000000455b2f in system.file_io.close () (gdb) 0x0000000000455b33 in system.file_io.close () (gdb) 0x0000000000455b35 in system.file_io.close () (gdb) 0x0000000000455b3b in system.file_io.close () (gdb) 0x0000000000455b3e in system.file_io.close () (gdb) 0x0000000000455b40 in system.file_io.close () (gdb) 0x0000000000455b43 in system.file_io.close () (gdb) 0x0000000000455b47 in system.file_io.close () (gdb) 0x0000000000455b4a in system.file_io.close () (gdb) 0x0000000000455c60 in system.file_io.close () (gdb) 0x0000000000455c64 in system.file_io.close () (gdb) 0x0000000000455c6b in system.file_io.close () (gdb) 0x0000000000455b58 in system.file_io.close () (gdb) 0x0000000000455b5b in system.file_io.close () (gdb) 0x0000000000455b5f in system.file_io.close () (gdb) 0x0000000000455b62 in system.file_io.close () (gdb) 0x0000000000455b64 in system.file_io.close () (gdb) 0x0000000000455b68 in system.file_io.close () (gdb) 0x0000000000455b6c in system.file_io.close () (gdb) 0x0000000000455b70 in system.file_io.close () (gdb) 0x0000000000455b72 in system.file_io.close () (gdb) 0x0000000000455bd7 in system.file_io.close () (gdb) 0x0000000000455bde in system.file_io.close () (gdb) 0x0000000000455be0 in system.file_io.close () (gdb) 0x0000000000455be6 in system.file_io.close () (gdb) 0x0000000000435c30 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c34 in system.tasking.initialization.task_unlock () (gdb) 0x00000000004337f0 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337f9 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fc in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fe in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x0000000000435c39 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c3f in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c42 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c44 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c4a in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c4c in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c50 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000455bec in system.file_io.close () (gdb) 0x0000000000455bed in system.file_io.close () (gdb) 0x0000000000455bee in system.file_io.close () (gdb) 0x0000000000455bf0 in system.file_io.close () (gdb) 0x0000000000455e43 in system.file_io.finalize () (gdb) 0x0000000000455e46 in system.file_io.finalize () (gdb) 0x0000000000455e4b in system.file_io.finalize () (gdb) 0x0000000000455e30 in system.file_io.finalize () (gdb) 0x0000000000455e34 in system.file_io.finalize () (gdb) 0x0000000000455e39 in system.file_io.finalize () (gdb) 0x0000000000455e3e in system.file_io.finalize () (gdb) 0x0000000000455b00 in system.file_io.close () (gdb) 0x0000000000455b02 in system.file_io.close () (gdb) 0x0000000000455b03 in system.file_io.close () (gdb) 0x0000000000455b04 in system.file_io.close () (gdb) 0x0000000000455b07 in system.file_io.close () (gdb) 0x0000000000435ab0 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ab4 in system.tasking.initialization.task_lock () (gdb) 0x00000000004337f0 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337f9 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fc in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fe in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x0000000000435ab9 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435abf in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ac2 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ac5 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435acb in system.tasking.initialization.task_lock () (gdb) 0x0000000000435acd in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ad1 in system.tasking.initialization.task_lock () (gdb) 0x0000000000455b0d in system.file_io.close () (gdb) 0x0000000000455b10 in system.file_io.close () (gdb) 0x0000000000455b13 in system.file_io.close () (gdb) 0x0000000000455b19 in system.file_io.close () (gdb) 0x0000000000455b1c in system.file_io.close () (gdb) 0x0000000000455b20 in system.file_io.close () (gdb) 0x0000000000455b22 in system.file_io.close () (gdb) 0x0000000000455b28 in system.file_io.close () (gdb) 0x0000000000455b2a in system.file_io.close () (gdb) 0x0000000000451090 in ada.text_io.afcb_close () (gdb) 0x0000000000451097 in ada.text_io.afcb_close () (gdb) 0x0000000000451099 in ada.text_io.afcb_close () (gdb) 0x00000000004510a0 in ada.text_io.afcb_close () (gdb) 0x00000000004510a2 in ada.text_io.afcb_close () (gdb) 0x00000000004510a9 in ada.text_io.afcb_close () (gdb) 0x00000000004510ab in ada.text_io.afcb_close () (gdb) 0x0000000000451030 in ada.text_io.terminate_line () (gdb) 0x0000000000451031 in ada.text_io.terminate_line () (gdb) 0x0000000000451034 in ada.text_io.terminate_line () (gdb) 0x0000000000454670 in system.file_io.check_file_open () (gdb) 0x0000000000454673 in system.file_io.check_file_open () (gdb) 0x0000000000454675 in system.file_io.check_file_open () (gdb) 0x0000000000451039 in ada.text_io.terminate_line () (gdb) 0x000000000045103c in ada.text_io.terminate_line () (gdb) 0x0000000000454e40 in system.file_io.mode () (gdb) 0x0000000000454e43 in system.file_io.mode () (gdb) 0x0000000000454e45 in system.file_io.mode () (gdb) 0x0000000000454e49 in system.file_io.mode () (gdb) 0x0000000000451041 in ada.text_io.terminate_line () (gdb) 0x0000000000451043 in ada.text_io.terminate_line () (gdb) 0x0000000000451045 in ada.text_io.terminate_line () (gdb) 0x0000000000451049 in ada.text_io.terminate_line () (gdb) 0x000000000045104b in ada.text_io.terminate_line () (gdb) 0x0000000000451052 in ada.text_io.terminate_line () (gdb) 0x000000000045106d in ada.text_io.terminate_line () (gdb) 0x000000000045106e in ada.text_io.terminate_line () (gdb) 0x0000000000455b2c in system.file_io.close () (gdb) 0x0000000000455b2f in system.file_io.close () (gdb) 0x0000000000455b33 in system.file_io.close () (gdb) 0x0000000000455b35 in system.file_io.close () (gdb) 0x0000000000455b3b in system.file_io.close () (gdb) 0x0000000000455b3e in system.file_io.close () (gdb) 0x0000000000455b40 in system.file_io.close () (gdb) 0x0000000000455b43 in system.file_io.close () (gdb) 0x0000000000455b47 in system.file_io.close () (gdb) 0x0000000000455b4a in system.file_io.close () (gdb) 0x0000000000455c60 in system.file_io.close () (gdb) 0x0000000000455c64 in system.file_io.close () (gdb) 0x0000000000455c6b in system.file_io.close () (gdb) 0x0000000000455b58 in system.file_io.close () (gdb) 0x0000000000455b5b in system.file_io.close () (gdb) 0x0000000000455b5f in system.file_io.close () (gdb) 0x0000000000455b62 in system.file_io.close () (gdb) 0x0000000000455b64 in system.file_io.close () (gdb) 0x0000000000455b68 in system.file_io.close () (gdb) 0x0000000000455b6c in system.file_io.close () (gdb) 0x0000000000455b70 in system.file_io.close () (gdb) 0x0000000000455b72 in system.file_io.close () (gdb) 0x0000000000455bd7 in system.file_io.close () (gdb) 0x0000000000455bde in system.file_io.close () (gdb) 0x0000000000455be0 in system.file_io.close () (gdb) 0x0000000000455be6 in system.file_io.close () (gdb) 0x0000000000435c30 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c34 in system.tasking.initialization.task_unlock () (gdb) 0x00000000004337f0 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337f9 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fc in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fe in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x0000000000435c39 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c3f in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c42 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c44 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c4a in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c4c in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c50 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000455bec in system.file_io.close () (gdb) 0x0000000000455bed in system.file_io.close () (gdb) 0x0000000000455bee in system.file_io.close () (gdb) 0x0000000000455bf0 in system.file_io.close () (gdb) 0x0000000000455e43 in system.file_io.finalize () (gdb) 0x0000000000455e46 in system.file_io.finalize () (gdb) 0x0000000000455e4b in system.file_io.finalize () (gdb) 0x0000000000455e30 in system.file_io.finalize () (gdb) 0x0000000000455e34 in system.file_io.finalize () (gdb) 0x0000000000455e39 in system.file_io.finalize () (gdb) 0x0000000000455e3e in system.file_io.finalize () (gdb) 0x0000000000455b00 in system.file_io.close () (gdb) 0x0000000000455b02 in system.file_io.close () (gdb) 0x0000000000455b03 in system.file_io.close () (gdb) 0x0000000000455b04 in system.file_io.close () (gdb) 0x0000000000455b07 in system.file_io.close () (gdb) 0x0000000000435ab0 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ab4 in system.tasking.initialization.task_lock () (gdb) 0x00000000004337f0 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337f9 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fc in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fe in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x0000000000435ab9 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435abf in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ac2 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ac5 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435acb in system.tasking.initialization.task_lock () (gdb) 0x0000000000435acd in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ad1 in system.tasking.initialization.task_lock () (gdb) 0x0000000000455b0d in system.file_io.close () (gdb) 0x0000000000455b10 in system.file_io.close () (gdb) 0x0000000000455b13 in system.file_io.close () (gdb) 0x0000000000455b19 in system.file_io.close () (gdb) 0x0000000000455b1c in system.file_io.close () (gdb) 0x0000000000455b20 in system.file_io.close () (gdb) 0x0000000000455b22 in system.file_io.close () (gdb) 0x0000000000455b28 in system.file_io.close () (gdb) 0x0000000000455b2a in system.file_io.close () (gdb) 0x0000000000451090 in ada.text_io.afcb_close () (gdb) 0x0000000000451097 in ada.text_io.afcb_close () (gdb) 0x0000000000451099 in ada.text_io.afcb_close () (gdb) 0x00000000004510a0 in ada.text_io.afcb_close () (gdb) 0x00000000004510a2 in ada.text_io.afcb_close () (gdb) 0x00000000004510a9 in ada.text_io.afcb_close () (gdb) 0x00000000004510ab in ada.text_io.afcb_close () (gdb) 0x0000000000451030 in ada.text_io.terminate_line () (gdb) 0x0000000000451031 in ada.text_io.terminate_line () (gdb) 0x0000000000451034 in ada.text_io.terminate_line () (gdb) 0x0000000000454670 in system.file_io.check_file_open () (gdb) 0x0000000000454673 in system.file_io.check_file_open () (gdb) 0x0000000000454675 in system.file_io.check_file_open () (gdb) 0x0000000000451039 in ada.text_io.terminate_line () (gdb) 0x000000000045103c in ada.text_io.terminate_line () (gdb) 0x0000000000454e40 in system.file_io.mode () (gdb) 0x0000000000454e43 in system.file_io.mode () (gdb) 0x0000000000454e45 in system.file_io.mode () (gdb) 0x0000000000454e49 in system.file_io.mode () (gdb) 0x0000000000451041 in ada.text_io.terminate_line () (gdb) 0x0000000000451043 in ada.text_io.terminate_line () (gdb) 0x0000000000451045 in ada.text_io.terminate_line () (gdb) 0x0000000000451049 in ada.text_io.terminate_line () (gdb) 0x000000000045104b in ada.text_io.terminate_line () (gdb) 0x0000000000451052 in ada.text_io.terminate_line () (gdb) 0x0000000000451054 in ada.text_io.terminate_line () (gdb) 0x000000000045105b in ada.text_io.terminate_line () (gdb) 0x000000000045106d in ada.text_io.terminate_line () (gdb) 0x000000000045106e in ada.text_io.terminate_line () (gdb) 0x0000000000455b2c in system.file_io.close () (gdb) 0x0000000000455b2f in system.file_io.close () (gdb) 0x0000000000455b33 in system.file_io.close () (gdb) 0x0000000000455b35 in system.file_io.close () (gdb) 0x0000000000455b3b in system.file_io.close () (gdb) 0x0000000000455b3e in system.file_io.close () (gdb) 0x0000000000455b40 in system.file_io.close () (gdb) 0x0000000000455b43 in system.file_io.close () (gdb) 0x0000000000455b47 in system.file_io.close () (gdb) 0x0000000000455b4a in system.file_io.close () (gdb) 0x0000000000455c60 in system.file_io.close () (gdb) 0x0000000000455c64 in system.file_io.close () (gdb) 0x0000000000455c6b in system.file_io.close () (gdb) 0x0000000000455b58 in system.file_io.close () (gdb) 0x0000000000455b5b in system.file_io.close () (gdb) 0x0000000000455b5f in system.file_io.close () (gdb) 0x0000000000455b62 in system.file_io.close () (gdb) 0x0000000000455b64 in system.file_io.close () (gdb) 0x0000000000455b68 in system.file_io.close () (gdb) 0x0000000000455b6c in system.file_io.close () (gdb) 0x0000000000455b70 in system.file_io.close () (gdb) 0x0000000000455b72 in system.file_io.close () (gdb) 0x0000000000455bd7 in system.file_io.close () (gdb) 0x0000000000455bde in system.file_io.close () (gdb) 0x0000000000455be0 in system.file_io.close () (gdb) 0x0000000000455be6 in system.file_io.close () (gdb) 0x0000000000435c30 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c34 in system.tasking.initialization.task_unlock () (gdb) 0x00000000004337f0 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337f9 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fc in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fe in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x0000000000435c39 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c3f in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c42 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c44 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c4a in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c4c in system.tasking.initialization.task_unlock () (gdb) 0x0000000000435c50 in system.tasking.initialization.task_unlock () (gdb) 0x0000000000455bec in system.file_io.close () (gdb) 0x0000000000455bed in system.file_io.close () (gdb) 0x0000000000455bee in system.file_io.close () (gdb) 0x0000000000455bf0 in system.file_io.close () (gdb) 0x0000000000455e43 in system.file_io.finalize () (gdb) 0x0000000000455e46 in system.file_io.finalize () (gdb) 0x0000000000455e4b in system.file_io.finalize () (gdb) 0x0000000000455e30 in system.file_io.finalize () (gdb) 0x0000000000455e34 in system.file_io.finalize () (gdb) 0x0000000000455e39 in system.file_io.finalize () (gdb) 0x0000000000455e3e in system.file_io.finalize () (gdb) 0x0000000000455b00 in system.file_io.close () (gdb) 0x0000000000455b02 in system.file_io.close () (gdb) 0x0000000000455b03 in system.file_io.close () (gdb) 0x0000000000455b04 in system.file_io.close () (gdb) 0x0000000000455b07 in system.file_io.close () (gdb) 0x0000000000435ab0 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ab4 in system.tasking.initialization.task_lock () (gdb) 0x00000000004337f0 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337f9 in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fc in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x00000000004337fe in system__task_primitives__operations(short,...)(long, float) () (gdb) 0x0000000000435ab9 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435abf in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ac2 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ac5 in system.tasking.initialization.task_lock () (gdb) 0x0000000000435acb in system.tasking.initialization.task_lock () (gdb) 0x0000000000435acd in system.tasking.initialization.task_lock () (gdb) 0x0000000000435ad1 in system.tasking.initialization.task_lock () (gdb) 0x0000000000455b0d in system.file_io.close () (gdb) 0x0000000000455b10 in system.file_io.close () (gdb) 0x0000000000455b13 in system.file_io.close () (gdb) 0x0000000000455b19 in system.file_io.close () (gdb) 0x0000000000455b1c in system.file_io.close () (gdb)
It is a GCC bug rather than an Ahven bug, because the bug is triggered by `with Ada.Text_IO;` (and disappears if we remove this line from spawn-signals.adb) which should not influence semantics of the program, because the imported package is not used.
Created attachment 42640 [details] ahven sources + modified simple_test I added a way to reproduce the problem. Extract all files, check Makefile, run "make all && make run". Expected results: "make run" (simple_test) finishes successfully. Actual results (with gcc 7.2 on Fedora 26): "make run" (simple_test) gets stuck to infinite loop. I simplified simple_test.adb into following: with Text_IO; procedure Simple_Test is begin null; end Simple_Test; Note that if you remove "for Library_Interface use .." statement from ahven_simple_lib.gpr, the problem does not appear. Also, if you use static library, the problem does not appear. It is required that you use shared library and specify the library interface files.
> It is a GCC bug rather than an Ahven bug, because the bug is triggered by > `with Ada.Text_IO;` (and disappears if we remove this line from > spawn-signals.adb) which should not influence semantics of the program, > because the imported package is not used. Maybe, but can you extract a self-contained reproducer in order to give a definitive answer to the question? I know nothing about this Ahven library.
I've discovered that Ahven source uses tasking. So it is most likely some tasking problem with Ahven.
Created attachment 42666 [details] Minimal example reprising the bug I've created the minimal example reprising the bug. The bug is actually awful: Just four innocent (doing nothing) source files cause the program to hang infinitely despite it was asked to do none. Note that the bug is triggered only for dynamic libraries. To reprise the bug unpack the attached minimal.tar.gz archive run make all && make run It stucks infinitely. Now we know for sure: It is a GCC (or maybe linker) bug, not Ahven one.
> Created attachment 42666 [details] > Minimal example reprising the bug > > I've created the minimal example reprising the bug. > > The bug is actually awful: Just four innocent (doing nothing) source files > cause the program to hang infinitely despite it was asked to do none. > > Note that the bug is triggered only for dynamic libraries. Thanks for the small reproducer. This has apparently never worked correctly...
The small reproducer (minimal.tar.gz) doesn’t show the error with macOS : GCC 6.1.0, GCC 7.1.0, GCC 8.0.0, GNAT GPL 2017 debian jessie: GNAT GPL 2017 NB, for GNAT GPL 2017 I had to add Astrings to the interface set in ahven_simple_lib.gpr.
> Thanks for the small reproducer. This has apparently never worked correctly... And the workaround is to pass -F to gnatbind for the main program.
@Eric Botcazou: Adding binder flag -F solves the problem in the attached examples https://gcc.gnu.org/bugzilla/attachment.cgi?id=42630 and https://gcc.gnu.org/bugzilla/attachment.cgi?id=42666 but not in my real code: https://github.com/vporton/spawn-manager
> Adding binder flag -F solves the problem in the attached examples > https://gcc.gnu.org/bugzilla/attachment.cgi?id=42630 and > https://gcc.gnu.org/bugzilla/attachment.cgi?id=42666 but not in my real code: > > https://github.com/vporton/spawn-manager My gut feeling is that it's a different issue.