You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
try/except leads to infinite loop with growing memory usage #1
Running a following script (./py exc.py) leads to an infinite loop with a growing memory usage (i.e. uPy keeps allocating something in an infinite loop):
There is currently no memory manager (no garbage collection) for the unix version, so that's why it eats memory. But it's certainly a bug that it runs an infinite loop.
Thanks for quick response, hope it doesn't steal cycles from hardware hacking ;-). (Though this particular issue is important enough, so I really appreciate looking into it).
Well, exception-throwing path now works (including on x86/32bit, will submit patch once cleaned up), but exception-free path leads to:
a = {1:2}
try:
a[1]
except KeyError:
print("caught")
Yep, it's not fully implemented. Micro Python doesn't use reference counting (like CPython) so the action of push/pop blocks in the interpreter is a bit simpler for Micro Python. Thus, the byte code POP_BLOCK is probably only needed when exiting an exception handling block.
Yes, confirmed working. Let's close and track finally/with somewhere else then. (Note that I didn't try to find which Python features don't work, just read that "It works only for 64-bit machines due to a small piece of x86-64 assembler for
the exception handling.", so after building for x86, I proceeded to test exactly exception handling ;-) ).
By "exception handling" I actually meant the underlying C exception handling that I'm using (nlr_jump). You don't see it, but it's working when you get a Python error, eg at the command line just type "foo" and it'll give you a NameError. That's using nlr_jump, written in assembler.
Activity
dpgeorge commentedon Dec 29, 2013
There is currently no memory manager (no garbage collection) for the unix version, so that's why it eats memory. But it's certainly a bug that it runs an infinite loop.
dpgeorge commentedon Dec 29, 2013
Added proper nested exception handling, and basic exception type matching. Above code should now work.
pfalcon commentedon Dec 29, 2013
Thanks for quick response, hope it doesn't steal cycles from hardware hacking ;-). (Though this particular issue is important enough, so I really appreciate looking into it).
Well, exception-throwing path now works (including on x86/32bit, will submit patch once cleaned up), but exception-free path leads to:
Corresponding opcode doesn't appear to be implemented.
dpgeorge commentedon Dec 29, 2013
Yep, it's not fully implemented. Micro Python doesn't use reference counting (like CPython) so the action of push/pop blocks in the interpreter is a bit simpler for Micro Python. Thus, the byte code POP_BLOCK is probably only needed when exiting an exception handling block.
dpgeorge commentedon Dec 29, 2013
Okay, it should now work. There will still be issues with "finally" and "with" blocks.
pfalcon commentedon Dec 29, 2013
Yes, confirmed working. Let's close and track finally/with somewhere else then. (Note that I didn't try to find which Python features don't work, just read that "It works only for 64-bit machines due to a small piece of x86-64 assembler for
the exception handling.", so after building for x86, I proceeded to test exactly exception handling ;-) ).
dpgeorge commentedon Dec 29, 2013
By "exception handling" I actually meant the underlying C exception handling that I'm using (nlr_jump). You don't see it, but it's working when you get a Python error, eg at the command line just type "foo" and it'll give you a NameError. That's using nlr_jump, written in assembler.
Merge pull request micropython#1 from micropython/master
atmel-samd: Support raw repl and soft reset to support ampy.
Merge pull request #1 from ajbaabf/nrf5_no_sdk
Merge pull request micropython#1 from arofarn/patch-1
Merge pull request micropython#1 from adafruit/master
Merge pull request micropython#1 from bwshockley/D51G18A
19 remaining items
Merge pull request micropython#1 from ChenxiXiao/ChenxiXiao-ZH_PINYIN
Attempt micropython#1 to build a release workflow
Merge pull request micropython#1 from MakerM0/magiclick_s3_n4r2
Merge pull request micropython#1 from mariopesch/add-sensebox-mcus2
Merge pull request micropython#1 from Erasertm/board-support-for-vidi-x
Merge pull request micropython#1 from deisterhold/lilygo-tdongle-s3
Merge pull request micropython#1 from adafruit/main
builtinimport: Fix a crash with 'import ulab.linalg' on unix port only
Merge pull request micropython#1 from tannewt/UM_S2_Boards
sharpdisplay: Fix memory corruption across soft-reset
Merge pull request micropython#1 from adafruit/main
Merge pull request micropython#1 from CoffeeTronics/patch-1
Fix 3 bugs in arbitrary precision integer division (mpz.c)
py/repl: Don't read past the end of import_str.