On 6/2/14, 6:02 PM, osirisgothra paradisim llc wrote:
> Bash Version: 4.3
> Patch Level: 11
> Release Status: release
>
> Description:
> Seems that the shell crashes when the value of PS2 is set to
> something that is evaluated when displayed, and the user presses (usually by
> accident) CTRL+D (EOF) when entering extra lines, especially "here
> documents". It also seems that the current line must be EMPTY when Ctrl+D is
> pressed by accident, if there is (usually) keystrokes already entered, then
> the crash does not happen and it works as expected (which is probably why it
> has taken so long for me to figure out what was doing it). Now I understand
> that Ctrl+D is bound to also exit the shell however the two issues are the
> crashing (segmentation fault), and the continuity of behavior dependent upon
> the number of characters entered. I said (usually) earlier because there are
> some times (not sure why) that there are a few characters on the line, but I
> have not been able to reproduce this only two times, so I'm not sure what
> that's all about.
>
> Repeat-By:
>
> bash --norc --noprofile (also tried running from inside /usr/bin/env but it
> acts the same)
> ubuntu@localhost:~$ PS2='$(echo "enter something>")'
> ubuntu@localhost:~$ cat <<-EOF
> enter something>here's some text
> enter something>pressing ctrl+d on the next line
> enter something>
> bash: warning: here-document at line 30 delimited by end-of-file (wanted
> `EOF')
> Segmentation fault (core dumped)
Thanks for the report. I've attached a patch that fixes the problem.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.3-patched/shell.h 2012-12-25 21:11:01.0 -0500
--- shell.h 2014-06-03 09:24:28.0 -0400
***
*** 169,173
int expand_aliases;
int echo_input_at_read;
!
} sh_parser_state_t;
--- 169,174
int expand_aliases;
int echo_input_at_read;
! int need_here_doc;
!
} sh_parser_state_t;
*** ../bash-4.3-patched/parse.y 2014-05-14 09:16:40.0 -0400
--- parse.y 2014-04-30 09:27:59.0 -0400
***
*** 2643,2647
r = 0;
! while (need_here_doc)
{
parser_state |= PST_HEREDOC;
--- 2643,2647
r = 0;
! while (need_here_doc > 0)
{
parser_state |= PST_HEREDOC;
***
*** 6076,6079
--- 6076,6080
ps->expand_aliases = expand_aliases;
ps->echo_input_at_read = echo_input_at_read;
+ ps->need_here_doc = need_here_doc;
ps->token = token;
***
*** 6124,6127
--- 6125,6129
expand_aliases = ps->expand_aliases;
echo_input_at_read = ps->echo_input_at_read;
+ need_here_doc = ps->need_here_doc;
FREE (token);