← Back to team overview

touch-packages team mailing list archive

[Bug 1525436] Re: SEGV on function loop

 

** Description changed:

  I've the following code:
  
  $ cat foo.sh
  #!/bin/bash
  function f() { f; }; f;
  
  or:
  
  $ cat test.sh
  #!/bin/bash
  function foo() { foo; }
  foo
  
  which both crashing in the following way:
  
  $ ./foo.sh
  Segmentation fault (core dumped)
  
  is that normal?
  
  dmesg on Linux shows me the following errors:
  
  [  146.205518] foo.sh[1999]: segfault at 7fff9b6c8ef8 ip 00000000004b7628 sp 00007fff9b6c8f00 error 6 in bash[400000+f2000]
  [  867.791687] foo.sh[2020]: segfault at 7ffc82a11fe8 ip 00000000004b7628 sp 00007ffc82a11ff0 error 6 in bash[400000+f2000]
  [ 1023.472538] foo.sh[2049]: segfault at 7fff67f93f78 ip 00000000004b7628 sp 00007fff67f93f80 error 6 in bash[400000+f2000]
  [ 1129.373294] foo.sh[2058]: segfault at 7ffcf059ff68 ip 00000000004b7628 sp 00007ffcf059ff70 error 6 in bash[400000+f2000]
  
  On OSX I've got this:
  VM Regions Near 0x7fff503edfb8:
-     MALLOC_SMALL           00007ff65d800000-00007ff65e000000 [ 8192K] rw-/rwx SM=PRV  
+     MALLOC_SMALL           00007ff65d800000-00007ff65e000000 [ 8192K] rw-/rwx SM=PRV
  --> STACK GUARD            00007fff4cbee000-00007fff503ee000 [ 56.0M] ---/rwx SM=NUL  stack guard for thread 0
-     Stack                  00007fff503ee000-00007fff50bee000 [ 8192K] rw-/rwx SM=PRV  thread 0
+     Stack                  00007fff503ee000-00007fff50bee000 [ 8192K] rw-/rwx SM=PRV  thread 0
  
  Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
  0   bash                          	0x000000010f053ffa 0x10f012000 + 270330
  1   bash                          	0x000000010f04f964 0x10f012000 + 252260
  
  This happens in Ubuntu VM and on OSX.
  
+ I understand there is a infinite loop, however should bash crash with
+ SEGV? If it's out of resources (ulimit), it should be Killed by kernel
+ instead.
  
- I understand there is a infinite loop, however should bash crash with SEGV? If it's out of resources (ulimit), it should be Killed by kernel instead.
+ In comparison, this is how this script is handled by zsh:
+ 
+ $ zsh test.sh 
+ foo: maximum nested function level reached
+ 
+ so no SEGV here.
  
  My versions of bash which I've tested:
  GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin15.0.0)
  GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to bash in Ubuntu.
https://bugs.launchpad.net/bugs/1525436

Title:
  SEGV on function loop

Status in bash package in Ubuntu:
  New

Bug description:
  I've the following code:

  $ cat foo.sh
  #!/bin/bash
  function f() { f; }; f;

  or:

  $ cat test.sh
  #!/bin/bash
  function foo() { foo; }
  foo

  which both crashing in the following way:

  $ ./foo.sh
  Segmentation fault (core dumped)

  is that normal?

  dmesg on Linux shows me the following errors:

  [  146.205518] foo.sh[1999]: segfault at 7fff9b6c8ef8 ip 00000000004b7628 sp 00007fff9b6c8f00 error 6 in bash[400000+f2000]
  [  867.791687] foo.sh[2020]: segfault at 7ffc82a11fe8 ip 00000000004b7628 sp 00007ffc82a11ff0 error 6 in bash[400000+f2000]
  [ 1023.472538] foo.sh[2049]: segfault at 7fff67f93f78 ip 00000000004b7628 sp 00007fff67f93f80 error 6 in bash[400000+f2000]
  [ 1129.373294] foo.sh[2058]: segfault at 7ffcf059ff68 ip 00000000004b7628 sp 00007ffcf059ff70 error 6 in bash[400000+f2000]

  On OSX I've got this:
  VM Regions Near 0x7fff503edfb8:
      MALLOC_SMALL           00007ff65d800000-00007ff65e000000 [ 8192K] rw-/rwx SM=PRV
  --> STACK GUARD            00007fff4cbee000-00007fff503ee000 [ 56.0M] ---/rwx SM=NUL  stack guard for thread 0
      Stack                  00007fff503ee000-00007fff50bee000 [ 8192K] rw-/rwx SM=PRV  thread 0

  Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
  0   bash                          	0x000000010f053ffa 0x10f012000 + 270330
  1   bash                          	0x000000010f04f964 0x10f012000 + 252260

  This happens in Ubuntu VM and on OSX.

  I understand there is a infinite loop, however should bash crash with
  SEGV? If it's out of resources (ulimit), it should be Killed by kernel
  instead.

  In comparison, this is how this script is handled by zsh:

  $ zsh test.sh 
  foo: maximum nested function level reached

  so no SEGV here.

  My versions of bash which I've tested:
  GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin15.0.0)
  GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1525436/+subscriptions


References