* $HOME not set and zsh crashing in emulation mode
@ 2016-10-27 17:51 Paulo César Pereira de Andrade
2016-10-27 20:27 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Paulo César Pereira de Andrade @ 2016-10-27 17:51 UTC (permalink / raw)
To: zsh-users
A simple reproducer:
"""
$ cat t.sh
#!/bin/sh
echo $HOME
$ ln -sf /bin/zsh ksh
$ ./ksh -n t.sh
Segmentation fault (core dumped)
"""
This probably is not correct, but a possible patch is:
---8<---
--- zsh-5.0.2/Src/init.c.orig 2016-10-27 15:36:29.210875166 -0200
+++ zsh-5.0.2/Src/init.c 2016-10-27 15:36:33.581867451 -0200
@@ -963,7 +963,7 @@ setupvals(void)
if (EMULATION(EMULATE_ZSH))
ptr = home;
else
- ptr = zgetenv("HOME");
+ ptr = home = zgetenv("HOME");
if (ptr && ispwd(ptr))
pwd = ztrdup(ptr);
else if ((ptr = zgetenv("PWD")) && (strlen(ptr) < PATH_MAX) &&
---8<---
The problem happens because when importing the
environment, setstrvalue will return too early with -n,
but will always set HOME if not in emulation mode:
mod_export void
setstrvalue(Value v, char *val)
{
if (unset(EXECOPT))
return;
From gdb:
(gdb) b setstrvalue
(gdb) cond 1 (strcmp(val, "/home/pcpa") == 0)
Breakpoint 1, setstrvalue (val=0x6e0b00 "/home/pcpa",
v=0x7fffffffd950) at params.c:2267
2267 if (unset(EXECOPT))
(gdb) bt
#0 setstrvalue (val=0x6e0b00 "/home/pcpa", v=0x7fffffffd950) at params.c:2267
#1 assignsparam (s=0x7ffff7ff5cc4 "", s@entry=0x7ffff7ff5cc0 "HOME",
val=0x6e0b00 "/home/pcpa", flags=<optimized out>, flags@entry=0)
at params.c:2738
#2 0x00000000004712fe in createparamtable () at params.c:737
#3 0x000000000044823f in setupvals () at init.c:988
#4 0x000000000044a1ac in zsh_main (argc=<optimized out>,
argv=<optimized out>) at init.c:1596
#5 0x000000000040e3f0 in main (argc=3, argv=0x7fffffffde78) at ./main.c:93
Thanks,
Paulo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: $HOME not set and zsh crashing in emulation mode
2016-10-27 17:51 $HOME not set and zsh crashing in emulation mode Paulo César Pereira de Andrade
@ 2016-10-27 20:27 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2016-10-27 20:27 UTC (permalink / raw)
To: zsh-users
This was fixed by workers/36780 about a year ago.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: $HOME not set and zsh crashing in emulation mode
2016-10-27 20:19 ` Daniel Shahaf
@ 2016-10-28 12:04 ` Paulo César Pereira de Andrade
0 siblings, 0 replies; 4+ messages in thread
From: Paulo César Pereira de Andrade @ 2016-10-28 12:04 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: zsh-users
2016-10-27 18:19 GMT-02:00 Daniel Shahaf <d.s@daniel.shahaf.name>:
>> """
>> $ cat t.sh
>> #!/bin/sh
>> echo $HOME
>>
>> $ ln -sf /bin/zsh ksh
>>
>> $ ./ksh -n t.sh
>> Segmentation fault (core dumped)
>> """
>
> You're using 5.0.2, which is four years old. We've fixed this bug in
> 5.2 last year:
>
> commit 83a175795a444e8169fcb592a110d4d15a09b907
> Author: Peter Stephenson <pws@zsh.org>
> Date: Tue Oct 6 09:28:07 2015 +0100
>
> 36780: Fix crash in ksh mode with -n and $HOME.
>
> If home variable is NULL ensure HOME is unset.
>
> Current master does not have the problem:
>
> % ARGV0=ksh Src/zsh -fn =(<<<$'#!/bin/sh\necho $HOME\n')
> %
>
> Thanks for the bug report and the patch.
Sorry for not checking latest sources before reporting
upstream. Will do so next time :)
I updated the bug report with the patch at
https://bugzilla.redhat.com/show_bug.cgi?id=1389492
> Cheers,
>
> Daniel
Thanks,
Paulo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: $HOME not set and zsh crashing in emulation mode
[not found] <CAHAq8pEPk41cxWdqyBLawsbadAt+JUBnv59nZbNLkte8nfX0iw__31688.0478793339$1477597412$gmane$org@mail.gmail.com>
@ 2016-10-27 20:19 ` Daniel Shahaf
2016-10-28 12:04 ` Paulo César Pereira de Andrade
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Shahaf @ 2016-10-27 20:19 UTC (permalink / raw)
To: Paulo César Pereira de Andrade; +Cc: zsh-users
Paulo César Pereira de Andrade wrote on Thu, Oct 27, 2016 at 15:51:43 -0200:
> A simple reproducer:
>
> """
> $ cat t.sh
> #!/bin/sh
> echo $HOME
>
> $ ln -sf /bin/zsh ksh
>
> $ ./ksh -n t.sh
> Segmentation fault (core dumped)
> """
You're using 5.0.2, which is four years old. We've fixed this bug in
5.2 last year:
commit 83a175795a444e8169fcb592a110d4d15a09b907
Author: Peter Stephenson <pws@zsh.org>
Date: Tue Oct 6 09:28:07 2015 +0100
36780: Fix crash in ksh mode with -n and $HOME.
If home variable is NULL ensure HOME is unset.
Current master does not have the problem:
% ARGV0=ksh Src/zsh -fn =(<<<$'#!/bin/sh\necho $HOME\n')
%
Thanks for the bug report and the patch.
Cheers,
Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-28 13:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 17:51 $HOME not set and zsh crashing in emulation mode Paulo César Pereira de Andrade
2016-10-27 20:27 ` Bart Schaefer
[not found] <CAHAq8pEPk41cxWdqyBLawsbadAt+JUBnv59nZbNLkte8nfX0iw__31688.0478793339$1477597412$gmane$org@mail.gmail.com>
2016-10-27 20:19 ` Daniel Shahaf
2016-10-28 12:04 ` Paulo César Pereira de Andrade
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).