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