Bash dumps stack after writing to /etc
meingbg
meingbg@gmail.com
Fri Sep 21 23:11:00 GMT 2012
A bug is found that might be located in cygwin or bash.
Bash dumps stack on exit if all of the following requirements are true:
- Bash was started from a windows batch script
- Bash was started in non-interactive mode to execute a script
- The script includes an attempt to write (pipe) data to a file in /etc
- The write attempt is enclosed by an if clause.
To reproduce the bug, start a windows batch script that starts bash in
non-interactive mode running a bash script that within an if clause
attempts to write to a file in the /etc directory. This will result in a bash
stack dump, at least on Windows 7 Professional SP1.
As an example, place example*.bat and script*.bash (code listed below)
in the cygwin root folder. Then start the batch files via the Windows GUI.
example1-breaks.bat reproduces the bug.
example1i-works.bat shows that bash works like expected in interactive mode.
example2-works.bat shows that bash works like expected when writing to
a file outside of /etc.
example3-maybe.bat shows that the if clause might change the behaviour.
File listing follows. Make sure to save the .bat files with windows
linebreaks, and the .bash files with unix linebreaks.
example1-breaks.bat:
@echo off
%~d0
cd %~dp0
bin\bash.exe script1.bash
pause
example1i-works.bat:
@echo off
%~d0
cd %~dp0
bin\bash.exe -i script1.bash
pause
example2-works.bat:
@echo off
%~d0
cd %~dp0
bin\bash.exe script2.bash
pause
example3-maybe.bat:
@echo off
%~d0
cd %~dp0
bin\bash.exe script3.bash
pause
script1.bash:
#!/bin/bash
PATH="/bin:$PATH"
if true; then
echo hello > /etc/hello
fi
script2.bash:
#!/bin/bash
PATH="/bin:$PATH"
if true; then
echo hello > /hello
fi
script3.bash:
#!/bin/bash
PATH="/bin:$PATH"
echo hello > /etc/hello
fi
System information:
Machine: i686
OS: cygwin on Windows 7 Professional SP1
Compiler: gcc-4
Compilation CFLAGS: -DPROGRAM='bash.exe' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='cygwin' -DCONF_MACHTYPE='i686-pc-cygwin' -DCONF_VENDOR='pc'
-DLOCALEDIR='/usr/$
uname output: CYGWIN_NT-6.1 Machine-name 1.7.16(0.262/5/3) 2012-07-20 22:55
i686 Cygwin
Machine Type: i686-pc-cygwin
See also attached cygcheck.out. It was created by cygcheck running
independently from any cygwin installation. "WITHHELD" denotes a
manual alteration.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 21892 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20120921/dfd8c5a2/attachment.obj>
-------------- next part --------------
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list