bug-bash
[Top][All Lists]
Advanced

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

Re: Simple sleep scripts causes SEGFAULT


From: Robert Elz
Subject: Re: Simple sleep scripts causes SEGFAULT
Date: Thu, 26 Oct 2017 11:37:38 +0700

    Date:        Wed, 25 Oct 2017 21:21:23 -0700
    From:        Alex Coffin <address@hidden>
    Message-ID:  <address@hidden>

  |     Run the following script (assuming you trust me lol):
  |     function sleep {
  |       local dur
  |       dur="$1"
  |       # if replaced with "echo" no segfault.
  |       sleep ${dur}s
  |     }
  |     "sleep" $((5))

This one is easy, your function is calling itself recursively, (sleep,
calls sleep, calls sleep, calls sleep ....) until the stack runs out.

When you make the (internal) sleep be echo, the problem vanishes...

You can fix it by renaming the function to be something other than sleep,
by replacing the inner sleep with "command sleep" so it won't run the
function, or by replacing it with /bin/sleep (or wherever sleep is found
on your system.)

kre




reply via email to

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