LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-22-2007, 05:52 AM   #1
nc3b
Member
 
Registered: Aug 2005
Posts: 330

Rep: Reputation: 32
Unhappy ferror and feof segmentation fault


Hello. I have a strange problem.. I have the following code:

Code:
if(rx==NULL)
{
  //bla bla
}
else
{
    if(ferror(rx) || feof(rx))
    {
        //bla bla
    }
}
And it fails on ferror with sigsev. And if I take out ferror, I it fails on feof. It's the first case of ferror or feof failing like that.. In the man page they say

Quote:
These functions should not fail
I am really confused, as the problem only came up recently after making some changes that DO NOT relate in any way with this piece of code. And I don't have a working copy of the program, the newest is ages old.. Can anyone help?
 
Old 07-22-2007, 08:07 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
These functions are likely to fail if something elsewhere in the program is stomping on *rx.

If you put that snippet of code in a tiny test program, you'll probably find that it works.

In the full body of code, it fails.

The changes that do not relate in any way to this code probably contain a bug that steps on *rx.

Your job is most likely to see what steps on *rx and why.

Hope this helps.
 
Old 07-22-2007, 08:07 AM   #3
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
What is rx (how declared)? Is it already opened?
 
Old 07-22-2007, 11:32 AM   #4
nc3b
Member
 
Registered: Aug 2005
Posts: 330

Original Poster
Rep: Reputation: 32
Thanks guys. I solved this one, wjevans was right, something was trashing rx.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
Segmentation fault alnreddy Linux - Software 1 11-05-2005 08:54 PM
Segmentation fault bondoroyot Linux - Newbie 1 06-14-2005 07:53 PM
segmentation fault libriana Linux - Newbie 2 06-10-2005 05:52 PM
segmentation fault??? max_rsr Programming 2 04-15-2005 08:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration