test/parser.py fails on my port: any clue how to debug this?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
pulkin
Posts: 44
Joined: Tue Feb 19, 2019 10:22 pm

test/parser.py fails on my port: any clue how to debug this?

Post by pulkin » Sat Mar 07, 2020 6:30 pm

The test with "compile" statements fails (i.e. it freezes the board). I traced the problem down to mp_map_lookup where mp_map_t *map becomes an invalid pointer (it is by fact 0x04 which might be just random data). This happens during another call to mp_load_name which makes me think that it is a problem with globals map. Can you guys provide any hints for debugging it? Following is the full debug output with some additional prints from m_realloc, m_realloc_maybe, mp_map_lookup, mp_load_name, mp_load_global, mp_globals_get.

Code: Select all

gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182770)
malloc 16 : 82182770
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182780)
malloc 16 : 82182780
make_function_from_raw_code 8827e69c
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182790)
malloc 16 : 82182790
mp_globals_get: result 0p82300ff0
calling function 82182790(n_args=0, n_kw=0, args=0)
Input n_args: 0, n_kw: 0
Input pos args: 0: 
Input kw args: 0: 
gc_alloc(36 bytes -> 3 blocks)
gc_alloc(821827a0)
malloc 36 : 821827a0
Calling: n_pos_args=0, n_kwonly_args=0
821827c4: 
821827b4: 0 0 0 0 
mp_globals_get: result 0p82300ff0
import name 'os' level=0
__import__:
  'os'
  None
  None
  None
  0
mp_map_lookup: map 82300fa0 lookup_kind 0 is_fixed 0
mp_map_lookup: map 88279044 lookup_kind 0 is_fixed 1
Module not yet loaded
Processing module: os
Previous path: ==
stat os: 0
stat /lib/os: 0
stat //os: 0
Current path: //os.mpy
mp_map_lookup: map 88279050 lookup_kind 0 is_fixed 1
mp_map_lookup: map 882805c8 lookup_kind 0 is_fixed 1
store name os <- 8828059c
mp_map_lookup: map 82300ff4 lookup_kind 1 is_fixed 0
mp_map_rehash(82300ff4): 1 -> 2
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(821827d0)
malloc 16 : 821827d0
mp_map_lookup: map 82300ff4 lookup_kind 1 is_fixed 0
gc_free(82182750)
free 82182750
mp_load_name: name os
mp_globals_get: result 0p82300ff0
mp_load_name: looking up in globals os
load global os
mp_globals_get: result 0p82300ff0
mp_map_lookup: map 82300ff4 lookup_kind 0 is_fixed 0
load global os OK
load method 8828059c.mount
mp_map_lookup: map 882805c8 lookup_kind 0 is_fixed 1
mp_load_name: name os
mp_globals_get: result 0p82300ff0
mp_load_name: looking up in globals os
load global os
mp_globals_get: result 0p82300ff0
mp_map_lookup: map 82300ff4 lookup_kind 0 is_fixed 0
load global os OK
load attr 8828059c.internal_flash
load method 8828059c.internal_flash
mp_map_lookup: map 882805c8 lookup_kind 0 is_fixed 1
call method (fun=8827d864, self=0, n_args=2, n_kw=0, args=821827b4)
calling function 8827d864(n_args=2, n_kw=0, args=821827bc)
mp_map_lookup: map 822787f8 lookup_kind 0 is_fixed 1
mp_map_lookup: map 822787f8 lookup_kind 0 is_fixed 1
mp_obj_class_lookup: Looking up mount in internal_flash
mp_map_lookup: map 88280724 lookup_kind 0 is_fixed 1
mp_obj_class_lookup: Returning: <function>
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182750)
malloc 16 : 82182750
load method 882806c8.mount
mp_obj_class_lookup: Looking up mount in internal_flash
mp_map_lookup: map 88280724 lookup_kind 0 is_fixed 1
mp_obj_class_lookup: Returning: <function>
call method (fun=882804e4, self=0, n_args=2, n_kw=0, args=82278770)
calling function 882804e4(n_args=2, n_kw=0, args=82278778)
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(821827e0)
malloc 16 : 821827e0
gc_alloc(8 bytes -> 1 blocks)
gc_alloc(821827f0)
malloc 8 : 821827f0
load method 882806c8.stat
mp_obj_class_lookup: Looking up stat in internal_flash
mp_map_lookup: map 88280724 lookup_kind 0 is_fixed 1
mp_obj_class_lookup: Returning: <function>
call method (fun=88280574, self=0, n_args=1, n_kw=0, args=82278968)
calling function 88280574(n_args=1, n_kw=0, args=82278970)
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182800)
malloc 16 : 82182800
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(82182810)
malloc 12 : 82182810
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182820)
malloc 16 : 82182820
gc_alloc(8 bytes -> 1 blocks)
gc_alloc(82182830)
malloc 8 : 82182830
load method 882806c8.stat
mp_obj_class_lookup: Looking up stat in internal_flash
mp_map_lookup: map 88280724 lookup_kind 0 is_fixed 1
mp_obj_class_lookup: Returning: <function>
call method (fun=88280574, self=0, n_args=1, n_kw=0, args=82278968)
calling function 88280574(n_args=1, n_kw=0, args=82278970)
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182840)
malloc 16 : 82182840
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(82182850)
malloc 12 : 82182850
gc_alloc(32 bytes -> 2 blocks)
gc_alloc(82182860)
malloc 32 : 82182860

