ubports / ubuntu-ui-toolkit

Moved to https://gitlab.com/ubports/core/lomiri-ui-toolkit
https://gitlab.com/ubports/core/lomiri-ui-toolkit
GNU Lesser General Public License v3.0
13 stars 21 forks source link

apicheck segfaults when compiled with Qt 5.9.5 #26

Closed UniversalSuperBox closed 5 years ago

UniversalSuperBox commented 5 years ago

This issue is going to be a bit of a brain dump as I've been working at it for a few hours and I'm only a little further than when I started.

As can be seen in recent build output, the apicheck binary segfaults after being called on Extinct.Animals. Since this prevents tests from finishing, we are unable to merge any pull requests right now.

I've been trying to debug this issue for a few hours. TL;DR: We're corrupting our heap for a QQmlType, replacing its QQmlTypePrivate named d's name attribute, maybe more:

(gdb) print thisQmlType->d->name
$8 = {static null = {<No data fields>}, d = 0x61}

I feel like I'm close to finding the issue, since looking at a data structure closer to the beginning of the private object nets us...

p thisQmlType->d->extraData
$18 = {cd = 0x3, sd = 0x3, fd = 0x3}

In case it's helpful, here's the valgrind output

mardy commented 5 years ago

Try printing the string in apicheck.cpp:169

UniversalSuperBox commented 5 years ago

As discussed off-issue, that's exactly what segfaults.

Reading the valgrind output again, it looked like the typeFormat QString creation just a bit before the illegal call was causing a value to be written a little too close to the problem memory, so I changed typeFormat to just an empty QString. Now the new valgrind output says Use of uninitialised value of size 8. Progress!

UniversalSuperBox commented 5 years ago

This is fixed in d85ab399d0a97d035ad473aa4449f631151e6566, but I will keep the issue open until a PR with it is merged.