Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qsgtexture: fix debug build with uclibc #4

Closed
wants to merge 1 commit into from
Closed

qsgtexture: fix debug build with uclibc #4

wants to merge 1 commit into from

Conversation

ffontaine
Copy link

Debug build of qsgtexture fails on uclibc since version 5.11 and
7c507ea:

scenegraph/util/qsgtexture.cpp:69:22: fatal error: execinfo.h: No such file or directory
#include <execinfo.h>

Indeed, !defined(UCLIBC) has been replaced by defined(GBLIBC) to
fix build on musl but as a result, build fails on uclibc because uclibc
also defines GLIBC (and it does not have execinfo like musl)

This error is raised only when building in debug mode because
CAN_BACKTRACE_EXECINFO is undefined if QT_NO_DEBUG is set

So keep defined(GLIBC), but put back !defined(UCLIBC)

Fixes:

Signed-off-by: Fabrice Fontaine fontaine.fabrice@gmail.com

Debug build of qsgtexture fails on uclibc since version 5.11 and
7c507ea:

scenegraph/util/qsgtexture.cpp:69:22: fatal error: execinfo.h: No such file or directory
 #include <execinfo.h>

Indeed, !defined(__UCLIBC__) has been replaced by defined(__GBLIBC__) to
fix build on musl but as a result, build fails on uclibc because uclibc
also defines __GLIBC__ (and it does not have execinfo like musl)

This error is raised only when building in debug mode because
CAN_BACKTRACE_EXECINFO is undefined if QT_NO_DEBUG is set

So keep defined(__GLIBC__), but put back !defined(__UCLIBC__)

Fixes:
 - http://autobuild.buildroot.org/results/6fce0ce5aea943e097532efbbc8d1e28f41e5866

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
@ossilator
Copy link
Contributor

@ossilator ossilator closed this Dec 10, 2018
qtprojectorg pushed a commit that referenced this pull request Apr 25, 2019
Fix crash when QQmlMetaType::freeUnusedTypesAndCaches() is being called
during program exit, i.e. when the parent QJSEngine instance is being
destructed during exit().

Sample backtrace:
    #0  QQmlMetaType::freeUnusedTypesAndCaches () at /home/kfunk/devel/src/qt5.12/qtdeclarative/src/qml/qml/qqmlmetatype.cpp:2600
    #1  0x00007fffe12fce83 in QJSEnginePrivate::~QJSEnginePrivate (this=0x60c001c0b040, __in_chrg=<optimized out>) at /home/kfunk/devel/src/qt5.12/qtdeclarative/src/qml/jsapi/qjsengine.cpp:982
    #2  0x00007fffe12fce9f in QJSEnginePrivate::~QJSEnginePrivate (this=0x60c001c0b040, __in_chrg=<optimized out>) at /home/kfunk/devel/src/qt5.12/qtdeclarative/src/qml/jsapi/qjsengine.cpp:980
    #3  0x00007ffff53650c3 in QScopedPointerDeleter<QObjectData>::cleanup (pointer=<optimized out>) at ../../include/QtCore/../../../../../src/qt5.12/qtbase/src/corelib/tools/qscopedpointer.h:52
    #4  QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::~QScopedPointer (this=0x60300178b3a8, __in_chrg=<optimized out>) at ../../include/QtCore/../../../../../src/qt5.12/qtbase/src/corelib/tools/qscopedpointer.h:107
    #5  QObject::~QObject (this=<optimized out>, __in_chrg=<optimized out>) at /home/kfunk/devel/src/qt5.12/qtbase/src/corelib/kernel/qobject.cpp:891
    #6  0x00007fffe12ff572 in QJSEngine::~QJSEngine (this=0x60300178b3a0, __in_chrg=<optimized out>) at /home/kfunk/devel/src/qt5.12/qtdeclarative/src/qml/jsapi/qjsengine.cpp:379
    #7  0x00007fffe12ff583 in QJSEngine::~QJSEngine (this=0x60300178b3a0, __in_chrg=<optimized out>) at /home/kfunk/devel/src/qt5.12/qtdeclarative/src/qml/jsapi/qjsengine.cpp:375
    #8  0x00007ffff5363cc4 in QObjectPrivate::deleteChildren (this=this@entry=0x60b00016c380) at /home/kfunk/devel/src/qt5.12/qtbase/src/corelib/kernel/qobject.cpp:2010
    #9  0x00007ffff53650f5 in QObject::~QObject (this=<optimized out>, __in_chrg=<optimized out>) at /home/kfunk/devel/src/qt5.12/qtbase/src/corelib/kernel/qobject.cpp:1032
    #10 0x00007fffe103b43b in Grantlee::ScriptableTagLibrary::~ScriptableTagLibrary (this=0x607000ba4c00) at templates/lib/Grantlee_Templates_autogen/MTDBPGIEEV/../../../../../../../src/kf5/grantlee/templates/scriptabletags/scriptabletags.h:58
    #11 0x00007fffe103b469 in Grantlee::ScriptableTagLibrary::~ScriptableTagLibrary (this=0x607000ba4c00) at templates/lib/Grantlee_Templates_autogen/MTDBPGIEEV/../../../../../../../src/kf5/grantlee/templates/scriptabletags/scriptabletags.h:58
    #12 0x00007ffff5363cc4 in QObjectPrivate::deleteChildren (this=this@entry=0x60b00016c0c0) at /home/kfunk/devel/src/qt5.12/qtbase/src/corelib/kernel/qobject.cpp:2010
    #13 0x00007ffff53650f5 in QObject::~QObject (this=<optimized out>, __in_chrg=<optimized out>) at /home/kfunk/devel/src/qt5.12/qtbase/src/corelib/kernel/qobject.cpp:1032
    #14 0x00007fffe0fef704 in Grantlee::Engine::~Engine (this=0x60300178a2c0) at /home/kfunk/devel/src/kf5/grantlee/templates/lib/engine.cpp:60
    #15 0x00007fffdf2e2482 in GrantleeTheme::Engine::~Engine (this=0x60300178a2c0) at /home/kfunk/devel/src/kf5/grantleetheme/src/grantleethemeengine.cpp:54
    #16 0x00007fffdf2e24a9 in GrantleeTheme::Engine::~Engine (this=0x60300178a2c0) at /home/kfunk/devel/src/kf5/grantleetheme/src/grantleethemeengine.cpp:52
    #17 0x00007ffff3f4f8d1 in MessageViewer::MessagePartRendererManager::~MessagePartRendererManager (this=0x7ffff40c8ab0 <MessageViewer::MessagePartRendererManager::self()::s_self>) at /home/kfunk/devel/src/kf5/messagelib/messageviewer/src/messagepartthemes/default
    /messagepartrenderermanager.cpp:118
    #18 0x00007ffff4b442ac in ?? () from /lib/x86_64-linux-gnu/libc.so.6
    #19 0x00007ffff4b443da in exit () from /lib/x86_64-linux-gnu/libc.so.6

