All of lore.kernel.org
 help / color / mirror / Atom feed
* bug in kernel
@ 2005-03-14 14:48 Evgeniy
  2005-03-14 14:51 ` Arjan van de Ven
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Evgeniy @ 2005-03-14 14:48 UTC (permalink / raw)
  To: linux-kernel

Here is a simple program.

#include <stdio.h>
#include <errno.h>
main(){
  int err;
  err=read(0,NULL,6);
  printf("%d %d\n",err,errno);
}

I think that it should be an error : Null pointer assignment, like in windows.
But in practise it is not so. 
Mandrake Linux kernel 2.4.21-0.13mdk
I am a programmer too and i am very interested to solve this problem. Please, 
send me fragment of sourse code of kernel with this bug.
Thanks.
Sorry for my English

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug in kernel
  2005-03-14 14:48 bug in kernel Evgeniy
@ 2005-03-14 14:51 ` Arjan van de Ven
  2005-03-14 14:55   ` Arjan van de Ven
  2005-03-14 15:22 ` Bernhard Rosenkraenzer
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Arjan van de Ven @ 2005-03-14 14:51 UTC (permalink / raw)
  To: Evgeniy; +Cc: linux-kernel

On Mon, 2005-03-14 at 17:48 +0300, Evgeniy wrote:
> Here is a simple program.
> 
> #include <stdio.h>
> #include <errno.h>
> main(){
>   int err;
>   err=read(0,NULL,6);
>   printf("%d %d\n",err,errno);
> }
> 
> I think that it should be an error : Null pointer assignment, like in windows.
> But in practise it is not so. 
> Mandrake Linux kernel 2.4.21-0.13mdk
> I am a programmer too and i am very interested to solve this problem. Please, 
> send me fragment of sourse code of kernel with this bug.

well what is the value of errno ?
-EFAULT by chance ?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug in kernel
  2005-03-14 14:51 ` Arjan van de Ven
@ 2005-03-14 14:55   ` Arjan van de Ven
  0 siblings, 0 replies; 7+ messages in thread
From: Arjan van de Ven @ 2005-03-14 14:55 UTC (permalink / raw)
  To: Evgeniy; +Cc: linux-kernel

On Mon, 2005-03-14 at 15:51 +0100, Arjan van de Ven wrote:
> On Mon, 2005-03-14 at 17:48 +0300, Evgeniy wrote:
> > Here is a simple program.
> > 
> > #include <stdio.h>
> > #include <errno.h>
> > main(){
> >   int err;
> >   err=read(0,NULL,6);
> >   printf("%d %d\n",err,errno);
> > }
> > 
> > I think that it should be an error : Null pointer assignment, like in windows.
> > But in practise it is not so. 
> > Mandrake Linux kernel 2.4.21-0.13mdk
> > I am a programmer too and i am very interested to solve this problem. Please, 
> > send me fragment of sourse code of kernel with this bug.
> 
> well what is the value of errno ?
> -EFAULT by chance ?

note that you need to include <unistd.h> for the proper read() prototype
btw


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug in kernel
  2005-03-14 14:48 bug in kernel Evgeniy
  2005-03-14 14:51 ` Arjan van de Ven
@ 2005-03-14 15:22 ` Bernhard Rosenkraenzer
  2005-03-14 15:55 ` Martin Zwickel
  2005-03-14 16:57 ` linux-os
  3 siblings, 0 replies; 7+ messages in thread
From: Bernhard Rosenkraenzer @ 2005-03-14 15:22 UTC (permalink / raw)
  To: Evgeniy; +Cc: linux-kernel

On Monday 14 March 2005 15:48, Evgeniy wrote:
> #include <stdio.h>
> #include <errno.h>
> main(){
>   int err;
>   err=read(0,NULL,6);
>   printf("%d %d\n",err,errno);
> }

On my box (2.6.11), that does exactly what it is supposed to do -- "-1 14"
14 == EFAULT == "Bad Address", which is what NULL is...

Btw, printf("%d %d %s\n", err, errno, strerror(errno)); gives you a more 
readable error, that would immediately show you did get the right error.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug in kernel
@ 2005-03-14 15:47 Pat Kane
  0 siblings, 0 replies; 7+ messages in thread
From: Pat Kane @ 2005-03-14 15:47 UTC (permalink / raw)
  To: linux-kernel

I ran the little test program on my 2.4.26  Knoppix system, and got the 
following two results:

  strace a.out < /dev/tty
   ...
   read(0, NULL, 6)                        = 1
   ...

  strace a.out < /dev/zero
   ...
   read(0, 0, 6)                           = -1 EFAULT (Bad address)
   ...

The first case looks broken.

Pat
---




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug in kernel
  2005-03-14 14:48 bug in kernel Evgeniy
  2005-03-14 14:51 ` Arjan van de Ven
  2005-03-14 15:22 ` Bernhard Rosenkraenzer
@ 2005-03-14 15:55 ` Martin Zwickel
  2005-03-14 16:57 ` linux-os
  3 siblings, 0 replies; 7+ messages in thread
From: Martin Zwickel @ 2005-03-14 15:55 UTC (permalink / raw)
  To: Evgeniy; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 633 bytes --]

On Mon, 14 Mar 2005 17:48:05 +0300
Evgeniy <shubin_evgeniy@mail.ru> bubbled:

> Here is a simple program.
> 
> #include <stdio.h>
> #include <errno.h>
> main(){
>   int err;
>   err=read(0,NULL,6);
>   printf("%d %d\n",err,errno);
> }

Results:
# ./a < /dev/zero 
read(0, 0, 6)                           = -1 EFAULT (Bad address)
-1 14 Bad address

So everything is fine...

Regards,
Martin

-- 
MyExcuse:
I'd love to help you -- it's just that the Boss won't let me near the
computer.

Martin Zwickel <martin.zwickel@technotrend.de>
Research & Development

TechnoTrend AG <http://www.technotrend.de>

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug in kernel
  2005-03-14 14:48 bug in kernel Evgeniy
                   ` (2 preceding siblings ...)
  2005-03-14 15:55 ` Martin Zwickel
@ 2005-03-14 16:57 ` linux-os
  3 siblings, 0 replies; 7+ messages in thread
From: linux-os @ 2005-03-14 16:57 UTC (permalink / raw)
  To: Evgeniy; +Cc: linux-kernel

On Mon, 14 Mar 2005, Evgeniy wrote:

> Here is a simple program.
>
> #include <stdio.h>
> #include <errno.h>
> main(){
>  int err;
>  err=read(0,NULL,6);
>  printf("%d %d\n",err,errno);
> }
>
> I think that it should be an error : Null pointer assignment, like in windows.
> But in practise it is not so.

It is an error. It will wait <forever> until you enter the [Enter]
key (it's reading from STDIN_FILENO). Then it will return -1 which
means there was an error, the error code in errno is 14 (EFAULT)
or "bad address".

You can configure user-mode code to "seg-fault" upon receiving
such an error. It can print a nasty message and leave a worthless
core file in your directory.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
  Notice : All mail here is now cached for review by Dictator Bush.
                  98.36% of all statistics are fiction.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-03-14 16:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-14 14:48 bug in kernel Evgeniy
2005-03-14 14:51 ` Arjan van de Ven
2005-03-14 14:55   ` Arjan van de Ven
2005-03-14 15:22 ` Bernhard Rosenkraenzer
2005-03-14 15:55 ` Martin Zwickel
2005-03-14 16:57 ` linux-os
  -- strict thread matches above, loose matches on Subject: below --
2005-03-14 15:47 Pat Kane

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.