简体   繁体   中英

QT app crashs on Ubuntu12.04

I have developed QT application with C++ on both Windows & Ubuntu12.04. I can run my app on Windows but my app crashes on Ubuntu. So I run my app on gdb and get the following messages.

Program received signal SIGSEGV, Segmentation fault.
_GLOBAL__sub_I_SmartEditImp.cpp ()
    at /home/linden/Qt5.3.1/5.3/gcc/include/QtCore/qrefcount.h:62
62          if (count != -1) // !isStatic

I could not specify where error is occured. Do you have any idea to solve this problem? I use QT5.3.1, QtCreator3.1.2 and gcc4.6.1. Thanks.

The helper private class QtPrivate::RefCount is used for implementation of copy-on-write idiom in all Qt containers (including QString and QByteArray ).

Usage of not valid Qt container instance is the only reason for crash in QtPrivate::RefCount:ref() method. For example, that method is called in the first line of body of QString copy constructor or QString assigment operator:

QString::QString(const QString &other);
QString &QString::operator=(const QString &other);

So, there are three possible scenarios for such crash:

  • the most probable case of accessing by pointer or reference already destroyed object with some Qt container inside;
  • dereferencing of never initialized pointer to a Qt container and its usage;
  • corrupted application heap by a hidden bug is the least expected scenario, since in that case the application may crash in random places.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM