Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
$HOME not set and zsh crashing in emulation mode
- X-seq: zsh-users 22037
- From: Paulo César Pereira de Andrade <paulo.cesar.pereira.de.andrade@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: $HOME not set and zsh crashing in emulation mode
- Date: Thu, 27 Oct 2016 15:51:43 -0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=MDzLdfjGGwuS5aY/fJCSPx/q+SKAUbWxuhT9ij3/xNw=; b=YT92YUai6NHYnp3qL2kC5ggf+k5lHUT2QBxGSaQ+rWJgA8lQ6rAWuylCO4s73+Iuo+ 0Ril5RbqY7ibD1az2HJlnF/0H9RQ6ffLCJwZsJStozYr3VLejkbhh4BCgPVlRBlTvYz+ FZI5p4eCFQIe1xfe8qB9JZ+33SjwMlgew3URViZNYvl7Se3GUoFfbfI0HeiJEKPep8D3 YvmbyT/NfrB4MB5XyuzPl+vAn5zOuqHC3DfpaCua8o4kC+GLuMgB/fVRjacAGi40Qx8B GKojvieIT2RSLHtIExW+2Sbwc45r2BLzKXYhTNiwVROY/ZNNsSgV2ykin9Y6YtBaMKm/ nq0A==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author