Code: Select all

MicroPython v1.11-703-g892cf5203-dirty on 2020-03-07; A9/A9G module with RDA8955
Type "help()" for more information.
>>> import parser

Code: Select all

gc_alloc(14 bytes -> 1 blocks)
gc_alloc(82182880)
malloc 14 : 82182880
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182890)
malloc 16 : 82182890
gc_alloc(84 bytes -> 6 blocks)
gc_alloc(821828a0)
malloc 84 : 821828a0
gc_alloc(20 bytes -> 2 blocks)
gc_alloc(82182900)
malloc 20 : 82182900
gc_alloc(32 bytes -> 2 blocks)
gc_alloc(82182920)
malloc 32 : 82182920
gc_alloc(512 bytes -> 32 blocks)
gc_alloc(82182940)
malloc 512 : 82182940
gc_alloc(128 bytes -> 8 blocks)
gc_alloc(82182b40)
malloc 128 : 82182b40
gc_alloc(128 bytes -> 8 blocks)
gc_alloc(82182bc0)
malloc 128 : 82182bc0
QSTR: add hash=3170 len=6 data=parser
gc_alloc(96 bytes -> 6 blocks)
gc_alloc(82182c40)
malloc 96 : 82182c40
QSTR: allocate new pool of size 20
gc_alloc(136 bytes -> 9 blocks)
gc_alloc(82182ca0)
malloc 136 : 82182ca0
gc_free(0)
free 0
m_realloc_maybe: realloc 82182ca0, 20, 2182622368 : 82182ca0
gc_free(82182940)
free 82182940
gc_free(82182b40)
free 82182b40
gc_free(82182890)
free 82182890
gc_free(82182920)
free 82182920
gc_free(82182900)
free 82182900
gc_free(821828a0)
free 821828a0
gc_alloc(48 bytes -> 3 blocks)
gc_alloc(82182890)
malloc 48 : 82182890
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(821828c0)
malloc 12 : 821828c0
gc_alloc(32 bytes -> 2 blocks)
gc_alloc(821828d0)
malloc 32 : 821828d0
gc_alloc(64 bytes -> 4 blocks)
gc_alloc(821828f0)
malloc 64 : 821828f0
gc_alloc(0 bytes -> 0 blocks)
malloc 0 : 0
gc_alloc(24 bytes -> 2 blocks)
gc_alloc(82182930)
malloc 24 : 82182930
gc_alloc(0 bytes -> 0 blocks)
malloc 0 : 0
assign byte code: code=82182930 len=0 flags=0
gc_free(0)
free 0
gc_free(821828f0)
free 821828f0
gc_free(82182ca0)
free 82182ca0
gc_free(821828d0)
free 821828d0
gc_free(82182890)
free 82182890
make_function_from_raw_code 821828c0
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182890)
malloc 16 : 82182890
mp_globals_get: result 0p82300ff0
calling function 82182890(n_args=0, n_kw=0, args=0)
Input n_args: 0, n_kw: 0
Input pos args: 0: 
Input kw args: 0: 
gc_alloc(28 bytes -> 2 blocks)
gc_alloc(821828a0)
malloc 28 : 821828a0
Calling: n_pos_args=0, n_kwonly_args=0
821828bc: 
821828b4: 0 0 
mp_globals_get: result 0p82300ff0
import name 'parser' level=0
__import__:
  'parser'
  None
  None
  None
  0
mp_map_lookup: map 82300fa0 lookup_kind 0 is_fixed 0
mp_map_lookup: map 88279044 lookup_kind 0 is_fixed 1
Module not yet loaded
Processing module: parser
Previous path: ==
load method 882806c8.stat
mp_obj_class_lookup: Looking up stat in internal_flash
mp_map_lookup: map 88280724 lookup_kind 0 is_fixed 1
mp_obj_class_lookup: Returning: <function>
call method (fun=88280574, self=0, n_args=1, n_kw=0, args=822785f8)
calling function 88280574(n_args=1, n_kw=0, args=82278600)
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(821828d0)
malloc 16 : 821828d0
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(821828e0)
malloc 12 : 821828e0
stat parser: 0
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(821828f0)
malloc 16 : 821828f0
gc_alloc(10 bytes -> 1 blocks)
gc_alloc(82182900)
malloc 10 : 82182900
load method 882806c8.stat
mp_obj_class_lookup: Looking up stat in internal_flash
mp_map_lookup: map 88280724 lookup_kind 0 is_fixed 1
mp_obj_class_lookup: Returning: <function>
call method (fun=88280574, self=0, n_args=1, n_kw=0, args=822785e0)
calling function 88280574(n_args=1, n_kw=0, args=822785e8)
gc_alloc(48 bytes -> 3 blocks)
gc_alloc(82182950)
malloc 48 : 82182950
Current path: parser.py
mp_map_lookup: map 82300fa0 lookup_kind 0 is_fixed 0
mp_map_lookup: map 88279044 lookup_kind 0 is_fixed 1
mp_map_lookup: map 82300fa0 lookup_kind 1 is_fixed 0
gc_alloc(8 bytes -> 1 blocks)
gc_alloc(82182910)
malloc 8 : 82182910
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182920)
malloc 16 : 82182920
gc_alloc(8 bytes -> 1 blocks)
gc_alloc(82182980)
malloc 8 : 82182980
mp_map_lookup: map 82182924 lookup_kind 1 is_fixed 0
gc_alloc(32 bytes -> 2 blocks)
gc_alloc(82182990)
malloc 32 : 82182990
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(821829b0)
malloc 16 : 821829b0
gc_alloc(10 bytes -> 1 blocks)
gc_alloc(821829c0)
malloc 10 : 821829c0
mp_map_lookup: map 88277938 lookup_kind 0 is_fixed 1
mp_map_lookup: map 88277938 lookup_kind 0 is_fixed 1
mp_map_lookup: map 88277938 lookup_kind 0 is_fixed 1
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(821829d0)
malloc 16 : 821829d0
gc_alloc(10 bytes -> 1 blocks)
gc_alloc(821829e0)
malloc 10 : 821829e0
load method 882806c8.open
mp_obj_class_lookup: Looking up open in internal_flash
mp_map_lookup: map 88280724 lookup_kind 0 is_fixed 1
mp_obj_class_lookup: Returning: <function>
call method (fun=882809c0, self=0, n_args=2, n_kw=0, args=822785d8)
calling function 882809c0(n_args=2, n_kw=0, args=822785e0)
mp_map_lookup: map 82278540 lookup_kind 0 is_fixed 1
mp_map_lookup: map 82278540 lookup_kind 0 is_fixed 1
gc_alloc(8 bytes -> 1 blocks)
gc_alloc(821829f0)
malloc 8 : 821829f0
QSTR: add hash=63877 len=9 data=parser.py
gc_alloc(84 bytes -> 6 blocks)
gc_alloc(82182a00)
malloc 84 : 82182a00
gc_alloc(20 bytes -> 2 blocks)
gc_alloc(82182a60)
malloc 20 : 82182a60
gc_alloc(32 bytes -> 2 blocks)
gc_alloc(82182a80)
malloc 32 : 82182a80
store attr 82182910.__file__ <- d46
mp_map_lookup: map 82182924 lookup_kind 1 is_fixed 0
mp_map_rehash(82182924): 1 -> 2
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182aa0)
malloc 16 : 82182aa0
mp_map_lookup: map 82182924 lookup_kind 1 is_fixed 0
gc_free(82182980)
free 82182980
mp_globals_get: result 0p82300ff0
gc_alloc(512 bytes -> 32 blocks)
gc_alloc(82182ca0)
malloc 512 : 82182ca0
gc_alloc(128 bytes -> 8 blocks)
gc_alloc(82182ab0)
malloc 128 : 82182ab0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
gc_alloc(136 bytes -> 9 blocks)
gc_alloc(82182b30)
malloc 136 : 82182b30
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
QSTR: add hash=44804 len=4 data=SKIP
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
m_realloc_maybe: realloc 82182b30, 156, 0 : 82182b30
m_realloc_maybe: realloc 82182b30, 128, 2182622000 : 82182b30
gc_alloc(136 bytes -> 9 blocks)
gc_alloc(82182ea0)
malloc 136 : 82182ea0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
m_realloc_maybe: realloc 82182ea0, 152, 2182622880 : 82182ea0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
m_realloc_maybe: realloc 82182ea0, 172, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 184, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 200, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 216, 2182622880 : 82182ea0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
QSTR: add hash=29971 len=2 data=\

