ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/08/08/16:37:27

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Subject: That BASH crash, revisited
To: djgpp AT delorie DOT com
X-Mailer: Lotus Notes Release 6.5.4 CCH5 September 12, 2005
Message-ID: <OF61A52282.CB39175D-ON872571C4.006931B1-872571C4.0070EA32@seagate.com>
From: Gordon DOT Schumacher AT seagate DOT com
Date: Tue, 8 Aug 2006 14:34:54 -0600
X-MIMETrack: Serialize by Router on SV-GW1/Seagate Internet(Release 7.0.1 HF29|March 07, 2006) at
08/08/2006 01:33:39 PM
MIME-Version: 1.0
X-Proofpoint-FWRule: outbound2
X-Proofpoint-Virus-Version: vendor=fsecure engine=4.64.4171:2.3.9,1.2.33,4.0.164 definitions=2006-08-08_04:2006-08-08,2006-08-04,2006-08-08 signatures=0

Long ago, I wrote about a crash in shell-scripts related
to "return" from a BASH function:

http://www.delorie.com/djgpp/mail-archives/thread.cgi?msg=djgpp/2004/05/09/05:01:32&mode=frames
http://www.delorie.com/djgpp/mail-archives/thread.cgi?msg=djgpp/2004/05/10/13:02:56&mode=frames

I've now been working with this stuff enough - and my new
job has afforded me the time - that I've been able to
reproduce it in a very short script.

It appears to require the use of command substitution -
of any kind - from within a function:

#!/bin/sh

func()
{
   echo Calling out to the world...
   echo `uname`
   echo Preparing to meet our maker!
   return
}

func


This line will also make it crash:
boom=$(uname)


Here's the crashdump, as run through my variant of bfdsymify:

Exiting due to signal SIGSEGV
General Protection Fault at eip=00025f4a
eax=cfcfcfcf ebx=00139d48 ecx=0000000c edx=cfcfcfcf esi=00038ed7
edi=00038ed7
ebp=0012c9d8 esp=0012c9c0 program=c:\djgpp\bin\bash.exe
cs: sel=01ff  base=02b70000  limit=0014ffff
ds: sel=0207  base=02b70000  limit=0014ffff
es: sel=0207  base=02b70000  limit=0014ffff
fs: sel=01d7  base=0000de50  limit=0000ffff
gs: sel=0217  base=00000000  limit=0010ffff
ss: sel=0207  base=02b70000  limit=0014ffff
App stack: [0012d668..000ad668]  Exceptn stack: [000accac..000aad6c]

Call frame traceback EIPs:
  0x00025f4a hash_search
             c:/djgpp/src/bash-2.05b/djbuild/../hashlib.c:175
  0x000154af kill_all_local_variables
             c:/djgpp/src/bash-2.05b/djbuild/../variables.c:1347
  0x00015516 var_lookup
             c:/djgpp/src/bash-2.05b/djbuild/../variables.c:1360
  0x00015548 find_variable_internal
             c:/djgpp/src/bash-2.05b/djbuild/../variables.c:1393
  0x000155b0 find_variable
             c:/djgpp/src/bash-2.05b/djbuild/../variables.c:1405
  0x00038f99 nofork_restore_all_environment
             c:/djgpp/src/bash-2.05b/djbuild/../nofork.c:249
  0x0001ec43 command_substitute
             c:/djgpp/src/bash-2.05b/djbuild/../subst.c:3926
  0x00021461 expand_string_unsplit_to_string
             c:/djgpp/src/bash-2.05b/djbuild/../subst.c:6120
  0x0013bdc8 __tty_screen
             ??:0
  0x000549e1 inttostr
             ../../../lib/sh/itos.c:39


Any thoughts?  Let me know what else I can do to help
debug this.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019