Opened 6 years ago
Last modified 5 years ago
#57203 assigned defect
pcreposix segfault in regfree with trivial program
Reported by: | markpizz (Mark Pizzolato) | Owned by: | larryv (Lawrence Velázquez) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | Cc: | ||
Port: | pcre |
Description
This program (retest.c) fails:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <pcreposix.h> #include <pcre.h> #include <pthread.h> int main (int argc, char **argv) { int re_result; regex_t re; char match_buf[64] = "Match This"; printf("Using PCRE V %s\n", pcre_version()); memset (&re, 0, sizeof(re)); re_result = regcomp (&re, match_buf, REG_EXTENDED); if (re_result) { size_t err_size = regerror (re_result, &re, NULL, 0); char *err_buf = (char *)calloc (err_size+1, 1); regerror (re_result, &re, err_buf, err_size); fprintf (stderr, "Regular Expression Error compiling '%s': %s\n", match_buf, err_buf); free (err_buf); exit (1); } printf("Regular Expression compile of '%s' successful\n", match_buf); regfree (&re); }
This is how I see the failure:
bash-3.2# port list installed bash-3.2# port install pcre ---> Computing dependencies for pcre The following dependencies will be installed: bzip2 libedit ncurses zlib Continue? [Y/n]: y ---> Fetching archive for bzip2 ---> Attempting to fetch bzip2-1.0.6_0.darwin_17.x86_64.tbz2 from https://packages.macports.org/bzip2 ---> Attempting to fetch bzip2-1.0.6_0.darwin_17.x86_64.tbz2.rmd160 from https://packages.macports.org/bzip2 ---> Installing bzip2 @1.0.6_0 ---> Activating bzip2 @1.0.6_0 ---> Cleaning bzip2 ---> Fetching archive for ncurses ---> Attempting to fetch ncurses-6.1_0.darwin_17.x86_64.tbz2 from https://packages.macports.org/ncurses ---> Attempting to fetch ncurses-6.1_0.darwin_17.x86_64.tbz2.rmd160 from https://packages.macports.org/ncurses ---> Installing ncurses @6.1_0 ---> Activating ncurses @6.1_0 ---> Cleaning ncurses ---> Fetching archive for libedit ---> Attempting to fetch libedit-20170329-3.1_2.darwin_17.x86_64.tbz2 from https://packages.macports.org/libedit ---> Attempting to fetch libedit-20170329-3.1_2.darwin_17.x86_64.tbz2.rmd160 from https://packages.macports.org/libedit ---> Installing libedit @20170329-3.1_2 ---> Activating libedit @20170329-3.1_2 ---> Cleaning libedit ---> Fetching archive for zlib ---> Attempting to fetch zlib-1.2.11_0.darwin_17.x86_64.tbz2 from https://packages.macports.org/zlib ---> Attempting to fetch zlib-1.2.11_0.darwin_17.x86_64.tbz2.rmd160 from https://packages.macports.org/zlib ---> Installing zlib @1.2.11_0 ---> Activating zlib @1.2.11_0 ---> Cleaning zlib ---> Fetching archive for pcre ---> Attempting to fetch pcre-8.42_0.darwin_17.x86_64.tbz2 from https://packages.macports.org/pcre ---> Attempting to fetch pcre-8.42_0.darwin_17.x86_64.tbz2.rmd160 from https://packages.macports.org/pcre ---> Installing pcre @8.42_0 ---> Activating pcre @8.42_0 ---> Cleaning pcre ---> Updating database of binaries ---> Updating database of C++ stdlib usage ---> Scanning binaries for linking errors ---> No broken files found. ---> No broken ports found. bash-3.2# exit exit mac-mini:~ mark$ gcc retest.c -I/opt/local/include -L/opt/local/lib -lpthread -lpcreposix -lpcre -o retest mac-mini:~ mark$ ./retest Using PCRE V 8.42 2018-03-20 Regular Expression compile of 'Match This' successful Segmentation fault: 11 -mini:~ mark$
Change History (3)
comment:1 Changed 6 years ago by jmroot (Joshua Root)
Owner: | set to larryv |
---|---|
Status: | new → assigned |
comment:2 Changed 6 years ago by markpizz (Mark Pizzolato)
Hi Larry,
My system is running the latest macOS Hight Sierra version 10.13.6.
Looking in /Library/Logs/DiagnosticReports I do not see any 'crash log' specific to this simple application generating a segfault. The /Library/Logs/CrashReporter directory is empty.
If I run this test program under the debugger I get:
marks-mac-mini:simh mark$ gcc -g -O0 retest.c -I/opt/local/include -L/opt/local/lib -lpthread -lpcreposix -lpcre -o retest marks-mac-mini:simh mark$ lldb ./retest (lldb) target create "./retest" Current executable set to './retest' (x86_64). (lldb) run Process 20418 launched: './retest' (x86_64) Using PCRE V 8.42 2018-03-20 Regular Expression compile of 'Match This' successful Process 20418 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x400280) frame #0: 0x00007fff714ece95 libsystem_c.dylib`tre_free + 37 libsystem_c.dylib`tre_free: -> 0x7fff714ece95 <+37>: cmpl $0x0, 0x40(%r14) 0x7fff714ece9a <+42>: movq (%r14), %rdi 0x7fff714ece9d <+45>: je 0x7fff714ecef6 ; <+134> 0x7fff714ece9f <+47>: xorl %ebx, %ebx Target 0: (retest) stopped. (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x400280) * frame #0: 0x00007fff714ece95 libsystem_c.dylib`tre_free + 37 frame #1: 0x0000000100000dfd retest`main(argc=1, argv=0x00007ffeefbffb48) at retest.c:29 frame #2: 0x00007fff7142a015 libdyld.dylib`start + 1 frame #3: 0x00007fff7142a015 libdyld.dylib`start + 1 (lldb)
comment:3 Changed 5 years ago by dgilman (David Gilman)
I can't reproduce this in the latest pcre v8.44.
Note: See
TracTickets for help on using
tickets.
Can you attach a crash log?