m_realloc_maybe: realloc 82182ea0, 236, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 248, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 264, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 280, 2182622880 : 82182ea0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
m_realloc_maybe: realloc 82182ea0, 292, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 308, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 324, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 340, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 356, 2182622880 : 82182ea0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
m_realloc_maybe: realloc 82182ea0, 376, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 388, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 404, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 420, 2182622880 : 82182ea0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
m_realloc_maybe: realloc 82182ea0, 432, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 448, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 464, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 480, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 496, 2182622880 : 82182ea0
mp_map_lookup: map 822785d0 lookup_kind 0 is_fixed 0
m_realloc_maybe: realloc 82182ea0, 516, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 528, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 544, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 560, 2182622880 : 82182ea0
m_realloc_maybe: realloc 82182ea0, 596, 2182622880 : 82182ea0
gc_free(0)
free 0
m_realloc_maybe: realloc 82182ea0, 592, 2182622880 : 82182ea0
gc_free(82182ca0)
free 82182ca0
gc_free(82182ab0)
free 82182ab0
gc_free(82182990)
free 82182990
gc_free(82182a80)
free 82182a80
gc_free(82182a60)
free 82182a60
gc_free(82182a00)
free 82182a00
gc_alloc(48 bytes -> 3 blocks)
gc_alloc(82182980)
malloc 48 : 82182980
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(82182a00)
malloc 12 : 82182a00
gc_alloc(32 bytes -> 2 blocks)
gc_alloc(82182a10)
malloc 32 : 82182a10
gc_alloc(64 bytes -> 4 blocks)
gc_alloc(82182a30)
malloc 64 : 82182a30
gc_alloc(80 bytes -> 5 blocks)
gc_alloc(82182ab0)
gc_realloc(82182a10 -> 82182ab0)
gc_free(82182a10)
m_realloc: realloc 82182a10, 80 : 82182ab0
gc_alloc(64 bytes -> 4 blocks)
gc_alloc(82182ca0)
malloc 64 : 82182ca0
gc_alloc(228 bytes -> 15 blocks)
gc_alloc(82182ce0)
malloc 228 : 82182ce0
gc_alloc(0 bytes -> 0 blocks)
malloc 0 : 0
assign byte code: code=82182ce0 len=0 flags=0
gc_free(82182ca0)
free 82182ca0
gc_free(82182a30)
free 82182a30
gc_free(82182ea0)
free 82182ea0
gc_free(82182b30)
free 82182b30
gc_free(82182ab0)
free 82182ab0
gc_free(82182980)
free 82182980
make_function_from_raw_code 82182a00
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182980)
malloc 16 : 82182980
mp_globals_get: result 0p82182920
calling function 82182980(n_args=0, n_kw=0, args=0)
Input n_args: 0, n_kw: 0
Input pos args: 0: 
Input kw args: 0: 
gc_alloc(56 bytes -> 4 blocks)
gc_alloc(82182a10)
malloc 56 : 82182a10
Calling: n_pos_args=0, n_kwonly_args=0
82182a3c: 
82182a24: 0 0 0 0 0 0 
mp_globals_get: result 0p82182920
mp_load_name: name compile
mp_globals_get: result 0p82182920
mp_load_name: looking up in globals compile
load global compile
mp_globals_get: result 0p82182920
mp_map_lookup: map 82182924 lookup_kind 0 is_fixed 0
load global compile OK
mp_map_lookup: map 8827afbc lookup_kind 0 is_fixed 1
mp_load_name: name compile
mp_globals_get: result 0p82182920
mp_load_name: looking up in globals compile
load global compile
mp_globals_get: result 0p82182920
mp_map_lookup: map 82182924 lookup_kind 0 is_fixed 0
load global compile OK
mp_map_lookup: map 8827afbc lookup_kind 0 is_fixed 1
calling function 8827acf8(n_args=3, n_kw=0, args=82182a28)
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182990)
malloc 16 : 82182990
gc_alloc(84 bytes -> 6 blocks)
gc_alloc(82182ab0)
malloc 84 : 82182ab0
gc_alloc(20 bytes -> 2 blocks)
gc_alloc(82182a50)
malloc 20 : 82182a50
gc_alloc(32 bytes -> 2 blocks)
gc_alloc(82182a70)
malloc 32 : 82182a70
gc_alloc(8 bytes -> 1 blocks)
gc_alloc(821829a0)
malloc 8 : 821829a0
mp_globals_get: result 0p82182920
gc_alloc(512 bytes -> 32 blocks)
gc_alloc(82182dd0)
malloc 512 : 82182dd0
gc_alloc(128 bytes -> 8 blocks)
gc_alloc(82182b10)
malloc 128 : 82182b10
gc_free(0)
free 0
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182a90)
malloc 16 : 82182a90
gc_alloc(16 bytes -> 1 blocks)
gc_alloc(82182b90)
malloc 16 : 82182b90
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(82182ba0)
malloc 12 : 82182ba0
gc_alloc(12 bytes -> 1 blocks)
gc_alloc(82182bb0)
malloc 12 : 82182bb0
gc_alloc(24 bytes -> 2 blocks)
gc_alloc(82182ca0)
gc_realloc(82182bb0 -> 82182ca0)
gc_free(82182bb0)
m_realloc_maybe: realloc 82182bb0, 24, 2182622368 : 82182bb0
mp_load_name: name SyntaxError
mp_globals_get: result 0
mp_load_name: looking up in globals SyntaxError
load global SyntaxError
mp_globals_get: result 0
mp_map_lookup: map 4 lookup_kind 0

