GNU bug report logs - #19874
25.0.50; encode-time not working as expected

Previous Next

Package: emacs;

Reported by: ashish.is <at> lostca.se (Ashish SHUKLA)

Date: Sun, 15 Feb 2015 13:42:01 UTC

Severity: normal

Found in version 25.0.50

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: ashish.is <at> lostca.se (Ashish SHUKLA)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: Wolfgang Jenkner <wjenkner <at> inode.at>, 19874 <at> debbugs.gnu.org
Subject: bug#19874: 25.0.50; encode-time not working as expected
Date: Fri, 27 Feb 2015 13:58:10 +0530
[Message part 1 (text/plain, inline)]
On Thu, 26 Feb 2015 22:38:31 -0800, Paul Eggert <eggert <at> cs.ucla.edu> said:
| Ashish SHUKLA wrote:
|| So, looks like you're right it only happens with X11 (Gtk3) build

| Possibly the Gtk3 code calls 'setenv', and this collides with Emacs's
| implementation of putenv.

| Emacs's putenv implementation should be portable to any POSIX
| platform, but FreeBSD 10.1 getenv+setenv has a bug.  The attached
| program should work on any POSIX platform, and it does work on
| GNU/Linux and on Solaris, but it doesn't work on FreeBSD 10.1.  Emacs
| has similar code, which apparently also runs afoul of the FreeBSD bug.

In FreeBSD, every call to setenv() results in a rebuilding of "internal
environment" with strdup-ed copies of existing strings in "environ"[1], and
getenv only refers to "environ" iff environ is different than what "internal
environment" points to.

If your test program is modified a bit:

--8<---------------cut here---------------start------------->8---
#include <stdio.h>
#include <stdlib.h>
extern char **environ;
char env1[] = "abc=def";
char *small_environ[] = { env1, 0 };
int
main (void)
{
  int i = 0;
  environ = small_environ;
  for( i = 0; NULL != environ[i]; i++ )
    printf( "environment[%d]: %p\n", i, environ[i] );
  if (setenv ("mno", "pqr", 0) != 0)
    return perror ("setenv"), 1;
  for( i = 0; NULL != environ[i]; i++ )
    printf( "environment[%d]: %p\n", i, environ[i] );
  environ[1][0] = 'x';
  if (! getenv ("xbc")) {
        printf("environ: %p\nsmall_environ: %p\n", environ, small_environ );
    return fprintf (stderr, "getenv failed\n"), 1;
  }
  return 0;
}
--8<---------------cut here---------------end--------------->8---

then it doesn't fail:

--8<---------------cut here---------------start------------->8---
% /tmp/putenv-test           
environment[0]: 0x600de0
environment[0]: 0x801008060
environment[1]: 0x801008058
--8<---------------cut here---------------end--------------->8---

which is definitely incompatible with GNU Emacs, and thus breaks its
expectations.

References:
[1]  http://svnweb.freebsd.org/base/releng/10.1/lib/libc/stdlib/getenv.c?revision=272461&view=markup#l349

HTH
-- 
Ashish SHUKLA

“echo pkill cat >curiosity ; chmod +x !$; ./curiosity” (abbe, 2010)

Sent from my Emacs
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 5 years and 118 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.