Vladimir Marek
2013-12-04 08:34:22 UTC
Hi,
I'm not an ksh developer, so sorry if I got some things wrong.
Recently on Solaris I found out that this command cores:
$ /usr/bin/cd a b
Segmentation Fault (core dumped)
$ pstack core
core 'core' of 10186: /usr/bin/cd a b
000000000047c1a8 sh_substitute () + 30
000000000049d853 b_cd () + 1bb
000000000048bc3b sh_exec () + 34b7
00000000004898e5 sh_exec () + 1161
000000000048a557 sh_exec () + 1dd3
0000000000487b53 sh_eval () + 263
0000000000431142 sh_trap () + 1f2
000000000042f50b main () + 27f
000000000042f12c ???????? ()
After some digging I found out that the cd surprisingly(?) comes from
ksh sources. After a bit of debugging it turns out that this patch seems to fix
the issue:
--- a/src/cmd/ksh93/bltins/cd_pwd.c 2013-10-31 16:18:43.904039613 +0100
+++ b/src/cmd/ksh93/bltins/cd_pwd.c 2013-10-31 16:18:14.980499662 +0100
@@ -81,7 +81,7 @@
dir = argv[0];
if(error_info.errors>0 || argc >2)
errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
- oldpwd = (char*)shp->pwd;
+ oldpwd = path_pwd(shp,0)
opwdnod = (shp->subshell?sh_assignok(OLDPWDNOD,1):OLDPWDNOD);
pwdnod = (shp->subshell?sh_assignok(PWDNOD,1):PWDNOD);
if(argc==2)
The problem was that shp->pwd was 0. Looking around the file it seems
that 'the' way of getting current directory is calling path_pwd and thus
this diff. I wasn't able to find any public repository containing
sources to check whether the issue is fixed already in development
branch or not.
I do have two questions.
a) Is the fix correct?
b) If this issue is not already fixed in your source tree, would you
mind including the fix there?
Thank you
I'm not an ksh developer, so sorry if I got some things wrong.
Recently on Solaris I found out that this command cores:
$ /usr/bin/cd a b
Segmentation Fault (core dumped)
$ pstack core
core 'core' of 10186: /usr/bin/cd a b
000000000047c1a8 sh_substitute () + 30
000000000049d853 b_cd () + 1bb
000000000048bc3b sh_exec () + 34b7
00000000004898e5 sh_exec () + 1161
000000000048a557 sh_exec () + 1dd3
0000000000487b53 sh_eval () + 263
0000000000431142 sh_trap () + 1f2
000000000042f50b main () + 27f
000000000042f12c ???????? ()
After some digging I found out that the cd surprisingly(?) comes from
ksh sources. After a bit of debugging it turns out that this patch seems to fix
the issue:
--- a/src/cmd/ksh93/bltins/cd_pwd.c 2013-10-31 16:18:43.904039613 +0100
+++ b/src/cmd/ksh93/bltins/cd_pwd.c 2013-10-31 16:18:14.980499662 +0100
@@ -81,7 +81,7 @@
dir = argv[0];
if(error_info.errors>0 || argc >2)
errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0));
- oldpwd = (char*)shp->pwd;
+ oldpwd = path_pwd(shp,0)
opwdnod = (shp->subshell?sh_assignok(OLDPWDNOD,1):OLDPWDNOD);
pwdnod = (shp->subshell?sh_assignok(PWDNOD,1):PWDNOD);
if(argc==2)
The problem was that shp->pwd was 0. Looking around the file it seems
that 'the' way of getting current directory is calling path_pwd and thus
this diff. I wasn't able to find any public repository containing
sources to check whether the issue is fixed already in development
branch or not.
I do have two questions.
a) Is the fix correct?
b) If this issue is not already fixed in your source tree, would you
mind including the fix there?
Thank you
--
Vlad
Vlad