User avatar
jimmo
Posts: 1769
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: test/parser.py fails on my port: any clue how to debug this?

Post by jimmo » Mon Mar 16, 2020 12:42 am

pulkin wrote:
Sat Mar 07, 2020 6:30 pm
Can you guys provide any hints for debugging it?
That's going to be very hard to debug without access to a board etc.

My best guess is that because this involves the globals map and exception handling that maybe there's some issues with NLR or exception unwinding.

My second guess would be an issue with GC root pointer discovery, and something's getting cleaned up that shouldn't. Do you see issues with GC disabled?

pulkin
Posts: 44
Joined: Tue Feb 19, 2019 10:22 pm

Re: test/parser.py fails on my port: any clue how to debug this?

Post by pulkin » Thu Mar 19, 2020 10:38 pm

No, that [compiling without gc] does not help.

Is it normal for bulk tests to fail at some point without gc?

User avatar
jimmo
Posts: 1769
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: test/parser.py fails on my port: any clue how to debug this?

Post by jimmo » Fri Mar 20, 2020 2:20 am

pulkin wrote:
Thu Mar 19, 2020 10:38 pm
Is it normal for bulk tests to fail at some point without gc?
Yes.

pulkin
Posts: 44
Joined: Tue Feb 19, 2019 10:22 pm

