[Development] It could be a little bug

Thiago Macieira thiago.macieira at intel.com
Mon Nov 4 17:14:39 CET 2013


On segunda-feira, 4 de novembro de 2013 12:24:37, Marc Mutz wrote:
> Clang's -fsanitize=undefined disagrees:

No, it doesn't. You're pointing to QUrlTwoFlags, not QFlags.

> /home/marc/qtbase-clang-
> build/src/corelib/../../include/QtCore/../../../qtbase/src/corelib/io/qurl.h
> :353:10: runtime error: load of value 32505856, which is not a valid value
> for type 'QUrl::UrlFormattingOption' 

qurl.h line 353:
    friend class QUrlQuery;

> /home/marc/qtbase-clang-
> build/src/corelib/../../include/QtCore/../../../qtbase/src/corelib/io/qurl.h
> :90: runtime error: load of value 32505856, which is not a valid value for
> type 'QUrl::UrlFormattingOption' 

Line 90:
    Q_DECL_CONSTEXPR inline bool operator!() const { return !i; }


> /home/marc/qtbase-clang-
> build/src/corelib/../../include/QtCore/../../../qtbase/src/corelib/global/qf
> lags.h:100: runtime error: load of value 4161798143, which is not a valid
> value for type
> 'QUrl::ComponentFormattingOption'

qflags.h line 100:
    Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(Int(f)) {}

Looks like the sanitiser is reporting an error in the called function, as 
opposed to the place where the invalid value was actually loaded into the enum 
(it's a parameter argument, so it was loaded into the call site).

> PASS   : tst_QUrl::comparison()

4161798143 is 0xf80fffff. Sounds like a ~ applied to some enums, because no 
combination of ORs of QUrl flags will yield that mask. But I can't find a ~ nor 
an explicit cast in tst_QUrl::comparison.

I'm inclined to believe the sanitiser found something, but the report is 
useless if it doesn't tell us *where* the undefined behaviour happened.

> > And even if that were the case, QFlags does not store an enum. It stores
> > an
> > int, which has a very defined behaviour of storing bitwise OR combinations
> > of known values.
> 
> The issue is with the casts to enums in some of the QFlags operators, IIRC,
> but the log I cited is old and the line numbers might not match anymore.

They don't.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131104/f184ae40/attachment.sig>


More information about the Development mailing list