473,732 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_r eg, "http://([^/]*)(/{0,1}.*)",
REG_EXTENDED | REG_ICASE);
printf("regcomp success = %d\r\n", success);
success = regexec(&test_r eg, 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 5621
al********@gmai l.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.progr ammer 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
11440
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 () from /lib/tls/libc.so.6 It's really strange; I just call malloc() like "tmp=malloc(size);" the system gives me Segmentation fault I want to write a code to do like a dynamic array, and the code is as
5
2996
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 understood that a segmentation fault can occur whenever I declare a pointer and I leave it un-initialized. So I thought the problem here is with the (const char *)s in the stuct flightData (please note that I get the same fault declaring as char * the...
18
26115
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)? Thanks.
27
3360
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! #include <stdlib.h> #include <stdio.h> typedef struct _node_t {
2
2390
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, char * string, (size_t) nmatch,regmatch_t pmatch,int eflags); My Query is this :
7
5879
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 testcases we experiance Segmentation fault from the python libraries. If i know how to handle the exception for Segmentation fault , it will help me complete the run on any testcase , even if i experiance Seg Fault due to any one or many functions in...
3
5187
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 from 10g release2 PHP is configured with the following parameters './configure' '--prefix=/opt/oracle/php' '--with-apxs=/opt/oracle/apache/bin/apxs' '--with-config-file-path=/opt/oracle/apache/conf' '--enable-safe-mode' '--enable-session'...
6
5043
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 gcc. The only difference is that in first I only call "main" and in second call
2
2901
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. I want to modify the sub string such that it matches only if the
0
9447
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.