* (no subject)
@ 2001-10-15 6:25 Dinesh Gandhewar
2001-10-15 6:31 ` your mail Tim Hockin
2001-10-15 6:56 ` David Ford
0 siblings, 2 replies; 5+ messages in thread
From: Dinesh Gandhewar @ 2001-10-15 6:25 UTC (permalink / raw)
To: mlist-linux-kernel
Hello,
What is the effect of following statement at the end of function definition?
*(int *)0 = 0;
Thanking you,
Dinesh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: your mail
2001-10-15 6:25 Dinesh Gandhewar
@ 2001-10-15 6:31 ` Tim Hockin
2001-10-15 6:56 ` David Ford
1 sibling, 0 replies; 5+ messages in thread
From: Tim Hockin @ 2001-10-15 6:31 UTC (permalink / raw)
To: dinesh_gandhewar; +Cc: mlist-linux-kernel
> What is the effect of following statement at the end of function definition?
> *(int *)0 = 0;
to cause a crash - you can't derefernce a pointer whose value is 0 (NULL).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:
2001-10-15 6:25 Dinesh Gandhewar
2001-10-15 6:31 ` your mail Tim Hockin
@ 2001-10-15 6:56 ` David Ford
2001-10-15 16:02 ` Re: Timur Tabi
1 sibling, 1 reply; 5+ messages in thread
From: David Ford @ 2001-10-15 6:56 UTC (permalink / raw)
To: Dinesh Gandhewar; +Cc: mlist-linux-kernel
That should throw a segmentation fault, in the kernel an OOPS, in this
statement the code is trying to dereference a NULL pointer and store a
value at 0x0.
David
Dinesh Gandhewar wrote:
>Hello,
>What is the effect of following statement at the end of function definition?
>*(int *)0 = 0;
>Thanking you,
>Dinesh
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re:
2001-10-15 6:56 ` David Ford
@ 2001-10-15 16:02 ` Timur Tabi
2001-10-18 7:32 ` *(int *)0 = 0 Riley Williams
0 siblings, 1 reply; 5+ messages in thread
From: Timur Tabi @ 2001-10-15 16:02 UTC (permalink / raw)
To: mlist-linux-kernel
David Ford wrote:
> That should throw a segmentation fault, in the kernel an OOPS, in this
> statement the code is trying to dereference a NULL pointer and store a
> value at 0x0.
I much smarter way to do this would be to use this code:
static inline void int3(void) { __asm__ __volatile__ (".byte 0xCC\n"); };
Granted, it's x86-specific, but it works better, since gdb will halt the code
right at that spot rather than inside some trap hander. And it's just more
elegant.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: *(int *)0 = 0
2001-10-15 16:02 ` Re: Timur Tabi
@ 2001-10-18 7:32 ` Riley Williams
0 siblings, 0 replies; 5+ messages in thread
From: Riley Williams @ 2001-10-18 7:32 UTC (permalink / raw)
To: Timur Tabi; +Cc: Linux Kernel
Hi Timur.
>>> What is the effect of the following statement at the end of a
>>> function definition?
>>>
>>> *(int *)0 = 0;
>> That should throw a segmentation fault, in the kernel an OOPS, in
>> this statement the code is trying to dereference a NULL pointer and
>> store a value at 0x0.
> A much smarter way to do this would be to use this code:
> static inline void int3(void) { __asm__ __volatile__ (".byte 0xCC\n"); };
> Granted, it's x86-specific, but it works better, since gdb will halt
> the code right at that spot rather than inside some trap hander.
> And it's just more elegant.
As I understand it, there's two problems with your suggestion:
1. The fact that it's x86-specific would rule it out as part of
the actual code of most functions, as they are designed to
work on any of the supported processors without change.
However, this can be dealt with by using a macro function and
dropping the macro definition in an arch-specific header file.
2. The code isn't normally designed for what gdb does with it,
but for what it does when run on its own. I believe that the
original results in an error message being thrown up on the
screen, but I suspect your replacement would just halt the
processor and make the user think Linux had crashed.
Comments, anybody?
Best wishes from Riley.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-10-18 17:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-15 6:25 Dinesh Gandhewar
2001-10-15 6:31 ` your mail Tim Hockin
2001-10-15 6:56 ` David Ford
2001-10-15 16:02 ` Re: Timur Tabi
2001-10-18 7:32 ` *(int *)0 = 0 Riley Williams
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).