Closed abstraktor closed 9 years ago
what is the issue?
It raises a MemoryError. I assume that for yet undetermined reasons size is larger (needs a long) than chunk.size but instead of simply keeping the list or copying it, the MemoryError appears.
When the python code is interpreted instead of translated, the overgrown size value does not appear at all and no MemoryErrors occur.
Why len(chunk.data) != size
and not len(chunk.data) >= size
, btw?
Actually, the only reason to assume that chunk.size is indeed smaller than size in this case is that allocating a list with a length that is > 2**31 would throw a MemoryError in the first place and not when trying to slice it.
Reply to !=
vs. >=
: the code omitted here before should make sure that len(chunk.data) can only exceed or equal size usually (it is actually a rounding up for 64bit alignment).
Fwiw:
(RSqueak is 32bit only, still)
Ah, sorry. Then indeed you're doing "chunk.data[:size]", where size is probably a "r_ulonglong". It gets converted to a signed 32-bit number, which for a number like 700000000000 gives a negative result. But the RPython annotator "proved" that the size cannot be negative here (because it is ulonglong). It confuses the resulting code a lot.
Don't try to use slicing with numbers that are so huge. RPython would normally give a runtime error if you try to slice with a number larger than the length of the string (at least when compiled in lldebug mode), but in this case it's probably fooled by the fact that the number becomes negative.
@abstraktor: in #pypy arigo suggested building with --lldebug to see if any assertions are violated. But the lldebug build result does not play nicely with the Windows C library here, so I would appreciate you taking this over.
On the other hand I will try to make sure that those bogus size values do not appear at all. ;-)
Any progress?
The bogus size values have been fixed, so the problem no longer occurs. We were only curious about the behavior after translation back in these days.
This python code
translates with rpython to that c: