[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Recursively calling a bash script goes undetected and eats all system me
From: |
Diggory Hardy |
Subject: |
Recursively calling a bash script goes undetected and eats all system memory |
Date: |
Wed, 8 Dec 2010 10:15:23 +0100 |
User-agent: |
KMail/1.13.5 (Linux/2.6.32-5-amd64; KDE/4.5.3; x86_64; ; ) |
Hello,
With a simple script such as that below, bash can enter an infinite loop of
eating memory until the system is rendered unusable:
#!/bin/bash
PATH=~
infinitely-recurse
Save this as infinitely-recurse in your home directory and run - and make sure
you kill it pretty quick. OK, so an obvious bug when put like this, though it
bit me recently (mistakenly using PATH as an ordinary variable and having a
script with the same name as a system program). Would it not be simple to add
some kind of protection against this — say don't let a script call itself more
than 100 times?
Thanks,
Diggory
Re: Recursively calling a bash script goes undetected and eats all system memory, Marc Herbert, 2010/12/10