unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: ashish.is@lostca.se (Ashish SHUKLA)
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Wolfgang Jenkner <wjenkner@inode.at>, 19874@debbugs.gnu.org
Subject: bug#19874: 25.0.50; encode-time not working as expected
Date: Fri, 27 Feb 2015 13:58:10 +0530	[thread overview]
Message-ID: <86twy77o85.fsf@chateau.d.if> (raw)
In-Reply-To: <86vbj35m3n.fsf@chateau.d.if>

[-- Attachment #1: Type: text/plain, Size: 2324 bytes --]

On Thu, 26 Feb 2015 22:38:31 -0800, Paul Eggert <eggert@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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

  parent reply	other threads:[~2015-02-27  8:28 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-15 13:40 bug#19874: 25.0.50; encode-time not working as expected Ashish SHUKLA
2015-02-15 23:33 ` Ashish SHUKLA
2015-02-25 17:41 ` Paul Eggert
2015-02-26  0:24   ` Ashish SHUKLA
2015-02-26  8:15     ` Paul Eggert
2015-02-26 13:42       ` Wolfgang Jenkner
2015-02-26 17:36         ` Wolfgang Jenkner
2015-02-26 17:58         ` Paul Eggert
2015-02-26 16:03       ` Ashish SHUKLA
2015-02-26  6:51   ` Ashish SHUKLA
2015-02-26  8:39     ` Paul Eggert
2015-02-26 15:58       ` Ashish SHUKLA
2015-02-27  5:13         ` Paul Eggert
2015-02-26 19:00 ` Wolfgang Jenkner
2015-02-26 19:44   ` Ashish SHUKLA
2015-02-26 20:05     ` Wolfgang Jenkner
2015-02-26 21:47       ` Ashish SHUKLA
2015-02-27  0:16         ` Wolfgang Jenkner
2015-02-27  2:51         ` Wolfgang Jenkner
2015-02-27  4:59           ` Ashish SHUKLA
2015-02-27  6:38             ` Paul Eggert
2015-02-27  8:09             ` Paul Eggert
2015-02-27  8:49               ` Ashish SHUKLA
2015-02-27  6:31   ` Paul Eggert
2015-02-27  8:28 ` Ashish SHUKLA [this message]
2015-02-27 16:41   ` Paul Eggert
2015-02-27 17:33 ` Wolfgang Jenkner
2015-02-27 23:54   ` Paul Eggert
2015-02-28 14:10     ` Wolfgang Jenkner
2015-02-28 14:18       ` Wolfgang Jenkner
2015-02-28 19:43       ` Paul Eggert
2015-03-01 16:42 ` Wolfgang Jenkner
2015-03-01 18:28   ` Paul Eggert
2015-03-01 22:49 ` Wolfgang Jenkner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86twy77o85.fsf@chateau.d.if \
    --to=ashish.is@lostca.se \
    --cc=19874@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=wjenkner@inode.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).