Also see:
  https://bugs.kde.org/show_bug.cgi?id=406871

Change-Id: If5676880c87f1fa2405701a439e1a0037dce045c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
qtprojectorg pushed a commit that referenced this pull request Dec 8, 2023
Using std::binary_search has the requirement that the passed
range fulfils ordering requirements, which was not the case
for the cppKeywords array here.

As the QString doc says [1]:

> QStrings can be compared using overloaded operators such as operator<(),
> operator<=(), operator==(), operator>=(), and so on. Note that
> the comparison is based exclusively on the numeric Unicode
> values of the characters. It is very fast, but is not what a
> human would expect; (...)

Therefore, sort the array accordingly and add an assert to
ensure it will remain sorted.

Fixes an crash/assert when building qtdeclarative with
CXXFLAGS='-D_GLIBCXX_DEBUG':

    /usr/include/c++/13/bits/stl_algo.h:2243:
    In function:
        bool std::binary_search(_FIter, _FIter, const _Tp&) [with _FIter = const
        QString*; _Tp = QStringView]

    Error: elements in iterator range [first, last) are not partitioned by the
    value __val.

    Objects involved in the operation:
        iterator "first" @ 0x7ffc4a2c4f18 {
          type = QString const* (constant iterator);
        }
        iterator "last" @ 0x7ffc4a2c4f10 {
          type = QString const* (constant iterator);
        }
    Aborted (core dumped)
    ninja: build stopped: subcommand failed.

