[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#175529: regex: re_compile_pattern gets segfault



Package: libc6-dev
Version: 2.3.1-9
Severity: important
Tags: sid

Hi,

An hour or so ago I completed my first update of unstable after the
holidays and found that one of coreutils' configure-time run-tests of
regex is now failing.  This results in ./configure determining (rightly
so) that libc's regex.o code is unusable, and so the package (coreutils
in this case) ends up compiling and linking against its own version
of regex.c.  When I compile the sample script, below, with regex.c,
it works fine.  When linking it against libc, it segfaults.

This is certainly obvious to all of you, but ...
If the losing use of re_compile_pattern is not yet part of a test
case for glibc, I humbly suggest that you add it.

Regards,
Jim


-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux pi 2.4.19-xfs #1 SMP Son Okt 6 20:14:17 CEST 2002 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages libc6-dev depends on:
ii  libc6                         2.3.1-9    GNU C Library: Shared libraries an

-- no debconf information

This demonstrates the failure:

  pi$ gcc -g re-test.c
  pi$ gdb a.out
  (gdb) r
  Starting program: /tmp/a.out

  Program received signal SIGSEGV, Segmentation fault.
  0x4008f9bb in memset () from /lib/libc.so.6
  (gdb) bt
  #0  0x4008f9bb in memset () from /lib/libc.so.6
  #1  0x400c4d4b in re_comp () from /lib/libc.so.6
  #2  0x400c4c69 in re_comp () from /lib/libc.so.6
  #3  0x400c432c in re_compile_pattern () from /lib/libc.so.6
  #4  0x0804845d in main () at re-test.c:330
  (gdb)

And this shows that it works fine when using the regex.c
from coreutils-4.5.4.

  pi$ gcc -g re-test.c ~/work/fetish/cu/lib/regex.c
  pi$ ./a.out
  pi$

  pi$ cat re-test.c
