Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Ubuntu gdb cores Xcode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ubuntu gdb cores Xcode




On Nov 13, 2008, at 6:06 PM, Dee Ayy wrote:
"Now that my_app is running fine on Ubuntu, I'm trying again to run on
the Mac, but I actually get a Segmentation fault with the same
successfully built sources on the Mac."

When I go through my typical gdb session, it reports on the line
while(fgets(stream, StreamSize, stdin) != NULL){
regarding
fgets

My guess is that stream is NULL.

I dropped the -lm as you suggested Steve, and I still get the same
Segmentation fault (core dumped) with gdb complaining about fgets.
What about that -lc mentioned in man for fgets?

You don't need -lc.

On Nov 13, 2008, at 9:24 PM, Dee Ayy wrote:

Here is a sample of the strings being written to my_pipe from a MS
VC++ 6.0 compiled app, which runs in Wine from winehq.org on Mac OSX
shell X11.app.  It parsed fine through my_app running on Ubuntu.  It
runs intermittently on Mac OSX (apparently built by both cc and
Xcode).

Xcode uses gcc to compile.

Should I be concerned about porting the line endings when dealing with
fgets, strdup, strstr, strncpy, strtok, atof, char[], char* ?
They are supposed to be terminated by newlines \n sent by std::cout.
Also, although all these strings are written to my_pipe, after it
reaches fgets in my_app, only lines containing say GBPCHF are supposed
to filter through and continue parsing to get at the separate 1.7624
and 1.7633 and turn them into doubles.  On the Mac, such filtering of
only GBPCHF lines is not happening.

OS X considers \n as the line ending although that has no effect on strdup, strstr, strncpy, strtok, or atof, let alone character arrays or pointers.


Does it matter if I #define _GNU_SOURCE when compiling on the Mac?  It
did not seem to matter.  If so, is there another switch I should be
using?

I would imagine it would depend on why you are defining that in the first place.


I wrote a simple "filter" based on your input.

[PBG4:~/temp] steve$ cat filter.c
#include <stdio.h>

int main()
{
char buffer[1024];
while( fgets(buffer, sizeof(buffer), stdin) )
{
double n, d;
if( sscanf(buffer, "[GQ-%*d-%*d-%*d %*d:%*d:%*dGBPCHF%lf/%lf]\n", &n, &d) != 2 )
continue;
printf( "Found GBPCHF: %f/%f\n", n, d );
}
return 0;
}
[PBG4:~/temp] steve$ gcc -Wall filter.c
[PBG4:~/temp] steve$ cat <<EOF | ./a.out
> [GQ-2008-11-14 06:25:50EURJPY123.59/123.63]
> [GQ-2008-11-14 06:25:50USDCHF1.1885/1.1888]
> [GQ-2008-11-14 06:25:50EURCAD1.5497/1.5507]
> [GQ-2008-11-14 06:25:50EURAUD1.9312/1.9321]
> [GQ-2008-11-14 06:25:50GBPCHF1.7624/1.7633]
> [GQ-2008-11-14 06:25:51EURUSD1.2731/1.2733]
> [GQ-2008-11-14 06:25:51XAGUSD9.32/9.4]
> [GQ-2008-11-14 06:25:51EURGBP0.8583/0.8586]
> [GQ-2008-11-14 06:25:51AUDJPY63.98/64.04]
> [GQ-2008-11-14 06:25:51EURGBP0.8584/0.8587]
> [GQ-2008-11-14 06:25:51AUDCAD0.8022/0.8029]
> [GQ-2008-11-14 06:25:51EURJPY123.59/123.63]
> [GQ-2008-11-14 06:25:51GBPCHF1.7624/1.7633]
> [GQ-2008-11-14 06:25:51AUDNZD1.1669/1.168]
> [GQ-2008-11-14 06:25:51EURAUD1.9312/1.9321]
> [GQ-2008-11-14 06:25:51XAUUSD728.85/729.9]
> [GQ-2008-11-14 06:25:51CHFJPY81.68/81.73]
> [GQ-2008-11-14 06:25:51GBPUSD1.4828/1.4832]
> [GQ-2008-11-14 06:25:51USDCHF1.1885/1.1888]
> [GQ-2008-11-14 06:25:51GBPJPY143.95/144.03]
> [GQ-2008-11-14 06:25:51XAGUSD9.32/9.4]
> [GQ-2008-11-14 06:25:52EURAUD1.9311/1.932]
> EOF
Found GBPCHF: 1.762400/1.763300
Found GBPCHF: 1.762400/1.763300


(Of course there's no real reason to be using a pipe from the output of cat here, just giving it as standard input would suffice. I just wanted to demonstrate that the pipe works just fine.)

Without showing more code, it's pretty hard to guess what's going wrong.

HTH,

--
Steve Checkoway





_______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Ubuntu gdb cores Xcode (From: "Dee Ayy" <email@hidden>)
 >Re: Ubuntu gdb cores Xcode (From: Steve Checkoway <email@hidden>)
 >Re: Ubuntu gdb cores Xcode (From: "Dee Ayy" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.