LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   NULL buffer in read sys call unpredictable (https://www.linuxquestions.org/questions/programming-9/null-buffer-in-read-sys-call-unpredictable-225887/)

jwstric2 09-02-2004 05:28 PM

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.

infamous41md 09-02-2004 06:37 PM

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.

infamous41md 09-02-2004 06:39 PM

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.

jwstric2 09-02-2004 07:13 PM

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.


All times are GMT -5. The time now is 07:54 PM.