> Where the heck did you get idea?
By reading the man page in the middle of the night and reading
realloc() as malloc().
My error.
> -hpa
Igmar
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read
Where the heck did you get idea?
By reading the man page in the middle of the night and reading
realloc() as malloc().
My error.
-hpa
Igmar
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read
On Wed, Nov 08, 2000 at 02:11:34PM -0800, H. Peter Anvin wrote:
> Followup to: <[EMAIL PROTECTED]>
> By author:Igmar Palsenberg <[EMAIL PROTECTED]>
> In newsgroup: linux.dev.kernel
[snip]
> > May I remind you guys that a malloc(0) is equal to a free(). There is no
> > way that any mem
Followup to: <[EMAIL PROTECTED]>
By author:Igmar Palsenberg <[EMAIL PROTECTED]>
In newsgroup: linux.dev.kernel
>
>
> > The program does not work. A program works if it does what it's supposed to
> > do. If you want to argue that this program is supposed to print "ff"
> > then
On Tue, 7 Nov 2000, Tim Waugh wrote:
> On Wed, Nov 08, 2000 at 01:41:40AM +0100, Igmar Palsenberg wrote:
>
> > malloc(0) is bogus in this case. malloc(0) == free();
>
> No, you're thinking of realloc.
Yep. My error. Sorry.
Igmar
-
To unsubscribe from this list: send the line
On Tue, 7 Nov 2000, Tim Waugh wrote:
On Wed, Nov 08, 2000 at 01:41:40AM +0100, Igmar Palsenberg wrote:
malloc(0) is bogus in this case. malloc(0) == free();
No, you're thinking of realloc.
Yep. My error. Sorry.
Igmar
-
To unsubscribe from this list: send the line "unsubscribe
Followup to: [EMAIL PROTECTED]
By author:Igmar Palsenberg [EMAIL PROTECTED]
In newsgroup: linux.dev.kernel
The program does not work. A program works if it does what it's supposed to
do. If you want to argue that this program is supposed to print "ff"
then explain to me why
On Wed, Nov 08, 2000 at 02:11:34PM -0800, H. Peter Anvin wrote:
Followup to: [EMAIL PROTECTED]
By author:Igmar Palsenberg [EMAIL PROTECTED]
In newsgroup: linux.dev.kernel
[snip]
May I remind you guys that a malloc(0) is equal to a free(). There is no
way that any mem get's malloced.
On Wed, Nov 08, 2000 at 01:41:40AM +0100, Igmar Palsenberg wrote:
> malloc(0) is bogus in this case. malloc(0) == free();
No, you're thinking of realloc.
Tim.
*/
PGP signature
> This way all should work. However someone mentioned that the returns
> from "malloc" should be unique. Why would that be? That would prohibit
> my "1" trick. The statement implies you want to go about checking
> pointers for equality. If for example you have a memcmp (a, b) that
> has "if (a
Matti Aarnio wrote:
> needed size is bound to get user burned. malloc(0) is insane thing
> (IMO), but at least glibc supports it for some reason. Likely just due
> to padding and minimum size issues.
Part of the desing of the C language and the library is intended to
make boundary conditions
On Tue, 7 Nov 2000, Lyle Coder wrote:
> When a program does a malloc... the glibc gets atleast on page (brk)
> [actually, glibs determins of it needs to brk more memory from the kernel...
> because it maintains it;s own pool].. so if you malloc 4 byts, you can copy
> to that pointer more than 4
> The program does not work. A program works if it does what it's supposed to
> do. If you want to argue that this program is supposed to print "ff"
> then explain to me why the 'malloc' contains a zero in parenthesis.
>
> The program can't possibly work because it invokes
> I'm not sure that is fully responsive, Dan. Why doesn't the
> strcpy throw a hissyfit and coredump?
Because he's a lucky guy and doesn't cross a page boundary. If the
"" thing is the entire Wind95 source code it will dump :-)
> {^_^}
Igmar
-
To unsubscribe from this list: send
On Mon, 6 Nov 2000, RAJESH BALAN wrote:
> hi,
> why does this program works. when executed, it doesnt
> give a segmentation fault. when the program requests
> memory, is a standard chunk is allocated irrespective
> of the what the user specifies. please explain.
>
> main()
> {
>char *s;
>
> > > main()
> > > {
> > >char *s;
> > >s = (char*)malloc(0);
> > >strcpy(s,"f");
> > >printf("%s\n",s);
> > > }
I rather suspect that the strcpy() scribbled over malloc()s record keeping
data. However, that memory was in the processes allowed address space so
it didn't
>
> > hi,
> > why does this program works. when executed, it doesnt
> > give a segmentation fault. when the program requests
> > memory, is a standard chunk is allocated irrespective
> > of the what the user specifies. please explain.
> >
> > main()
> > {
> >char *s;
> >s =
As long as you don't try to do any more mm once you've allocated with
malloc(0), and as long as you haven't done any previous allocations with
malloc, you should be able to scribble all over malloc. In fact, if you
want, I think you can scribble all over your own stack without causing
Linux
> > The program can't possibly work because it invokes undefined
> behavior. It
> > is impossible to determine what a program that invokes
> undefined behavior is
> > 'supposed to do'.
>
> I dont think it's undefined behaviour ...
You are correct. This is bahavior that is undefined by
On Tue, Nov 07, 2000 at 12:09:09AM -0800, Lyle Coder wrote:
> When a program does a malloc... the glibc gets atleast on page (brk)
> [actually, glibs determins of it needs to brk more memory from the kernel...
> because it maintains it;s own pool].. so if you malloc 4 byts, you can copy
> to that
Hello ,
> > why does this program works. when executed, it doesnt
> > give a segmentation fault. when the program requests
> > memory, is a standard chunk is allocated irrespective
> > of the what the user specifies. please explain.
> >
> > main()
> > {
> >char *s;
> >s =
that
answers one of your questions... as far as why malloc(0) works... I dunno
Best Wishes,
Lyle
- Original Message -
From: "David Schwartz" <[EMAIL PROTECTED]>
To: "RAJESH BALAN" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, November 06, 2000 11:54 P
As long as you don't try to do any more mm once you've allocated with
malloc(0), and as long as you haven't done any previous allocations with
malloc, you should be able to scribble all over malloc. In fact, if you
want, I think you can scribble all over your own stack without causing
Linux
hi,
why does this program works. when executed, it doesnt
give a segmentation fault. when the program requests
memory, is a standard chunk is allocated irrespective
of the what the user specifies. please explain.
main()
{
char *s;
s = (char*)malloc(0);
main()
{
char *s;
s = (char*)malloc(0);
strcpy(s,"f");
printf("%s\n",s);
}
I rather suspect that the strcpy() scribbled over malloc()s record keeping
data. However, that memory was in the processes allowed address space so
it didn't SIGSEGV. Now, when you
On Mon, 6 Nov 2000, RAJESH BALAN wrote:
hi,
why does this program works. when executed, it doesnt
give a segmentation fault. when the program requests
memory, is a standard chunk is allocated irrespective
of the what the user specifies. please explain.
main()
{
char *s;
s =
I'm not sure that is fully responsive, Dan. Why doesn't the
strcpy throw a hissyfit and coredump?
Because he's a lucky guy and doesn't cross a page boundary. If the
"" thing is the entire Wind95 source code it will dump :-)
{^_^}
Igmar
-
To unsubscribe from this list: send
The program does not work. A program works if it does what it's supposed to
do. If you want to argue that this program is supposed to print "ff"
then explain to me why the 'malloc' contains a zero in parenthesis.
The program can't possibly work because it invokes undefined
On Tue, 7 Nov 2000, Lyle Coder wrote:
When a program does a malloc... the glibc gets atleast on page (brk)
[actually, glibs determins of it needs to brk more memory from the kernel...
because it maintains it;s own pool].. so if you malloc 4 byts, you can copy
to that pointer more than 4
Matti Aarnio wrote:
needed size is bound to get user burned. malloc(0) is insane thing
(IMO), but at least glibc supports it for some reason. Likely just due
to padding and minimum size issues.
Part of the desing of the C language and the library is intended to
make boundary conditions go
This way all should work. However someone mentioned that the returns
from "malloc" should be unique. Why would that be? That would prohibit
my "1" trick. The statement implies you want to go about checking
pointers for equality. If for example you have a memcmp (a, b) that
has "if (a == b)
On Wed, Nov 08, 2000 at 01:41:40AM +0100, Igmar Palsenberg wrote:
malloc(0) is bogus in this case. malloc(0) == free();
No, you're thinking of realloc.
Tim.
*/
PGP signature
> hi,
> why does this program works. when executed, it doesnt
> give a segmentation fault. when the program requests
> memory, is a standard chunk is allocated irrespective
> of the what the user specifies. please explain.
>
> main()
> {
>char *s;
>s = (char*)malloc(0);
>
> From: "Dan Kegel" <[EMAIL PROTECTED]>
> > [EMAIL PROTECTED] asked:
> > > [Why does this program not crash?]
> > >
> > > main()
> > > {
> > >char *s;
> > >s = (char*)malloc(0);
> > >strcpy(s,"f");
> > >printf("%s\n",s);
> > > }
> >
> > It doesn't crash because the standard
From: "Dan Kegel" <[EMAIL PROTECTED]>
> [EMAIL PROTECTED] asked:
> > [Why does this program not crash?]
> >
> > main()
> > {
> >char *s;
> >s = (char*)malloc(0);
> >strcpy(s,"f");
> >printf("%s\n",s);
> > }
>
> It doesn't crash because the standard malloc is
>
[EMAIL PROTECTED] asked:
> [Why does this program not crash?]
>
> main()
> {
>char *s;
>s = (char*)malloc(0);
>strcpy(s,"f");
>printf("%s\n",s);
> }
It doesn't crash because the standard malloc is
optimized for speed, not for finding bugs.
Try linking it with a
hi,
why does this program works. when executed, it doesnt
give a segmentation fault. when the program requests
memory, is a standard chunk is allocated irrespective
of the what the user specifies. please explain.
main()
{
char *s;
s = (char*)malloc(0);
strcpy(s,"f");
hi,
why does this program works. when executed, it doesnt
give a segmentation fault. when the program requests
memory, is a standard chunk is allocated irrespective
of the what the user specifies. please explain.
main()
{
char *s;
s = (char*)malloc(0);
strcpy(s,"f");
38 matches
Mail list logo