473,395 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

regexec from regex.h Segmentation fault

the below program is working in Suse and not working on Cent 5:
can any body have the solution ?

#include <regex.h>
#include <stdlib.h>
#include <stdio.h>

int main(){

char cool[] = "http://www.cnn.com:80/wowsers.html";
regex_t test_reg;
regmatch_t matches[3];
int num_matches;
int success = regcomp(&test_reg, "http://([^/]*)(/{0,1}.*)",
REG_EXTENDED | REG_ICASE);
printf("regcomp success = %d\r\n", success);
success = regexec(&test_reg, cool, num_matches, matches, 0);
printf("regexec success = %d\r\n", success);
printf("overall match start index = %d\r\n", matches[0].rm_so);
printf("overall match end index = %d\r\n",
matches[0].rm_eo);
printf("first match start index = %d\r\n", matches[1].rm_so);
printf("first match end index = %d\r\n", matches[1].rm_eo);
printf("second match start index = %d\r\n", matches[2].rm_so);
printf("second match end index = %d\r\n", matches[2].rm_eo);

}

OUTPUT on SuSE(10.2):
../regex
regcomp success = 0
regexec success = 0
overall match start index = 0
overall match end index = 34
first match start index = 7
first match end index = 21
second match start index = 21
second match end index = 34
OUTPUT on Cent(5):
../regex
regcomp success = 0
Segmentation fault

MORE DETAILS:
regex.h are same on both machine.

ldd ./regex ( on Cent 5 )
linux-gate.so.1 = (0x00a43000)
libc.so.6 =/lib/libc.so.6 (0x00110000)
/lib/ld-linux.so.2 (0x0093c000)
glibc-devel-2.5-12 (rpm -qf /usr/include/regex.h)
ldd ./regex ( on SuSE 10.2 )
linux-gate.so.1 = (0xffffe000)
libc.so.6 =/lib/libc.so.6 (0xb7d8c000)
/lib/ld-linux.so.2 (0xb7ee9000)
glibc-devel-2.5-25 (rpm -qf /usr/include/regex.h)
Feb 4 '08 #1
1 5588
al********@gmail.com writes:
the below program is working in Suse and not working on Cent 5:
can any body have the solution ?

#include <regex.h>
#include <stdlib.h>
#include <stdio.h>

int main(){

char cool[] = "http://www.cnn.com:80/wowsers.html";
regex_t test_reg;
regmatch_t matches[3];
int num_matches;
int num_matches = 3;

You are expected to say how big the matches array is. This is not
really on-topic here. Further problem should go to
comp.unix.programmer since this is a POSIX interface.

--
Ben.
Feb 4 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Zheng Da | last post by:
Program received signal SIGSEGV, Segmentation fault. 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 (gdb) bt #0 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 #1 0x40094c54 in malloc...
5
by: Fra-it | last post by:
Hi everybody, I'm trying to make the following code running properly, but I can't get rid of the "SEGMENTATION FAULT" error message when executing. Reading some messages posted earlier, I...
18
by: Digital Puer | last post by:
Hi, I'm coming over from Java to C++, so please bear with me. In C++, is there a way for me to use exceptions to catch segmentation faults (e.g. when I access a location off the end of an array)?...
27
by: Paminu | last post by:
I have a wierd problem. In my main function I print "test" as the first thing. But if I run the call to node_alloc AFTER the printf call I get a segmentation fault and test is not printed! ...
2
by: zoltan | last post by:
Hi, I am using a function called regexec() as defined in the regex.h header in libc.a. I am coding on Solaris 8 machine. The function is defined as follows : int regexec(const regex_t * preg,...
7
by: pycraze | last post by:
I would like to ask a question. How do one handle the exception due to Segmentation fault due to Python ? Our bit operations and arithmetic manipulations are written in C and to some of our...
3
by: madunix | last post by:
My Server is suffering bad lag (High Utlization) I am running on that server Oracle10g with apache_1.3.35/ php-4.4.2 Web visitors retrieve data from the web by php calls through oci cobnnection...
6
by: DanielJohnson | last post by:
int main() { printf("\n Hello World"); main; return 0; } This program terminate just after one loop while the second program goes on infinitely untill segmentation fault (core dumped) on...
2
by: apoorva.groups | last post by:
Hi I am facing problem while using regexec function. Ex: String = "abc_def_hig" sub string = "def" regexc if I use regexec the it will find the sub string in string and it will return 0....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.