Ahmed Sayeed <ahmedsayeed1...@yahoo.com> added the comment:
gdb: fix value_subscript when array upper bound is not known http://www-look-4.com/category/health/ Since commit 7c6f27129631 ("gdb: make get_discrete_bounds check for https://komiya-dental.com/category/crypto/ non-constant range bounds"), subscripting flexible array member fails: http://www.iu-bloomington.com/category/health/ struct no_size { https://waytowhatsnext.com/category/health/ int n; int items[]; }; http://www.wearelondonmade.com/category/health/ (gdb) p *ns $1 = {n = 3, items = 0x5555555592a4} (gdb) p ns->items[0] http://www.jopspeech.com/category/health/ Cannot access memory at address 0xfffe555b733a0164 (gdb) p *((int *) 0x5555555592a4) $2 = 101 <--- we would expect that http://joerg.li/category/health/ (gdb) p &ns->items[0] $3 = (int *) 0xfffe5559ee829a24 <--- wrong address http://connstr.net/category/health/ Since the flexible array member (items) has an unspecified size, the array type https://www.mktrade.fi/muottivalmistus created for it in the DWARF doesn't have dimensions (this is with gcc 9.3.0, http://embermanchester.uk/category/health/ Ubuntu 20.04): http://www.slipstone.co.uk/category/health/ 0x000000a4: DW_TAG_array_type DW_AT_type [DW_FORM_ref4] (0x00000038 "int") http://fishingnewsletters.co.uk/property/suluada/ DW_AT_sibling [DW_FORM_ref4] (0x000000b3) http://www.logoarts.co.uk/category/health/ 0x000000ad: DW_TAG_subrange_type DW_AT_type [DW_FORM_ref4] (0x00000031 "long unsigned int") http://www.acpirateradio.co.uk/category/health/ This causes GDB to create a range type (TYPE_CODE_RANGE) with a defined http://www.go-mk-websites.co.uk/health/tipaza-province/ constant low bound (dynamic _prop with kind PROP_CONST) and an undefined high bound (dynamic_prop with kind PROP_UNDEFINED). http://www.compilatori.com/category/health/ value_subscript gets both bounds of that range using get_discrete_bounds. Before commit 7c6f27129631, get_discrete_bounds http://www.mconstantine.co.uk/health/shanghai/ didn't check the kind of the dynamic_props and would just blindly read them as if they were PROP_CONST. https://www.webb-dev.co.uk/category/health/ It would return 0 for the high bound, because we zero-initialize the range_bounds structure. And it didn't really matter in this case, because the returned high bound wasn't used in the end. ---------- components: +Argument Clinic nosy: +ahmedsayeed1982, larry -benjamin.peterson, vstinner, zufuliu versions: +Python 3.7 -Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39926> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com