URL: <http://savannah.gnu.org/bugs/?51237>
Summary: Deadlock in Ctrl-C handler on Windows Project: make Submitted by: mbuilov Submitted on: Wed 14 Jun 2017 12:43:28 PM UTC Severity: 3 - Normal Item Group: Bug Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Component Version: 4.2.1 Operating System: MS Windows Fixed Release: None Triage Status: None _______________________________________________________ Details: Hello. There is a bug in processing of Ctrl+C event under WINDOWS. Gnu make handles Ctrl+C in fatal_error_signal() function, which suspends Main thread. But, if Main thread get suspended while it locks resources, where is a possibility for dead-lock. It's easy to reproduce dead-lock with this makefile: # run make -j -O, then press Ctrl+C all: a b c d CMD := cmd.exe /c "echo off & for /l %a in (0,1,1000) do echo %a" a:;$(CMD) b:;$(CMD) c:;$(CMD) d:;$(CMD) .PHONY: all a b c d (backtrace1 attached) Even without job-server and output synchronization, it is possible to dead-lock make or put it to infinite loop: # just run make without options, then press Ctrl+C # (hard to reproduce dead-lock) GOALS := a b c d e f g h i j k l m n o p q r s t u v w x y z GOALS += $(GOALS:=1) GOALS += $(GOALS:=2) GOALS += $(GOALS:=3) all: $(GOALS) $(GOALS):;cmd.exe /c "echo off & echo 1 > NUL" .PHONY: all $(GOALS) (backtrace2 attached) One of possible solutions to this dead-lock problem - instead of suspending Main thread, Ctrl+C handler thread may notify Main thread to stop and wait until it releases resources and goes to sleep. Here is the patch: https://github.com/mbuilov/gnumake-windows/blob/master/make-4.2.1-win32-ctrl-c.patch _______________________________________________________ File Attachments: ------------------------------------------------------- Date: Wed 14 Jun 2017 12:43:28 PM UTC Name: backtrace1 Size: 1kB By: mbuilov backtraces of dead-locked Main and Ctrl+C threads <http://savannah.gnu.org/bugs/download.php?file_id=40917> ------------------------------------------------------- Date: Wed 14 Jun 2017 12:43:28 PM UTC Name: backtrace2 Size: 2kB By: mbuilov backtraces of dead-locked Main and Ctrl+C threads <http://savannah.gnu.org/bugs/download.php?file_id=40918> _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?51237> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make