* ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg Fault
@ 2007-02-01 6:56 Daniel Ng
2007-02-02 7:30 ` Wolfgang Denk
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Daniel Ng @ 2007-02-01 6:56 UTC (permalink / raw)
To: linuxppc-embedded
Hi,
My application Seg Faults when I try to set flags for my socket fd.
First, I get the fd by calling socket():
fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
Then I try getting the fd flags:
fcntl(fd, F_GETFL, flags)
Then I try setting the flags:
flags |= O_NONBLOCK;
fcntl( fd, F_SETFL, flags );
-I get consistent Seg Faults on the last line above.
-I also checked fd, which is a sensible value.
I can even successfully connect() with it.
-The problem happens regardless of what value 'flags' is set to
My embedded target details-
-powerpc8272
-ELDK v4
-the application uses glibc
Any ideas why I'm getting these Seg Faults?
Cheers,
Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg Fault
2007-02-01 6:56 ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg Fault Daniel Ng
@ 2007-02-02 7:30 ` Wolfgang Denk
2007-02-05 3:11 ` Daniel Ng
2007-02-02 14:11 ` ELDK glibc fcntl(socketFd,F_SETFL, " Edward Jubenville
2007-02-02 15:03 ` ELDK glibc fcntl(socketFd, F_SETFL, " Magnus Hjorth
2 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Denk @ 2007-02-02 7:30 UTC (permalink / raw)
To: Daniel Ng; +Cc: linuxppc-embedded
In message <loom.20070201T073939-302@post.gmane.org> you wrote:
>
> My application Seg Faults when I try to set flags for my socket fd.
>
> First, I get the fd by calling socket():
> fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
>
> Then I try getting the fd flags:
> fcntl(fd, F_GETFL, flags)
Provide some working / crashing test code, i. e. a complete C program
with declarations etc.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
There's an old story about the person who wished his computer were as
easy to use as his telephone. That wish has come true, since I no
longer know how to use my telephone.
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg Fault
[not found] <mailman.1565.1170401421.9285.linuxppc-embedded@ozlabs.org>
@ 2007-02-02 14:10 ` Christopher Dumoulin
0 siblings, 0 replies; 6+ messages in thread
From: Christopher Dumoulin @ 2007-02-02 14:10 UTC (permalink / raw)
To: linuxppc-embedded
If that's your exact code, I notice you're not checking if the socket()
call succeeded. You may be calling fcntl with an invalid socket handle.
The first place I'd look is to make sure you've included 'Networking
Support', 'Unix domain sockets', maybe 'TCP/IP networking', and whatever
else you might need, when you configure your kernel.
---------------------------------------------------------------------
Message: 6
Date: Fri, 02 Feb 2007 08:30:18 +0100
From: Wolfgang Denk <wd@denx.de>
Subject: Re: ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg
Fault
To: Daniel Ng <daniel_ng11@lycos.com>
Cc: linuxppc-embedded@ozlabs.org
Message-ID: <20070202073018.C8710352B86@atlas.denx.de>
Content-Type: text/plain; charset=ISO-8859-1
In message <loom.20070201T073939-302@post.gmane.org> you wrote:
>
> My application Seg Faults when I try to set flags for my socket fd.
>
> First, I get the fd by calling socket():
> fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
>
> Then I try getting the fd flags:
> fcntl(fd, F_GETFL, flags)
Provide some working / crashing test code, i. e. a complete C program
with declarations etc.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
There's an old story about the person who wished his computer were as
easy to use as his telephone. That wish has come true, since I no
longer know how to use my telephone.
------------------------------
_______________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: ELDK glibc fcntl(socketFd,F_SETFL, flags) causes Seg Fault
2007-02-01 6:56 ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg Fault Daniel Ng
2007-02-02 7:30 ` Wolfgang Denk
@ 2007-02-02 14:11 ` Edward Jubenville
2007-02-02 15:03 ` ELDK glibc fcntl(socketFd, F_SETFL, " Magnus Hjorth
2 siblings, 0 replies; 6+ messages in thread
From: Edward Jubenville @ 2007-02-02 14:11 UTC (permalink / raw)
To: linuxppc-embedded
> Then I try getting the fd flags:
> fcntl(fd, F_GETFL, flags)
Don't you really need to do this...
flags = fcntl(fd, F_GETFL, 0)
to get the correct initial state of the flags?
Ed Jubenville
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg Fault
2007-02-01 6:56 ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg Fault Daniel Ng
2007-02-02 7:30 ` Wolfgang Denk
2007-02-02 14:11 ` ELDK glibc fcntl(socketFd,F_SETFL, " Edward Jubenville
@ 2007-02-02 15:03 ` Magnus Hjorth
2 siblings, 0 replies; 6+ messages in thread
From: Magnus Hjorth @ 2007-02-02 15:03 UTC (permalink / raw)
To: Daniel Ng; +Cc: linuxppc-embedded
Daniel Ng wrote:
> Hi,
>
> My application Seg Faults when I try to set flags for my socket fd.
>
> Then I try getting the fd flags:
> fcntl(fd, F_GETFL, flags)
>
Shouldn't it be &flags ??
--
Magnus Hjorth, M.Sc.
Omnisys Instruments AB
Gruvgatan 8
SE-421 30 Västra Frölunda, SWEDEN
Phone: +46 31 734 34 09
Fax: +46 31 734 34 29
http://www.omnisys.se
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg Fault
2007-02-02 7:30 ` Wolfgang Denk
@ 2007-02-05 3:11 ` Daniel Ng
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Ng @ 2007-02-05 3:11 UTC (permalink / raw)
To: linuxppc-embedded
Thanks for your help everyone, I figured it out.
The cause of the problem seems to be unrelated to the F_SETFL- it just happened
to seg fault at that point all the time.
Cheers,
Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-02-05 3:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-01 6:56 ELDK glibc fcntl(socketFd, F_SETFL, flags) causes Seg Fault Daniel Ng
2007-02-02 7:30 ` Wolfgang Denk
2007-02-05 3:11 ` Daniel Ng
2007-02-02 14:11 ` ELDK glibc fcntl(socketFd,F_SETFL, " Edward Jubenville
2007-02-02 15:03 ` ELDK glibc fcntl(socketFd, F_SETFL, " Magnus Hjorth
[not found] <mailman.1565.1170401421.9285.linuxppc-embedded@ozlabs.org>
2007-02-02 14:10 ` Christopher Dumoulin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).