* dash regression against klibc
@ 2008-05-01 17:25 Dan McGee
2008-05-02 5:25 ` Herbert Xu
0 siblings, 1 reply; 12+ messages in thread
From: Dan McGee @ 2008-05-01 17:25 UTC (permalink / raw)
To: herbert, dash
I wanted to let you know of an issue one of our users discovered with
dash compiled against klibc- working directory lookups appear to be an
issue in a clean environment:
http://bugs.archlinux.org/task/10327
What is interesting is it works fine if you just run dash from within
bash- it only fails as seen there if you run using the 'env -'
wrapper.
If you want me to look into this and/or help out with a fix, let me
know. Thanks!
-Dan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-01 17:25 dash regression against klibc Dan McGee
@ 2008-05-02 5:25 ` Herbert Xu
2008-05-02 6:23 ` Herbert Xu
0 siblings, 1 reply; 12+ messages in thread
From: Herbert Xu @ 2008-05-02 5:25 UTC (permalink / raw)
To: Dan McGee; +Cc: dash
On Thu, May 01, 2008 at 12:25:58PM -0500, Dan McGee wrote:
> I wanted to let you know of an issue one of our users discovered with
> dash compiled against klibc- working directory lookups appear to be an
> issue in a clean environment:
> http://bugs.archlinux.org/task/10327
>
> What is interesting is it works fine if you just run dash from within
> bash- it only fails as seen there if you run using the 'env -'
> wrapper.
>
> If you want me to look into this and/or help out with a fix, let me
> know. Thanks!
Could you please run it under ltrace and send us the output?
Something like
env - ltrace /bin/dash -c pwd
should do the trick.
I suspect the problem is klibc's getcwd implementation but this
should confirm it for us.
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-02 5:25 ` Herbert Xu
@ 2008-05-02 6:23 ` Herbert Xu
2008-05-02 7:50 ` Sam Ravnborg
2008-05-03 1:08 ` Dan McGee
0 siblings, 2 replies; 12+ messages in thread
From: Herbert Xu @ 2008-05-02 6:23 UTC (permalink / raw)
To: Dan McGee; +Cc: dash
On Fri, May 02, 2008 at 01:25:30PM +0800, Herbert Xu wrote:
>
> I suspect the problem is klibc's getcwd implementation but this
> should confirm it for us.
Actually klibc's getcwd is just fine as it is. It's dash that's
relying on glibc extensions of getcwd.
This patch sould make it work again.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
commit b306b8c58d10c3fa1a34edc22042e4d9b6185f87
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date: Fri May 2 14:20:44 2008 +0800
[CD] Restored non-glibc getcwd support
These days dash is expected to build with libraries other than
glibc so we need to support the old way of calling getcwd again.
Thanks to Dan McGee for reporting this bug when dash is built with
klibc.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/ChangeLog b/ChangeLog
index f5e0dbc..5216521 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-05-02 Herbert Xu <herbert@gondor.apana.org.au>
+
+ * Restored non-glibc getcwd support.
+
2008-03-07 Larry Doolittle <ldoolitt@recycle.lbl.gov>
* Fix cmdtxt crash on if statements.
diff --git a/src/cd.c b/src/cd.c
index 1849c69..0c2f1ee 100644
--- a/src/cd.c
+++ b/src/cd.c
@@ -241,8 +241,6 @@ updatepwd(const char *dir)
}
-#define MAXPWD 256
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-02 6:23 ` Herbert Xu
@ 2008-05-02 7:50 ` Sam Ravnborg
2008-05-02 9:53 ` Herbert Xu
2008-05-03 1:08 ` Dan McGee
1 sibling, 1 reply; 12+ messages in thread
From: Sam Ravnborg @ 2008-05-02 7:50 UTC (permalink / raw)
To: Herbert Xu; +Cc: Dan McGee, dash
On Fri, May 02, 2008 at 02:23:03PM +0800, Herbert Xu wrote:
> On Fri, May 02, 2008 at 01:25:30PM +0800, Herbert Xu wrote:
> >
> > I suspect the problem is klibc's getcwd implementation but this
> > should confirm it for us.
>
> Actually klibc's getcwd is just fine as it is. It's dash that's
> relying on glibc extensions of getcwd.
>
> This patch sould make it work again.
>
> Cheers,
> --
> Visit Openswan at http://www.openswan.org/
> Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
> --
> commit b306b8c58d10c3fa1a34edc22042e4d9b6185f87
> Author: Herbert Xu <herbert@gondor.apana.org.au>
> Date: Fri May 2 14:20:44 2008 +0800
>
> [CD] Restored non-glibc getcwd support
>
> These days dash is expected to build with libraries other than
> glibc so we need to support the old way of calling getcwd again.
>
> Thanks to Dan McGee for reporting this bug when dash is built with
> klibc.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
>
> diff --git a/ChangeLog b/ChangeLog
> index f5e0dbc..5216521 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,7 @@
> +2008-05-02 Herbert Xu <herbert@gondor.apana.org.au>
> +
> + * Restored non-glibc getcwd support.
> +
> 2008-03-07 Larry Doolittle <ldoolitt@recycle.lbl.gov>
>
> * Fix cmdtxt crash on if statements.
> diff --git a/src/cd.c b/src/cd.c
> index 1849c69..0c2f1ee 100644
> --- a/src/cd.c
> +++ b/src/cd.c
> @@ -241,8 +241,6 @@ updatepwd(const char *dir)
> }
>
>
> -#define MAXPWD 256
> -
> /*
> * Find out what the current directory is. If we already know the current
> * directory, this routine returns immediately.
> @@ -251,8 +249,13 @@ inline
> STATIC char *
> getpwd()
> {
> +#ifdef _GNU_SOURCE
> char *dir = getcwd(0, 0);
> return dir ? dir : nullstr;
> +#else
> + char buf[PATH_MAX];
> + return getcwd(buf, sizeof(buf)) ? savestr(buf) : nullstr;
> +#endif
> }
If this patch is correct then we leak memory in the glic extension case.
According to man 3 getcwd the memory is allocated and thus should be freed.
Is there a specific reason why you did not use PATH_MAX always
and dropped the use of the extension?
Sam
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-02 7:50 ` Sam Ravnborg
@ 2008-05-02 9:53 ` Herbert Xu
2008-05-02 10:30 ` Sam Ravnborg
0 siblings, 1 reply; 12+ messages in thread
From: Herbert Xu @ 2008-05-02 9:53 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: Dan McGee, dash
On Fri, May 02, 2008 at 09:50:10AM +0200, Sam Ravnborg wrote:
>
> > @@ -251,8 +249,13 @@ inline
> > STATIC char *
> > getpwd()
> > {
> > +#ifdef _GNU_SOURCE
> > char *dir = getcwd(0, 0);
> > return dir ? dir : nullstr;
> > +#else
> > + char buf[PATH_MAX];
> > + return getcwd(buf, sizeof(buf)) ? savestr(buf) : nullstr;
> > +#endif
> > }
> If this patch is correct then we leak memory in the glic extension case.
> According to man 3 getcwd the memory is allocated and thus should be freed.
If we leaked memory in the glibc case then we'd also leak in the
other one because savestr is dash's version of strdup. But we
don't because the caller is responsible for freeing it.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-02 9:53 ` Herbert Xu
@ 2008-05-02 10:30 ` Sam Ravnborg
0 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2008-05-02 10:30 UTC (permalink / raw)
To: Herbert Xu; +Cc: Dan McGee, dash
On Fri, May 02, 2008 at 05:53:40PM +0800, Herbert Xu wrote:
> On Fri, May 02, 2008 at 09:50:10AM +0200, Sam Ravnborg wrote:
> >
> > > @@ -251,8 +249,13 @@ inline
> > > STATIC char *
> > > getpwd()
> > > {
> > > +#ifdef _GNU_SOURCE
> > > char *dir = getcwd(0, 0);
> > > return dir ? dir : nullstr;
> > > +#else
> > > + char buf[PATH_MAX];
> > > + return getcwd(buf, sizeof(buf)) ? savestr(buf) : nullstr;
> > > +#endif
> > > }
> > If this patch is correct then we leak memory in the glic extension case.
> > According to man 3 getcwd the memory is allocated and thus should be freed.
>
> If we leaked memory in the glibc case then we'd also leak in the
> other one because savestr is dash's version of strdup. But we
> don't because the caller is responsible for freeing it.
OK, thanks for the explanation!
Sam
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-02 6:23 ` Herbert Xu
2008-05-02 7:50 ` Sam Ravnborg
@ 2008-05-03 1:08 ` Dan McGee
2008-05-03 2:21 ` Herbert Xu
1 sibling, 1 reply; 12+ messages in thread
From: Dan McGee @ 2008-05-03 1:08 UTC (permalink / raw)
To: Herbert Xu; +Cc: dash
On Fri, May 2, 2008 at 1:23 AM, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Fri, May 02, 2008 at 01:25:30PM +0800, Herbert Xu wrote:
> >
> > I suspect the problem is klibc's getcwd implementation but this
> > should confirm it for us.
>
> Actually klibc's getcwd is just fine as it is. It's dash that's
> relying on glibc extensions of getcwd.
>
> This patch sould make it work again.
You pushed this patch to git, so I tried to grab the repository and
compile from there. I'll follow this message with a series of patches
to fix some other compilation issues that have cropped up since the
last release of klibc.
Unfortunately this patch didn't work:
$ for f in /bin/bash /bin/sh /usr/lib/klibc/bin/sh /bin/dash
./src/dash; do echo " trying shell $f:"; env - $f -c 'echo $PWD; pwd;
pwd -P; /bin/pwd'; done
trying shell /bin/bash:
/home/dmcgee/projects/dash
/home/dmcgee/projects/dash
/home/dmcgee/projects/dash
/home/dmcgee/projects/dash
trying shell /bin/sh:
/home/dmcgee/projects/dash
/home/dmcgee/projects/dash
/home/dmcgee/projects/dash
/home/dmcgee/projects/dash
trying shell /usr/lib/klibc/bin/sh:
/home/dmcgee/projects/dash
/home/dmcgee/projects/dash
/home/dmcgee/projects/dash
/home/dmcgee/projects/dash
trying shell /bin/dash:
/home/dmcgee/projects/dash
trying shell ./src/dash:
/home/dmcgee/projects/dash
So the post-patch version of dash is acting identical to the prepatch
version. I'm not convinced this is a dash problem- it could very well
be an upstream klibc issue, and I will try to look into this
possibility as well.
-Dan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-03 1:08 ` Dan McGee
@ 2008-05-03 2:21 ` Herbert Xu
2008-05-03 6:06 ` H. Peter Anvin
0 siblings, 1 reply; 12+ messages in thread
From: Herbert Xu @ 2008-05-03 2:21 UTC (permalink / raw)
To: Dan McGee; +Cc: dash
On Fri, May 02, 2008 at 08:08:34PM -0500, Dan McGee wrote:
>
> So the post-patch version of dash is acting identical to the prepatch
> version. I'm not convinced this is a dash problem- it could very well
> be an upstream klibc issue, and I will try to look into this
> possibility as well.
Could you find out exactly what getcwd returned under klibc?
Or perhaps somehow _GNU_SOURCE is still being defined under
klibc?
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-03 2:21 ` Herbert Xu
@ 2008-05-03 6:06 ` H. Peter Anvin
2008-05-03 6:13 ` Herbert Xu
0 siblings, 1 reply; 12+ messages in thread
From: H. Peter Anvin @ 2008-05-03 6:06 UTC (permalink / raw)
To: Herbert Xu; +Cc: Dan McGee, dash
Herbert Xu wrote:
> On Fri, May 02, 2008 at 08:08:34PM -0500, Dan McGee wrote:
>> So the post-patch version of dash is acting identical to the prepatch
>> version. I'm not convinced this is a dash problem- it could very well
>> be an upstream klibc issue, and I will try to look into this
>> possibility as well.
>
> Could you find out exactly what getcwd returned under klibc?
> Or perhaps somehow _GNU_SOURCE is still being defined under
> klibc?
_GNU_SOURCE is defined by the application, not by the library.
-hpa
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-03 6:06 ` H. Peter Anvin
@ 2008-05-03 6:13 ` Herbert Xu
2008-05-03 6:16 ` Dan McGee
0 siblings, 1 reply; 12+ messages in thread
From: Herbert Xu @ 2008-05-03 6:13 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Dan McGee, dash
On Fri, May 02, 2008 at 11:06:23PM -0700, H. Peter Anvin wrote:
>
> _GNU_SOURCE is defined by the application, not by the library.
Yes, however the macro AC_GNU_SOURCE is supposed to define it
only for glibc. Having seen the actual code though it seems
that the automake documentation is misleading and the macro is
always defined regardless of the library being used.
I'll change it to use __GLIBC__ instead.
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-03 6:13 ` Herbert Xu
@ 2008-05-03 6:16 ` Dan McGee
2008-05-03 6:19 ` Herbert Xu
0 siblings, 1 reply; 12+ messages in thread
From: Dan McGee @ 2008-05-03 6:16 UTC (permalink / raw)
To: Herbert Xu; +Cc: H. Peter Anvin, dash
On Sat, May 3, 2008 at 1:13 AM, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Fri, May 02, 2008 at 11:06:23PM -0700, H. Peter Anvin wrote:
> >
> > _GNU_SOURCE is defined by the application, not by the library.
>
> Yes, however the macro AC_GNU_SOURCE is supposed to define it
> only for glibc. Having seen the actual code though it seems
> that the automake documentation is misleading and the macro is
> always defined regardless of the library being used.
>
> I'll change it to use __GLIBC__ instead.
That change makes it work fine here. Thanks for looking into all of this.
I forgot to hit reply to all on the last email I sent to just Herbert,
so I've included that below as well.
-Dan
> Could you find out exactly what getcwd returned under klibc?
> Or perhaps somehow _GNU_SOURCE is still being defined under
> klibc?
OK, here we go:
#include <sys/types.h>
#include <limits.h>
#include <unistd.h>
#include <stdio.h>
main(int argc, char **argv)
{
char buf[PATH_MAX];
char *ptr;
ptr = getcwd(buf, PATH_MAX);
printf("%s", ptr);
}
$ klcc test.c
$ ./a.out
/home/dmcgee/projects/dash
$ env - ./a.out
/home/dmcgee/projects/dash
And yes, as hpa said while I was finishing up this email, _GNU_SOURCE
is still enabled during the compile even with klibc. I can see that it
is defined in config.h even when running with this configure line:
$ ./configure CC=klcc LD=klcc CFLAGS="-D__CTYPE_NO_INLINE"
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: dash regression against klibc
2008-05-03 6:16 ` Dan McGee
@ 2008-05-03 6:19 ` Herbert Xu
0 siblings, 0 replies; 12+ messages in thread
From: Herbert Xu @ 2008-05-03 6:19 UTC (permalink / raw)
To: Dan McGee; +Cc: H. Peter Anvin, dash
On Sat, May 03, 2008 at 01:16:56AM -0500, Dan McGee wrote:
>
> That change makes it work fine here. Thanks for looking into all of this.
OK this is what I've committed.
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
commit d2bb89771175405c308a8a89424eeb82a15aaaee
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date: Sat May 3 14:17:40 2008 +0800
[CD] Test __GLIBC__ instead of _GNU_SOURCE
AC_GNU_SOURCE always defines _GNU_SOURCE so testing it is pointless.
This patch changes it to test __GLIBC__ instead.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/ChangeLog b/ChangeLog
index 1126b04..94b37c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
2008-05-03 Herbert Xu <herbert@gondor.apana.org.au>
* Fixed _PATH_BSHELL warning.
+ * Test __GLIBC__ instead of _GNU_SOURCE.
2008-05-02 Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/src/cd.c b/src/cd.c
index cb6e24d..73ccde0 100644
--- a/src/cd.c
+++ b/src/cd.c
@@ -249,7 +249,7 @@ inline
STATIC char *
getpwd()
{
-#ifdef _GNU_SOURCE
+#ifdef __GLIBC__
char *dir = getcwd(0, 0);
return dir ? dir : nullstr;
#else
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-05-03 6:19 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-01 17:25 dash regression against klibc Dan McGee
2008-05-02 5:25 ` Herbert Xu
2008-05-02 6:23 ` Herbert Xu
2008-05-02 7:50 ` Sam Ravnborg
2008-05-02 9:53 ` Herbert Xu
2008-05-02 10:30 ` Sam Ravnborg
2008-05-03 1:08 ` Dan McGee
2008-05-03 2:21 ` Herbert Xu
2008-05-03 6:06 ` H. Peter Anvin
2008-05-03 6:13 ` Herbert Xu
2008-05-03 6:16 ` Dan McGee
2008-05-03 6:19 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.