Is this a programming error, or a compiler error..
Dimitry Andric
dim at FreeBSD.org
Wed Mar 13 12:17:07 UTC 2019
On 13 Mar 2019, at 12:57, Willem Jan Withagen <wjw at digiware.nl> wrote:
>
> I'm getting a crash in a Ceph test program in the following pice of code:
>
> struct entity_addrvec_t {
> vector<entity_addr_t> v;
> .....
> entity_addr_t legacy_addr() const {
> for (auto& a : v) {
> if (a.type == entity_addr_t::TYPE_LEGACY) {
> return a;
> }
> }
> return entity_addr_t();
> }
> ......
>
> Where the loop is taken, even if v.size() == 0
> So v content is pointing to random memory and itterating over the next pointer results in a crash.
This can happen when the vector is invalidated, due to either it, or its
parent object having been moved from. Maybe run this under valgrind or
AddressSanitizer, that should give some more clues.
-Dimitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 223 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freebsd.org/pipermail/freebsd-toolchain/attachments/20190313/d4868388/attachment.sig>
More information about the freebsd-toolchain
mailing list