1. A not-really-important-but-still-a BUG in Eup2
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Apr 06, 1998
- 979 views
Watch this: -- Euphoria code from machine.e allocate_string () atom mem mem = allocate (length(string)) -- Or something like that poke (mem, s & 0) return mem end function -- You better redo this routine You don't want to be 'out of memory' and using allocate_string... Ralf nieuwen at xs4all.nl ICQ: 9389920 (I've finally got myself ICQ again, this time on my new PII-MMX with Ati 3D Rage Pro & 32 MB sdRAM 8-) (I know, I know, I'm being stupid, just had to tell ya all, maybe my age or something)
2. Re: A not-really-important-but-still-a BUG in Eup2
- Posted by Daniel Berstein <danielberstein at USA.NET> Apr 07, 1998
- 971 views
>Watch this: > >-- Euphoria code from machine.e allocate_string () >atom mem > > mem = allocate (length(string)) -- Or something like that > poke (mem, s & 0) > > return mem >end function > >-- You better redo this routine > >You don't want to be 'out of memory' and using allocate_string... I don't understand the bug. From your example I see you poked length(string)+1 bytes on a length(string) buffer. That's a programmers error, not an Euphoria bug. Oops! I just read the intro line of the code... Rob, that's a programmers error... Eagle eye Ralf! Regards, Daniel Berstein.
3. Re: A not-really-important-but-still-a BUG in Eup2
- Posted by Pete Eberlein <xseal at HARBORSIDE.COM> Apr 06, 1998
- 965 views
This is pasted directly from the Euphoria 2.0 machine.e: global function allocate_string(sequence s) -- create a C-style null-terminated string in memory atom mem mem = allocate(length(s) + 1) poke(mem, s & 0) return mem end function No bug... -- _____ _____ _____ ________ /\ \ /\ \ /\ \ / \ \ / \____\ / \____\ / \____\ / _ \____\ / / ___/_ / /____/ / / ___/_ / / \ |____|/ / /\____\ / \ \ / / /\____\ \ \_/ / / \ \/ / ___/_\ \ \ \ \/ / ___/_ \ /____/ \ / /\ \\/\ \ \ \ / /\ \ \ \ \ \ \/ \____\ \ \ \ \ \/ \____\ \ \ \ \ / / \ \____\ \ / / \ \____\ \ / / \ / / \ / / \ / / \ / / \/____/ \ / / \/____/ \/____/xseal at harborside.com\/____/
4. Re: A not-really-important-but-still-a BUG in Eup2
- Posted by Greg Harris <blackdog at CDC.NET> Apr 06, 1998
- 975 views
- Last edited Apr 07, 1998
-----Original Message----- From: Daniel Berstein <danielberstein at USA.NET> To: Multiple recipients of list EUPHORIA <EUPHORIA at MIAMIU.ACS.MUOHIO.EDU> Date: Monday, April 06, 1998 8:02 PM Subject: Re: A not-really-important-but-still-a BUG in Eup2 >>Watch this: --snip-- >I don't understand the bug. From your example I see you poked >length(string)+1 bytes on a length(string) buffer. That's a programmers >error, not an Euphoria bug. Here is the code from machine.e: global function allocate_string(sequence s) -- create a C-style null-terminated string in memory atom mem mem = allocate(length(s) + 1) poke(mem, s & 0) return mem end function The "bug" lies in the fact that the variable mem is not checked to see if it was able to be allocated (mem != 0)before sequence s is poked into memory. The code should have been written like this (for example): global function allocate_string(sequence s) -- create a C-style null-terminated string in memory atom mem mem = allocate(length(s) + 1) if mem != 0 then poke(mem, s & 0) end if return mem end function It now checks to see if the string can be allocated. If it can, it pokes then sequence into memory and returns the address. If it cannot allocate the string, function returns 0. I think that was the bug Ralf was taking about.?. Regards, Greg Harris
5. Re: A not-really-important-but-still-a BUG in Eup2
- Posted by Daniel Berstein <danielberstein at USA.NET> Apr 07, 1998
- 958 views
- Last edited Apr 08, 1998
Oops again! Sorry RDS for my miscomprehension of Ralf's declared pseudo-bug. Anyway, Ralf's original code did present the problem I issued, and the quote I post was relevant to the point. Maybe my participation on this thread wasn't over the actual point Ralf wanted to present, but it may help beginners to be aware of the problems "uncontrolled" memory pointers can cause. Regards, Daniel Berstein.
6. Re: A not-really-important-but-still-a BUG in Eup2
- Posted by Robert Craig <rds at EMAIL.MSN.COM> Apr 07, 1998
- 974 views
re: allocate_string() Thanks Ralf and others for bringing this to my attention. The modification suggested by Greg Harris looks like a good idea. Regards, Rob Craig Rapid Deployment Software
7. Re: A not-really-important-but-still-a BUG in Eup2
- Posted by "Graeme." <hmi at POWERUP.COM.AU> Apr 07, 1995
- 983 views
>ICQ: 9389920 >(I've finally got myself ICQ again, this time on my new PII-MMX with Ati 3D >Rage Pro & 32 MB sdRAM 8-) >(I know, I know, I'm being stupid, just had to tell ya all, maybe my age or >something) Where do you get all this money?