LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 09-02-2004, 05:28 PM   #1
jwstric2
Member
 
Registered: Jan 2004
Posts: 105

Rep: Reputation: 15
NULL buffer in read sys call unpredictable


This is a bad thing to do, but why does a NULL buffer in read(fd,buffer,size) result in:

1. Block call with no error
2. CPU intensive, cpu runs at a 100%

I was asking because some code I wrote by accident had a NULL buffer and it went crazy. I thought it would result in a seg fault at least.

This is just a general inquiry, I was hopin someone would know before I dug around in the read sys call.

Thanks
Jonathan S.
 
Old 09-02-2004, 06:37 PM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
doesn't do so when i tested reading from stdin, and from a regular file, on kernel 2.4.14-20. depending on what that file descriptor references, there may be some bad underlying device code though.
 
Old 09-02-2004, 06:39 PM   #3
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
a hint, if you are going to dig through the sources, and if this is a regular file being read, you'll want to look at the generic_file_read() function. that is what the function pointer that gets dereferenced is pointing to in sys_read(). it took me a bit to finally find that when digging through sources this summer, HTH.
 
Old 09-02-2004, 07:13 PM   #4
jwstric2
Member
 
Registered: Jan 2004
Posts: 105

Original Poster
Rep: Reputation: 15
Maybe I should have said it was a tcp socket fd. Does that make a difference when you test it. Im running 2.6.1 kernel, fedora 1.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
question about select sys call xatzipol Programming 1 10-30-2005 09:22 AM
Write sys call failing ppy Programming 1 11-05-2004 08:57 AM
Any sys call to list all users ? dileepkk Linux - General 5 07-06-2004 06:04 PM
Kill sys call eshwar_ind Programming 4 05-07-2004 11:41 AM
any sys call to get ip address of NIC jmdey Linux - General 2 05-30-2002 03:09 PM


All times are GMT -5. The time now is 04:56 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration