From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0856A385800E; Sat, 9 Oct 2021 11:00:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0856A385800E From: "gulsenenginar at aol dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/26901] Array subscript fails with flexible array member without size Date: Sat, 09 Oct 2021 11:00:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 10.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gulsenenginar at aol dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: 10.2 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Oct 2021 11:00:40 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26901 Gulsen Engin changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gulsenenginar at aol dot c= om --- Comment #12 from Gulsen Engin --- 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/=20 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 =3D {n =3D 3, items =3D 0x5555555592a4} (gdb) p ns->items[0] http://www.jopspeech.com/category/health/ Cannot access memory at address 0xfffe555b733a0164 (gdb) p *((int *) 0x5555555592a4) $2 =3D 101 <--- we would expect that http://joerg.li/category/heal= th/ (gdb) p &ns->items[0] $3 =3D (int *) 0xfffe5559ee829a24 <--- wrong address http://connstr.net/category/health/ Since the flexible array member (items) has an unspecified size, the ar= ray type 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") 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 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 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. https://pro-sangyoui.com/ https://fintechzoom.com/reviews/15-best-water-bottles-of-2021/ https://fintechzoom.com/reviews/10-best-yoga-mats-of-2021/ https://wikifinancepedia.com/ https://financeplusinsurance.com/ https://financeinsuranceblog.com/ https://fintechzoom.com/reviews/the-greatest-robot-vacuums-for-assure-clean= er-floors/ https://fintechzoom.com/reviews/the-11-best-air-purifiers-in-2021/ https://fintechzoom.com/reviews/the-6-best-cordless-stick-vacuum-in-2021/ https://amazon.com/Christopher-Horne/e/B08D6C1D2P%3Fref=3Ddbs_a_mng_rwt_scn= s_share https://nhacai888b.com/ https://www.soicau888.net/ https://kaiyokukan.vn/ http://twin688.net/ https://typhu88.me/ https://fitveform.com/ https://www.thegamblinggurus.com/ https://nodepositpokeronline.com/ https://onlinecasinoku.com/ https://slickcashloanca.blogspot.com/ https://www.aaz-credit-immobilier.com/ https://www.sport-trader.com/ https://www.lespersiennes.com/ https://www.espresso-international.it/ https://www.espresso-international.fi/ https://footballexpress.in/category/indian-football/ https://sixsports.in/category/cricket/ https://true-tech.net/ https://www.alivechristians.com/bible-verses-about-healing-sickness/ https://photoslate.co/ https://trellising-net.com/ https://www.seminariostop.com/seminarios-y-talleres/como-importar-de-china-= alibaba-aliexpress-dropshipping-peru/ https://bestonlinegambler.com/ https://vipcasinotips.com/ https://casinogamblingideas.com/ https://realmoneycasinoguides.com/ https://casinoexpertadvice.com/ https://komopoker5.com/ https://zehabesha.com/ --=20 You are receiving this mail because: You are on the CC list for the bug.=