GDB backtrace:

    Program terminated with signal SIGABRT, Aborted.
    #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
    44      ./nptl/pthread_kill.c: No such file or directory.
    (gdb) bt
    #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
    #1  0x00007f307e0a815f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
    #2  0x00007f307e05a472 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
    #3  0x00007f307e0444b2 in __GI_abort () at ./stdlib/abort.c:79
    #4  0x00007f307e2a300d in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
    #5  0x00005639ff90471d in std::binary_search<QString const*, QStringView> (__first=0x5639ffa1a9c0 <QmltcVisitor::checkForNamingCollisionsWithCpp(QDeferredSharedPointer<QQmlJSScope const> const&)::cppKeywords>,
        __last=0x5639ffa1b2c0 <guard variable for QmltcVisitor::checkForNamingCollisionsWithCpp(QDeferredSharedPointer<QQmlJSScope const> const&)::cppKeywords>, __val=...) at /usr/include/c++/13/bits/stl_algo.h:2243
    #6  0x00005639ff8fb837 in operator() (__closure=0x7ffc4a2c52bf, word=...) at /home/michi/development/git/qt5/qtdeclarative/tools/qmltc/qmltcvisitor.cpp:764
    #7  0x00005639ff8fb89e in operator() (__closure=0x7ffc4a2c52a0, name=..., errorPrefix=...) at /home/michi/development/git/qt5/qtdeclarative/tools/qmltc/qmltcvisitor.cpp:768
    #8  0x00005639ff8fc99b in QmltcVisitor::checkForNamingCollisionsWithCpp (this=0x7ffc4a2c6070, type=...) at /home/michi/development/git/qt5/qtdeclarative/tools/qmltc/qmltcvisitor.cpp:787
    #9  0x00005639ff8f9dea in QmltcVisitor::endVisit (this=0x7ffc4a2c6070, program=0x563a002e0628) at /home/michi/development/git/qt5/qtdeclarative/tools/qmltc/qmltcvisitor.cpp:341
    #10 0x00007f307f6636fa in QQmlJS::AST::UiProgram::accept0 (this=0x563a002e0628, visitor=0x7ffc4a2c6070) at /home/michi/development/git/qt5/qtdeclarative/src/qml/parser/qqmljsast.cpp:1193
    #11 0x00007f3080159b8f in QQmlJS::AST::Node::accept (this=0x563a002e0628, visitor=0x7ffc4a2c6070)
        at /home/michi/development/git/qt5/qtbase/include/QtQml/6.7.0/QtQml/private/../../../../../../qtdeclarative/src/qml/parser/qqmljsast_p.h:272
    #12 0x00007f3080212f4b in QQmlJSTypeResolver::init (this=0x7ffc4a2c5b50, visitor=0x7ffc4a2c6070, program=0x563a002e0628) at /home/michi/development/git/qt5/qtdeclarative/src/qmlcompiler/qqmljstyperesolver.cpp:173
    #13 0x00005639ff8f0bd3 in QmltcTypeResolver::init (this=0x7ffc4a2c5b50, visitor=0x7ffc4a2c6070, program=0x563a002e0628) at /home/michi/development/git/qt5/qtdeclarative/tools/qmltc/qmltctyperesolver.cpp:19
    #14 0x00005639ff8c02d4 in main (argc=23, argv=0x7ffc4a2c7a68) at /home/michi/development/git/qt5/qtdeclarative/tools/qmltc/main.cpp:269

[1] https://doc.qt.io/qt-6/qstring.html#comparing-strings

Change-Id: I82ebbcdca4ab90155b935f9af24b3a3821134563
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
qtprojectorg pushed a commit that referenced this pull request Dec 8, 2023
The Compare requirements [1] say:

> The return value of the function call operation applied to an object of
> a type satisfying Compare, when contextually converted to bool, yields
> true if the first argument of the call appears before the second in the
> strict weak ordering relation induced by this type, and false otherwise.

That requirement was violated here, because passing
the same value for both arguments would return true,
since the

    inlineComponentB->inherits(inlineComponentA)

check returns true when both inline components
are the same.

Add an equality check to fix that.

Fixes a build failure when building with
CXXFLAGS='-D_GLIBCXX_DEBUG':

    /usr/include/c++/13/bits/stl_algo.h:4892:
    In function:
        void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter =
        QList<variant<QString, monostate> >::iterator; _Compare =
        QmltcCompiler::compile(const QmltcCompilerInfo&)::<lambda(const
        QmltcCompiler::InlineComponentOrDocumentRootName&, const
        QmltcCompiler::InlineComponentOrDocumentRootName&)>]

    Error: comparison doesn't meet irreflexive requirements, assert(!(a < a)).

    Objects involved in the operation:
        instance "functor" @ 0x7ffec14329f8 {
          type = QmltcCompiler::compile(QmltcCompilerInfo const&)::{lambda(std::variant<QString, std::monostate> const&, std::variant<QString, std::monostate> const&)#1};
        }
        iterator::value_type "ordered type"  {
          type = std::variant<QString, std::monostate>;
        }
    Aborted (core dumped)
    ninja: build stopped: subcommand failed.

GDB backtrace:

    Program terminated with signal SIGABRT, Aborted.
    #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
    44      ./nptl/pthread_kill.c: No such file or directory.
    (gdb) bt
    #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
    #1  0x00007fbe6b4a815f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
    #2  0x00007fbe6b45a472 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
    #3  0x00007fbe6b4444b2 in __GI_abort () at ./stdlib/abort.c:79
    #4  0x00007fbe6b6a300d in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
    #5  0x0000560ae899bec4 in std::sort<QList<std::variant<QString, std::monostate> >::iterator, QmltcCompiler::compile(const QmltcCompilerInfo&)::<lambda(const QmltcCompiler::InlineComponentOrDocumentRootName&, const QmltcCompiler::InlineComponentOrDocumentRootName&)> >(QList<std::variant<QString, std::monostate> >::iterator, QList<std::variant<QString, std::monostate> >::iterator, struct {...}) (__first=..., __last=..., __comp=...)
        at /usr/include/c++/13/bits/stl_algo.h:4892
    #6  0x0000560ae898bd67 in QmltcCompiler::compile (this=0x7ffec1432e80, info=...) at /home/michi/development/git/qt5/qtdeclarative/tools/qmltc/qmltccompiler.cpp:85
    #7  0x0000560ae89264b6 in main (argc=23, argv=0x7ffec1434fc8) at /home/michi/development/git/qt5/qtdeclarative/tools/qmltc/main.cpp:284

[1] https://en.cppreference.com/w/cpp/named_req/Compare

Change-Id: Ie8934b8381ef217c1f8860ee110f6fa2aa0c86fa
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants