Port-vax archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Deadlock risk in putenv
Compiling python for vax I ran into an interesting failure that I
think may represent a real bug in NetBSD's libc on 6.1.5. The tzset
configure test never finishes.
When I connive to run the configure test with -g and attach with gdb I
get a stack trace like this which looks like it's deadlocked because
of a recursive call to getenv inside putenv.
When I run the same conftest manually it doesn't deadlock though -- my
suspicion is that it's sensitive to the exact number and size of the
environment variables and it happen that under pkgsrc's build it
triggers the malloc call which triggers the recursive getenv and the
deadlock.
Does anyone recall any known bugs fixed in libc since 6.1.5 that look
like this? It's a bit difficult to claim it's a real bug because there
are so many weird effects caused by the gcc bugs but this persists
even with -O0 which doesn't seem to be the case for any of the gcc
issues. I've attached the conftest but as I mentioned, it doesn't
reproduce when I run it by hand in my shell directly, only under
pkgsrc.
#0 0x7f78609d in ?? (2138447852, 0)
from /usr/lib/libpthread.so.1
#1 0x7f7861fc in pthread_rwlock_rdlock
(2138447852)
from /usr/lib/libpthread.so.1
#2 0x7f73d242 in __readlockenv ()
from /usr/lib/libc.so.12
#3 0x7f73d16c in getenv (2138333487)
from /usr/lib/libc.so.12
#4 0x7f707c3a in ?? ()
from /usr/lib/libc.so.12
#5 0x7f708f56 in malloc (512)
from /usr/lib/libc.so.12
#6 0x7f73d489 in __getenvslot (67797, 2, 1)
from /usr/lib/libc.so.12
#7 0x7f6bd804 in __putenv50 (67797)
from /usr/lib/libc.so.12
#8 0x00010767 in main
(1, 2147475448, 2147475456)
at conftest.c:304
--
greg
/* confdefs.h */
#define _GNU_SOURCE 1
#define _NETBSD_SOURCE 1
#define __BSD_VISIBLE 1
#define _BSD_TYPES 1
#define _DARWIN_C_SOURCE 1
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE_EXTENDED 1
#define _POSIX_C_SOURCE 200112L
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define __EXTENSIONS__ 1
#define _ALL_SOURCE 1
#define _GNU_SOURCE 1
#define _POSIX_PTHREAD_SEMANTICS 1
#define _TANDEM_SOURCE 1
#define Py_ENABLE_SHARED 1
#define STDC_HEADERS 1
#define HAVE_DLFCN_H 1
#define HAVE_ERRNO_H 1
#define HAVE_FCNTL_H 1
#define HAVE_GRP_H 1
#define HAVE_LANGINFO_H 1
#define HAVE_LIBINTL_H 1
#define HAVE_POLL_H 1
#define HAVE_PTHREAD_H 1
#define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
#define HAVE_TERMIOS_H 1
#define HAVE_UNISTD_H 1
#define HAVE_UTIME_H 1
#define HAVE_SYS_AUDIOIO_H 1
#define HAVE_SYS_EVENT_H 1
#define HAVE_SYS_FILE_H 1
#define HAVE_SYS_LOCK_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_SYS_POLL_H 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_STATVFS_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TIMES_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_UN_H 1
#define HAVE_SYS_UTSNAME_H 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_SYS_RESOURCE_H 1
#define HAVE_SYSEXITS_H 1
#define HAVE_BLUETOOTH_H 1
#define HAVE_SPAWN_H 1
#define HAVE_UTIL_H 1
#define HAVE_DIRENT_H 1
#define HAVE_MAKEDEV 1
#define _LARGEFILE_SOURCE 1
#define _FILE_OFFSET_BITS 64
#if defined(SCO_DS)
#undef _OFF_T
#endif
#define RETSIGTYPE void
#define HAVE_UINT32_T 1
#define HAVE_UINT64_T 1
#define HAVE_INT32_T 1
#define HAVE_INT64_T 1
#define HAVE_SSIZE_T 1
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
#define SIZEOF_VOID_P 4
#define SIZEOF_SHORT 2
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8
#define SIZEOF_FPOS_T 264
#define SIZEOF_SIZE_T 4
#define SIZEOF_PID_T 4
#define HAVE_LONG_LONG 1
#define SIZEOF_LONG_LONG 8
#define HAVE_LONG_DOUBLE 1
#define SIZEOF_LONG_DOUBLE 8
#define HAVE_C99_BOOL 1
#define SIZEOF__BOOL 1
#define HAVE_UINTPTR_T 1
#define SIZEOF_UINTPTR_T 4
#define SIZEOF_OFF_T 8
#define HAVE_LARGEFILE_SUPPORT 1
#define SIZEOF_TIME_T 8
#define SIZEOF_PTHREAD_T 4
#define SHLIB_EXT ".so"
#define HAVE_RAND_EGD 1
#define WITH_LIBINTL 1
#define WITH_THREAD 1
#define _REENTRANT 1
#define PTHREAD_SYSTEM_SCHED_SUPPORTED 1
#define HAVE_PTHREAD_SIGMASK 1
#define HAVE_PTHREAD_ATFORK 1
#define ENABLE_IPV6 1
#define WITH_DOC_STRINGS 1
#define WITH_PYMALLOC 1
#define HAVE_DLOPEN 1
#define HAVE_DYNAMIC_LOADING 1
#define HAVE_ALARM 1
#define HAVE_SETITIMER 1
#define HAVE_GETITIMER 1
#define HAVE_BIND_TEXTDOMAIN_CODESET 1
#define HAVE_CHOWN 1
#define HAVE_CLOCK 1
#define HAVE_CONFSTR 1
#define HAVE_CTERMID 1
#define HAVE_EXECV 1
#define HAVE_FCHMOD 1
#define HAVE_FCHOWN 1
#define HAVE_FORK 1
#define HAVE_FPATHCONF 1
#define HAVE_FTRUNCATE 1
#define HAVE_GAI_STRERROR 1
#define HAVE_GETGROUPS 1
#define HAVE_GETLOGIN 1
#define HAVE_GETLOADAVG 1
#define HAVE_GETPEERNAME 1
#define HAVE_GETPGID 1
#define HAVE_GETPID 1
#define HAVE_GETPRIORITY 1
#define HAVE_GETPWENT 1
#define HAVE_GETSID 1
#define HAVE_GETWD 1
#define HAVE_INITGROUPS 1
#define HAVE_KILL 1
#define HAVE_KILLPG 1
#define HAVE_LCHMOD 1
#define HAVE_LCHOWN 1
#define HAVE_LSTAT 1
#define HAVE_MKFIFO 1
#define HAVE_MKNOD 1
#define HAVE_MKTIME 1
#define HAVE_MMAP 1
#define HAVE_MREMAP 1
#define HAVE_NICE 1
#define HAVE_PATHCONF 1
#define HAVE_PAUSE 1
#define HAVE_POLL 1
#define HAVE_PUTENV 1
#define HAVE_READLINK 1
#define HAVE_REALPATH 1
#define HAVE_SELECT 1
#define HAVE_SEM_OPEN 1
#define HAVE_SEM_GETVALUE 1
#define HAVE_SEM_UNLINK 1
#define HAVE_SETEGID 1
#define HAVE_SETEUID 1
#define HAVE_SETGID 1
#define HAVE_SETLOCALE 1
#define HAVE_SETREGID 1
#define HAVE_SETREUID 1
#define HAVE_SETSID 1
#define HAVE_SETPGID 1
#define HAVE_SETPGRP 1
#define HAVE_SETUID 1
#define HAVE_SETVBUF 1
#define HAVE_SNPRINTF 1
#define HAVE_SETLOCALE 1
#define HAVE_SETREGID 1
#define HAVE_SETREUID 1
#define HAVE_SETSID 1
#define HAVE_SETPGID 1
#define HAVE_SETPGRP 1
#define HAVE_SETUID 1
#define HAVE_SETVBUF 1
#define HAVE_SNPRINTF 1
#define HAVE_SIGACTION 1
#define HAVE_SIGINTERRUPT 1
#define HAVE_SIGRELSE 1
#define HAVE_STRFTIME 1
#define HAVE_SYSCONF 1
#define HAVE_TCGETPGRP 1
#define HAVE_TCSETPGRP 1
#define HAVE_TEMPNAM 1
#define HAVE_TIMEGM 1
#define HAVE_TIMES 1
#define HAVE_TMPFILE 1
#define HAVE_TMPNAM 1
#define HAVE_TRUNCATE 1
#define HAVE_UNAME 1
#define HAVE_UNSETENV 1
#define HAVE_UTIMES 1
#define HAVE_WAITPID 1
#define HAVE_WAIT3 1
#define HAVE_WAIT4 1
#define HAVE_WCSCOLL 1
#define HAVE_CHROOT 1
#define HAVE_LINK 1
#define HAVE_SYMLINK 1
#define HAVE_FCHDIR 1
#define HAVE_FSYNC 1
#define HAVE_FDATASYNC 1
#define HAVE_KQUEUE 1
#define HAVE_FLOCK 1
#define HAVE_GETPAGESIZE 1
#define HAVE_ZLIB_COPY 1
#define HAVE_HSTRERROR 1
#define HAVE_INET_ATON 1
#define HAVE_INET_PTON 1
#define HAVE_SETGROUPS 1
#define HAVE_OPENPTY 1
#define HAVE_FORKPTY 1
#define HAVE_MEMMOVE 1
#define HAVE_FSEEKO 1
#define HAVE_FSTATVFS 1
#define HAVE_FTELLO 1
#define HAVE_STATVFS 1
#define HAVE_DUP2 1
#define HAVE_GETCWD 1
#define HAVE_STRDUP 1
#define HAVE_GETPGRP 1
#define HAVE_SETPGRP 1
#define SETPGRP_HAVE_ARG 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_DEVICE_MACROS 1
#define HAVE_GETADDRINFO 1
#define HAVE_GETNAMEINFO 1
#define TIME_WITH_SYS_TIME 1
#define HAVE_STRUCT_TM_TM_ZONE 1
#define HAVE_TM_ZONE 1
#define HAVE_STRUCT_STAT_ST_RDEV 1
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
#define HAVE_STRUCT_STAT_ST_FLAGS 1
#define HAVE_STRUCT_STAT_ST_GEN 1
#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
#define HAVE_STRUCT_STAT_ST_BLOCKS 1
#define HAVE_ST_BLOCKS 1
#define SYS_SELECT_WITH_SYS_TIME 1
#define HAVE_ADDRINFO 1
#define HAVE_SOCKADDR_STORAGE 1
#define HAVE_PROTOTYPES 1
#define HAVE_STDARG_PROTOTYPES 1
#define HAVE_SOCKETPAIR 1
#define HAVE_SOCKADDR_SA_LEN 1
#define HAVE_GETHOSTBYNAME 1
#define TANH_PRESERVES_ZERO_SIGN 1
#define HAVE_ACOSH 1
#define HAVE_ASINH 1
#define HAVE_ATANH 1
#define HAVE_COPYSIGN 1
#define HAVE_ERF 1
#define HAVE_ERFC 1
#define HAVE_EXPM1 1
#define HAVE_FINITE 1
#define HAVE_GAMMA 1
#define HAVE_HYPOT 1
#define HAVE_LGAMMA 1
#define HAVE_LOG1P 1
#define HAVE_ROUND 1
#define HAVE_DECL_ISINF 1
#define HAVE_DECL_ISNAN 1
#define HAVE_DECL_ISFINITE 1
#define HAVE_WCHAR_H 1
#define SIZEOF_WCHAR_T 4
#define Py_UNICODE_SIZE 2
#define Py_USING_UNICODE 1
#define PY_UNICODE_TYPE unsigned short
#define HAVE_GETC_UNLOCKED 1
#define HAVE_LIBREADLINE 1
#define HAVE_RL_CALLBACK 1
#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1
#define HAVE_RL_COMPLETION_SUPPRESS_APPEND 1
#define HAVE_RL_PRE_INPUT_HOOK 1
#define HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK 1
#define HAVE_RL_COMPLETION_MATCHES 1
#define HAVE_RL_CATCH_SIGNAL 1
#define HAVE_STRUCT_TM_TM_ZONE 1
#define HAVE_TM_ZONE 1
/* end confdefs.h. */
#include <stdlib.h>
#include <time.h>
#include <string.h>
#if HAVE_TZNAME
extern char *tzname[];
#endif
int main()
{
/* Note that we need to ensure that not only does tzset(3)
do 'something' with localtime, but it works as documented
in the library reference and as expected by the test suite.
This includes making sure that tzname is set properly if
tm->tm_zone does not exist since it is the alternative way
of getting timezone info.
Red Hat 6.2 doesn't understand the southern hemisphere
after New Year's Day.
*/
time_t groundhogday = 1044144000; /* GMT-based */
time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
putenv("TZ=UTC+0");
tzset();
if (localtime(&groundhogday)->tm_hour != 0)
exit(1);
#if HAVE_TZNAME
/* For UTC, tzname[1] is sometimes "", sometimes " " */
if (strcmp(tzname[0], "UTC") ||
(tzname[1][0] != 0 && tzname[1][0] != ' '))
exit(1);
#endif
putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
tzset();
if (localtime(&groundhogday)->tm_hour != 19)
exit(1);
#if HAVE_TZNAME
if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
exit(1);
#endif
putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
tzset();
if (localtime(&groundhogday)->tm_hour != 11)
exit(1);
#if HAVE_TZNAME
if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
exit(1);
#endif
#if HAVE_STRUCT_TM_TM_ZONE
if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
exit(1);
if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
exit(1);
#endif
exit(0);
}
Home |
Main Index |
Thread Index |
Old Index