#define PACKAGE_NAME "GNU coreutils"
#define PACKAGE_TARNAME "coreutils"
#define PACKAGE_VERSION "4.5.5"
#define PACKAGE_STRING "GNU coreutils 4.5.5"
#define PACKAGE_BUGREPORT "bug-coreutils@gnu.org"
#define PACKAGE "coreutils"
#define VERSION "4.5.5"
#define _GNU_SOURCE 1
#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 HAVE_UNAME 1
#define HAVE_CHROOT 1
#define HAVE_GETHOSTID 1
#define _FILE_OFFSET_BITS 64
#define PROTOTYPES 1
#define STDC_HEADERS 1
#define HAVE_STRING_H 1
#define HAVE_LONG_DOUBLE 1
#define HAVE_ERRNO_H 1
#define HAVE_FCNTL_H 1
#define HAVE_FLOAT_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MEMORY_H 1
#define HAVE_MNTENT_H 1
#define HAVE_NETDB_H 1
#define HAVE_PATHS_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_MOUNT_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_SYS_RESOURCE_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_STATFS_H 1
#define HAVE_SYS_STATVFS_H 1
#define HAVE_SYS_SYSCTL_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TIMEB_H 1
#define HAVE_SYS_VFS_H 1
#define HAVE_SYS_WAIT_H 1
#define HAVE_SYSLOG_H 1
#define HAVE_TERMIOS_H 1
#define HAVE_UNISTD_H 1
#define HAVE_UTIME_H 1
#define HAVE_VALUES_H 1
#define HAVE_DIRENT_H 1
#define HAVE_STRUCT_STAT_ST_BLOCKS 1
#define HAVE_ST_BLOCKS 1
#define HAVE_STRUCT_TM_TM_ZONE 1
#define HAVE_TM_ZONE 1
#define TIME_WITH_SYS_TIME 1
#define HAVE_STRUCT_TIMESPEC 1
#define GETGROUPS_T gid_t
#define RETSIGTYPE void
#define HAVE_UNSIGNED_LONG_LONG 1
#define HOST_OPERATING_SYSTEM "GNU/Linux"
#define HAVE_UTIME_H 1
#define HAVE_STRUCT_UTIMBUF 1
#define HAVE_STRUCT_DIRENT_D_TYPE 1
#define D_INO_IN_DIRENT 1
#define HAVE_GRP_H 1
#define HAVE_MEMORY_H 1
#define HAVE_PWD_H 1
#define HAVE_STRING_H 1
#define HAVE_STRINGS_H 1
#define HAVE_STDLIB_H 1
#define HAVE_UNISTD_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_UTMP_H 1
#define HAVE_UTMPX_H 1
#define HAVE_DECL_FREE 1
#define HAVE_DECL_GETENV 1
#define HAVE_DECL_GETEUID 1
#define HAVE_DECL_GETGRGID 1
#define HAVE_DECL_GETLOGIN 1
#define HAVE_DECL_GETPWUID 1
#define HAVE_DECL_GETUID 1
#define HAVE_DECL_GETUTENT 1
#define HAVE_DECL_LSEEK 1
#define HAVE_DECL_MALLOC 1
#define HAVE_DECL_MEMCHR 1
#define HAVE_DECL_MEMRCHR 1
#define HAVE_DECL_NANOSLEEP 1
#define HAVE_DECL_REALLOC 1
#define HAVE_DECL_STPCPY 1
#define HAVE_DECL_STRNDUP 1
#define HAVE_DECL_STRNLEN 1
#define HAVE_DECL_STRSTR 1
#define HAVE_DECL_STRTOUL 1
#define HAVE_DECL_STRTOULL 1
#define HAVE_DECL_TTYNAME 1
#define HAVE_LONG_FILE_NAMES 1
#define HAVE_PATHCONF 1
#define HAVE_LIMITS_H 1
#define HAVE_STRING_H 1
#define HAVE_UNISTD_H 1
#define HAVE_ALLOCA_H 1
#define HAVE_ALLOCA 1
#define HAVE_GETCONTEXT 1
#define HAVE_SIGALTSTACK 1
#define HAVE_DECL_GETCONTEXT 1
#define HAVE_DECL_SIGALTSTACK 1
#define HAVE_SYS_RESOURCE_H 1
#define HAVE_UCONTEXT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_STACK_T 1
#define HAVE_GETHOSTBYNAME 1
#define HAVE_GETHOSTBYADDR 1
#define HAVE_INET_NTOA 1
#define HAVE_UNISTD_H 1
#define HAVE_STRING_H 1
#define HAVE_NETDB_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_ARPA_INET_H 1
#define HAVE_STRING_H 1
#define HAVE_STRERROR 1
#define HAVE_VPRINTF 1
#define HAVE_DECL_STRERROR 1
#define HAVE_LIBINTL_H 1
#define HAVE_DECL_STRERROR_R 1
#define HAVE_STRERROR_R 1
#define STRERROR_R_CHAR_P 1
#define STDC_HEADERS 1
#define HAVE_MBSTATE_T 1
#define HAVE_STDBOOL_H 1
#define HAVE_GETPAGESIZE 1
#define HAVE_UNISTD_H 1
#define HAVE_LOCALE_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_SETLOCALE 1
#define HAVE_STDLIB_H 1
#define HAVE_LOCALE_H 1
#define HAVE_DECL_GETENV 1
#define HAVE_LOCALECONV 1
#define HAVE_LIMITS_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_WCHAR_H 1
#define HAVE_WCTYPE_H 1
#define HAVE_ISASCII 1
#define HAVE_ISWCNTRL 1
#define HAVE_ISWPRINT 1
#define HAVE_MBSINIT 1
#define HAVE_WCWIDTH 1
#define HAVE_MBRTOWC 1
#define HAVE_DECL_WCWIDTH 1
#define HAVE_MBSTATE_T 1
#define HAVE_LIMITS_H 1
#define HAVE_STDLIB_H 1
#define HAVE_UNISTD_H 1
#define HAVE_UNISTD_H 1
#define HAVE_DECL_GETENV 1
#define HAVE_C_BACKSLASH_A 1
#define HAVE_ISASCII 1
#define HAVE_ISWPRINT 1
#define HAVE_LIMITS_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_WCHAR_H 1
#define HAVE_WCTYPE_H 1
#define HAVE_STRING_H 1
#define HAVE_UTMP_H 1
#define HAVE_UTMPX_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_UTMPNAME 1
#define HAVE_UTMPXNAME 1
#define HAVE_STRUCT_UTMPX_UT_USER 1
#define HAVE_STRUCT_UTMP_UT_USER 1
#define HAVE_STRUCT_UTMPX_UT_NAME 1
#define HAVE_STRUCT_UTMP_UT_NAME 1
#define HAVE_STRUCT_UTMPX_UT_TYPE 1
#define HAVE_STRUCT_UTMP_UT_TYPE 1
#define HAVE_STRUCT_UTMPX_UT_PID 1
#define HAVE_STRUCT_UTMP_UT_PID 1
#define HAVE_STRUCT_UTMPX_UT_ID 1
#define HAVE_STRUCT_UTMP_UT_ID 1
#define HAVE_STRUCT_UTMPX_UT_EXIT_E_EXIT 1
#define HAVE_STRUCT_UTMP_UT_EXIT_E_EXIT 1
#define HAVE_STRUCT_UTMPX_UT_EXIT_E_TERMINATION 1
#define HAVE_STRUCT_UTMP_UT_EXIT_E_TERMINATION 1
#define HAVE_BZERO 1
#define HAVE_BCOPY 1
#define HAVE_ISASCII 1
#define HAVE_BTOWC 1
#define HAVE_ALLOCA_H 1
#define HAVE_LIBINTL_H 1
#define HAVE_WCTYPE_H 1
#define HAVE_WCHAR_H 1
#define HAVE_LONG_LONG 1
#define HAVE_SYS_SYSMACROS_H 1
#define HAVE_SYS_STATVFS_H 1
#define HAVE_SYS_VFS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_SYS_MOUNT_H 1
#define HAVE_STATVFS 1
#define HAVE_STRUCT_STATFS_F_TYPE 1
#define HAVE_STRUCT_STATFS_F_FSID___VAL 1
#define HAVE_STRUCT_STATVFS_F_NAMEMAX 1
#define HAVE_STRUCT_STATFS_F_NAMELEN 1
#define HAVE_MEMORY_H 1
#define HAVE_DECL_MEMCHR 1
#define HAVE_FCNTL_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define HAVE___SECURE_GETENV 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_DECL_GETENV 1
#define PROTOTYPES 1
#define __PROTOTYPES 1
#define HAVE_STDLIB_H 1
#define HAVE_UNISTD_H 1
#define HAVE_GETCWD_NULL 1
#define HAVE_LIMITS_H 1
#define HAVE_STDLIB_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_UNISTD_H 1
#define HAVE_GETCWD 1
#define HAVE_LIMITS_H 1
#define HAVE_STDLIB_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_UNISTD_H 1
#define HAVE_DIRENT_H 1
#define HAVE_DIRFD 1
#define HAVE_DECL_DIRFD 1
#define HAVE_LCHOWN 1
#define RMDIR_ERRNO_NOT_EMPTY 39
#define HAVE_SYS_TIME_H 1
#define HAVE_UNISTD_H 1
#define HAVE_ALARM 1
#define HAVE_LOCALTIME_R 1
#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
#define HAVE_STDLIB_H 1
#define HAVE_REALLOC 1
#define HAVE_STDLIB_H 1
#define HAVE_MALLOC 1
#define HAVE_DECL_CLEARERR_UNLOCKED 1
#define HAVE_DECL_FEOF_UNLOCKED 1
#define HAVE_DECL_FERROR_UNLOCKED 1
#define HAVE_DECL_FFLUSH_UNLOCKED 1
#define HAVE_DECL_FGETS_UNLOCKED 1
#define HAVE_DECL_FPUTC_UNLOCKED 1
#define HAVE_DECL_FPUTS_UNLOCKED 1
#define HAVE_DECL_FREAD_UNLOCKED 1
#define HAVE_DECL_FWRITE_UNLOCKED 1
#define HAVE_DECL_GETC_UNLOCKED 1
#define HAVE_DECL_GETCHAR_UNLOCKED 1
#define HAVE_DECL_PUTC_UNLOCKED 1
#define HAVE_DECL_PUTCHAR_UNLOCKED 1
#define HAVE_DECL_STRTOL 1
#define HAVE_DECL_STRTOUL 1
#define HAVE_DECL_STRTOULL 1
#define HAVE_DECL_STRTOIMAX 1
#define HAVE_DECL_STRTOUMAX 1
#define HAVE_LIMITS_H 1
#define HAVE_STDLIB_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STRTOUMAX 1
#define HAVE_DECL_STRTOL 1
#define HAVE_DECL_STRTOUL 1
#define HAVE_DECL_STRTOLL 1
#define HAVE_DECL_STRTOIMAX 1
#define HAVE_DECL_STRTOUMAX 1
#define HAVE_LIMITS_H 1
#define HAVE_STDLIB_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STRTOIMAX 1
#define HAVE_LOCALTIME_R 1
#define HAVE_STRFTIME 1
#define HAVE_LIMITS_H 1
#define HAVE_BCOPY 1
#define HAVE_TZSET 1
#define HAVE_MEMPCPY 1
#define HAVE_MEMCPY 1
#define HAVE_MEMSET 1
#define HAVE_STRUCT_TM_TM_ZONE 1
#define HAVE_TM_ZONE 1
#define HAVE_MBLEN 1
#define HAVE_MBRLEN 1
#define HAVE_TM_GMTOFF 1
#define HAVE_SYS_TIME_H 1
#define my_strftime nstrftime
#define HAVE_STDIO_EXT_H 1
#define HAVE___FPENDING 1
#define HAVE_DECL___FPENDING 1
#define HAVE_GETGROUPS 1
#define HAVE_FSEEKO 1
#define HAVE_VPRINTF 1
#define HAVE_PROC_UPTIME 1
#define HAVE_FTRUNCATE 1
#define HAVE_MKSTEMP 1
#define HAVE_UTIME_NULL 1
#define HAVE_UTIME_H 1
#define FILESYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX 0
#define FILESYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR 0
#define GNU_PACKAGE "GNU coreutils"
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
#define major_t unsigned int
#define minor_t unsigned int
/* end confdefs.h.  */
#include <stdio.h>
#include <regex.h>
	  int
	  main ()
	  {
	    static struct re_pattern_buffer regex;
	    const char *s;
	    struct re_registers regs;
	    re_set_syntax (RE_SYNTAX_POSIX_EGREP);
	    s = re_compile_pattern ("a[[:]:]]b\n", 9, &regex);
	    /* This should fail with _Invalid character class name_ error.  */
	    if (!s)
	      exit (1);

	    /* This should succeed, but doesn't for e.g. glibc-2.1.3.  */
	    s = re_compile_pattern ("{1", 2, &regex);

	    if (s)
	      exit (1);

	    /* The following example is derived from a problem report
               against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>.  */
	    s = re_compile_pattern ("[anù]*n", 7, &regex);
	    if (s)
	      exit (1);

	    /* This should match, but doesn't for e.g. glibc-2.2.1.  */
	    if (re_match (&regex, "an", 2, 0, &regs) != 2)
	      exit (1);

	    exit (0);
	  }



Reply to: