Solaris10 libc bug: regexec() hangs

Hello,

I have found a bug in Solaris10 libc. Compiling a regex containing combinations of +,*,?

characters, and executing it on a certain string leads to a hang of regexec().

The regexec is finite in length, and is compiled successfully, the string I want to match with is finite in length, so regexec() shouldn't hang, but finish execution within a reasonable amount of time.

I tested the same regular expression/string combination on other platforms with GNU libc, and only Solaris's implementation hangs.

I am not sure what the appropriate place is for a bugreport on Solaris10, so I contacted this forum.

A test case to reproduce this can be found below:

I tested the hang on SunOS solaris10 5.10 Generic_118855-33 i86pc i386 i86pc,

compiler: gcc 3.4.6

Others have tested on Solaris 9, sparc, cc (not gcc) with similar results.

#include <stdio.h>

#include <regex.h>

int main(int argc,char* argv[])

{

regex_t preg;

const char * regex="^(/((([-$_@.&a-zA-Z0-9!*\"'(),]|%[0-9a-fA-f]{2}))+/?)*)?$";

int rc;

const char* text="/wwwwww.wwwww/wwwwww-www/wwww-www/www/www=wwww/wwwww.wwwww/wwww&ww=98 563257ahyrtmpzikqs&wwwww=wwwww/wwwww&wwww/wwww";

rc = regcomp(&preg,regex,REG_EXTENDED|REG_ICASE|REG_NOSUB);

if(rc) {

size_t buflen =regerror(rc,&preg,NULL,0);

char *errbuf = malloc(buflen);

if(errbuf) {

regerror(rc,&preg,errbuf,buflen);

fprintf(stderr,"Error in compiling regex:%s\n",errbuf);

free(errbuf);

} else

fprintf(stderr,"Error in compiling regex. Additionally an Out-of-memory error was encountered while generating a detailed error message\n");

return 1;

}

printf("regexec()\n");

regexec(&preg, text, 0, NULL, 0);

return 0;

}

[1883 byte] By [edwin.toroka] at [2007-11-27 5:40:24]
# 1

> I am not sure what the appropriate place is for a

> bugreport on Solaris10, so I contacted this forum.

You might want to try over at:

https://www.opensolaris.org/enter.jspa?targetPage=%2Fbug%2Freport.jspa

or

https://osc-amer.sun.com/OSCSW/svcportal?pageName=clselection

the first one is for Open Solaris Bug Reports and the second one is

for Sunsolve.

alan

alan.paea at 2007-7-12 15:16:44 > top of Java-index,Solaris Operating System,Solaris 10 Features...
# 2

The symptom seems to match the following bug:

http://bugs.opensolaris.org/bugdatabase/printableBug.do?bug_id=4346175

Try the workaround once i.e., replace '^' with "\\n" in the string pointed by regex.

Feel free to file a bug at bugs.opensolaris.org, if the suggested workaround is not acceptable.

giri04a at 2007-7-12 15:16:44 > top of Java-index,Solaris Operating System,Solaris 10 Features...