Comments (8)
I see you're using Ubuntu; which version do you have, so I can replicate?
from micropython.
OS is
ubuntu 13.04 (GNU/Linux 3.8.0-34-generic x86_64)
gcc --version gives
gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
from micropython.
just as a side note. It seems the stack trace made github markdown go crazy and link this post with others. I tried to edit by putting a code fence block around the stack trace, but the links are still there.
from micropython.
Yes, this is a bug. It doesn't crash for me, but prints the wrong number (10 times).
If you want to try and fix it, enable debug output in runtime.c, at line 20. Then run the example again.
from micropython.
I can confirm that the above program listing will segfault on ubuntu 12.04 using GCC.
Using that setup, with the runtime.c debug output, I get:
store name test <- 0x94da7e0
assign byte code: id=1 code=0x94daca8 len=36 n_args=0
00 90 02 25 27 13 0a 00 80 92 01 52 92 01 35 2c
25 2c 52 53 0c 00 35 2d 25 26 25 2d 92 01 42 45
f1 7f 11 80
(NUM_LOCAL 0)
00 MAKE_FUNCTION 2
02 LOAD_NAME range
04 LOAD_CONST_SMALL_INT 10
08 CALL_FUNCTION n=1 nkw=0
10 GET_ITER
11 CALL_FUNCTION n=1 nkw=0
13 STORE_NAME gen
15 LOAD_NAME gen
17 GET_ITER
18 FOR_ITER 33
21 STORE_NAME i
23 LOAD_NAME print
25 LOAD_NAME i
27 CALL_FUNCTION n=1 nkw=0
29 POP_TOP
30 JUMP 18
33 LOAD_CONST_NONE
34 RETURN_VALUE
assign byte code: id=2 code=0x94dac68 len=14 n_args=1
00 20 53 07 00 31 21 82 42 45 f6 7f 11 80
(NUM_LOCAL 0)
00 LOAD_FAST_0
01 FOR_ITER 11
04 STORE_FAST_1
05 LOAD_FAST_1
06 YIELD_VALUE
07 POP_TOP
08 JUMP 1
11 LOAD_CONST_NONE
12 RETURN_VALUE
make_function_from_id 1
calling function 0x94dbfc8(n_args=0, args=(nil))
make_function_from_id 2
load name range
calling function 0x94daa68(n_args=1, args=0xbf819d3c)
calling function 0x94dac18(n_args=1, args=0xbf819d40)
store name gen <- 0x94dc038
load name gen
store name i <- (nil)
load name print
load name i
calling function 0x94daa50(n_args=1, args=0xbf819d3c)
Segmentation fault
from micropython.
And interestingly enough, changing the generator function in the original code to
gen = (1*i for i in range(10))
results in a successful test, returning 0 through 9 as expected.
from micropython.
Also, using the list comprehension, as:
gen = [i for i in range(10)]
will work just fine and dandy. For some reason, it just doesn't like the naked variable sitting there without something happening to it.
Update: go figure while I'm digging around that you fix it. :-)
from micropython.
It was a pretty nasty bug: I allocated enough memory for the state of the generator (to hold local variables and the stack), but I initialised the stack pointer to the last element, when it should be initialised to the position just after the last element of the state. This is because the stack is pre-decrement
Sorry if I spoiled your fun!
from micropython.
Related Issues (20)
- Renesas-RA: Pin-IRQ does not behave as expected. HOT 5
- MQTTS fail on ESP32-S3 but works in ESP32
- Cannot instantiate FrameBuffer from a bytes object HOT 9
- Build errors when building RPI_PICO for debug HOT 1
- mpremote cannot cat with recent MP on pyboard HOT 4
- asyncio module seems missing in self built firmware for ESP8266 board HOT 6
- nimble compile errors HOT 2
- ESP32-S3 Linking errors HOT 5
- esp32 wroom - guru meditation - socket accept (?) HOT 1
- esp32 - mDNS not working HOT 1
- rp2 - mDNS not working HOT 1
- rp2: Nonsense REPL input on Linux due to tty serial input echo race HOT 16
- docs: WLAN module, undocumented methods
- mpremote mount chdir() in mount fails after second call HOT 5
- STM32F407+MII+DP83848 not working properly HOT 20
- ESP32 SPIRAM IRAM overflow HOT 1
- ESP32 Outputting Garbage in REPL HOT 1
- ValueError: incompatible .mpy file HOT 2
- Raspberry Pi Pico _thread OSError: TinyUSB callback can't recurse HOT 5
- array: Add typecode property HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropython.