[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Segfault on recursive trap/kill

From: Mike Gerwitz
Subject: Segfault on recursive trap/kill
Date: Fri, 05 Oct 2018 21:33:17 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

The following code will cause a segfault on bash-4.4.19(1) on
GNU Guix.  I reproduced the issue on an old Ubuntu 14.04 LTS running
bash-4.3.11(1) as well as a Trisquel system running the same version.

  bash -c 'trap "kill 0" TERM; kill 0'

Also segfaults when replacing `0' with `$$', and presumably in any other
situation that would trigger the trap recursively.

I don't have the debug symbols, but here's the backtrace:

  #0  0x00007ffff6f7ad77 in kill () at ../sysdeps/unix/syscall-template.S:78
  #1  0x0000000000446513 in kill_pid ()
  #2  0x00000000004817a6 in kill_builtin ()
  #3  0x000000000043248d in execute_builtin.isra ()
  #4  0x0000000000434924 in execute_simple_command ()
  #5  0x0000000000435c2f in execute_command_internal ()
  #6  0x00000000004357e6 in execute_command_internal ()
  #7  0x000000000047d88f in parse_and_execute ()
  #8  0x000000000041be48 in run_one_command ()
  #9  0x000000000041da19 in main ()

I don't have a strong opinion on what the expected behavior ought to be
in this situation; I certainly didn't intend to discover this issue. :)

For context: I discovered this when my trap tried to kill a subprocess,
but the integer variable storing the pid of that process was not
properly set.

Mike Gerwitz
Free Software Hacker+Activist | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]