Post Reply 
newRPL: Alpha demo 0.9 released [UPDATED 2017-10-25]
11-05-2017, 12:48 AM
Post: #232
RE: newRPL: Alpha demo 0.9 released [UPDATED 2017-10-25]
(11-04-2017 04:31 PM)Gilles59 Wrote:  This program get "out of memory" error both on the calc or emulateur with more loops (change 1000 with 10000 or more). The limit is highter with the emulator.

EDIT : the same program with a MEM DROP after ΠLIST works without problem...

Thanks for the report. This one was a tough bug. UTF8-> was to blame.
This is a corner case I've never thought of, and I'll have to review all the commands to make sure it isn't happening anywhere else.
The bug itself (for those interested, others feel free to skip the technical details) is quite simple but very hard to catch: newRPL has pointers that are automatically updated during GC, so the code doesn't have to worry if a memory block moves. In this case, there were 2 pointers: one to the character being processed by UTF8, and one to the end of the string, used only to compare and end the loop.
Turns out that the end-of-string pointer actually points to the byte after the end of the string, but that's just outside the block of memory allocated for the string. When the garbage collector moved the block, that end pointer didn't move with the string, since it was pointing into the next object, which was moved to a different location.
With the pointers now separated in memory, the UTF8-> loop was processing more than 59000 characters, and running out of memory trying to create that huge list.

It's a simple fix, the end pointer needs to point to the last used byte, to make sure it's within the same object and gets moved together with the object.
But now I wonder in how many other places this is happening in the code... it'll take me a few days to review all libraries.

Thanks a lot for the report, this one was an eye opener.
Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: newRPL: Alpha demo 0.9 released [UPDATED 2017-10-25] - Claudio L. - 11-05-2017 12:48 AM

User(s) browsing this thread: 1 Guest(s)