Re: test/parser.py fails on my port: any clue how to debug this?

Post by pulkin » Sat Mar 21, 2020 6:06 pm

So what may, in principle, cause such failures? Was the pointer to globals accidentally overwritten?

User avatar
jimmo
Posts: 1769
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: test/parser.py fails on my port: any clue how to debug this?

Post by jimmo » Sun Mar 22, 2020 3:21 am

Sorry it's really hard to give advice that isn't just guessing randomly in the dark.

Do you have GDB support for your microcontroller?

I only suggested the globals thing because you mentioned the map pointer was corrupt and that I have previously debugged an issue in the native emitter that caused something that (on the surface) sounded similar, and it was due to the way it recovered the "previous globals" from storage on the stack, but that had been overwritten by something else.

pulkin
Posts: 44
Joined: Tue Feb 19, 2019 10:22 pm

Re: test/parser.py fails on my port: any clue how to debug this?

Post by pulkin » Sun Mar 22, 2020 7:12 pm

I am working on making gdb and, possibly, hardware breakpoint working. I tried doing that a couple of times already but did not really succeed. Can you point to commit fixing the issue you refer to? Maybe it is not yet in the port ...

User avatar
jimmo
Posts: 1769
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: test/parser.py fails on my port: any clue how to debug this?

Post by jimmo » Mon Mar 23, 2020 12:28 am

It's https://github.com/micropython/micropython/pull/5574 but it's almost certainly not your issue because:
- it didn't cause issues for existing tests
- it only happened when the native emitter was being used
- your port likely doesn't have a native emitter yet

I'm just using it as an example -- there are lots of things that can mess with globals.

I suggested earlier that this might be related to NLR. How did you implement NLR for your port?

pulkin
Posts: 44
Joined: Tue Feb 19, 2019 10:22 pm

Re: test/parser.py fails on my port: any clue how to debug this?

Post by pulkin » Mon Mar 23, 2020 10:26 am

Honestly saying, I have only a vague idea how nlr works and what has to be implemented by the port. I inherited it from whoever started porting mpy to the module. Here is the code:

https://github.com/pulkin/micropython/t ... ts/gprs_a9

pulkin
Posts: 44
Joined: Tue Feb 19, 2019 10:22 pm

Re: test/parser.py fails on my port: any clue how to debug this?

Post by pulkin » Thu Mar 26, 2020 6:46 pm

Code: Select all

>>> compile("", "stdin", "eval")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "stdin", line 2
SyntaxError: invalid syntax
>>> compile("", "stdin", "eval")
(module halts)

Post Reply