I am in a bit of a pickle.
My application has one main window (inherits from QMainWindow). The main window is parent to a QTabWidget, which acts as a sort of dialog that shows up when the user clicks a toolbar button on the main window, and hides when its 'Close' button is clicked. In addition, the main window has another toolbar button, which when clicked, calls exec() on a QDialog. While developing the app, I have noticed that once every 40 times or so, clicking one of the two buttons I have mentioned causes an empty widget to appear, but instead of the intended view being drawn, everything freezes. When I click the 'Close' button on the main window, my OS tells me that the application has stopped responding. There is never any way to recover from crashes like this, and I am usually forced to kill the app and restart.
The vexing thing about all this is that I cannot reproduce the crashes at will. They are impossible to predict, and often catch me off-guard.
I used gdb to attach to a frozen instance, and got the following back trace:
#0 pthread_cond_wait##GLIBC_2.3.2 ()
at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1 0x00007f1ba3bf1b03 in QWaitCondition::wait(QMutex*, unsigned long) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Core.so.5
#2 0x00007f1ba3bea277 in QReadWriteLock::lockForRead() ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Core.so.5
#3 0x00007f1b9bf5ee4e in ?? () from /opt/Qt/5.4/gcc_64/plugins/platforms/../../lib/libQt5DBus.so.5
#4 0x00007f1b9bf61d71 in ?? () from /opt/Qt/5.4/gcc_64/plugins/platforms/../../lib/libQt5DBus.so.5
#5 0x00007f1b9bf64e54 in ?? () from /opt/Qt/5.4/gcc_64/plugins/platforms/../../lib/libQt5DBus.so.5
#6 0x00007f1b904159d6 in dbus_connection_dispatch () from /lib/x86_64-linux-gnu/libdbus-1.so.3
#7 0x00007f1b9bf579f5 in ?? () from /opt/Qt/5.4/gcc_64/plugins/platforms/../../lib/libQt5DBus.so.5
#8 0x00007f1b9bfa78f5 in ?? () from /opt/Qt/5.4/gcc_64/plugins/platforms/../../lib/libQt5DBus.so.5
#9 0x00007f1ba3e5a326 in QObject::event(QEvent*) () from /opt/Qt/5.4/gcc_64/lib/libQt5Core.so.5
#10 0x00007f1ba510b8f4 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#11 0x00007f1ba510f506 in QApplication::notify(QObject*, QEvent*) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#12 0x00007f1ba3e25c84 in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Core.so.5
#13 0x00007f1ba3e28868 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Core.so.5
#14 0x00007f1ba3e80123 in ?? () from /opt/Qt/5.4/gcc_64/lib/libQt5Core.so.5
#15 0x00007f1ba283be04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007f1ba283c048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#17 0x00007f1ba283c0ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#18 0x00007f1ba3e80554 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)
() from /opt/Qt/5.4/gcc_64/lib/libQt5Core.so.5
#19 0x00007f1ba3e23eab in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Core.so.5
#20 0x00007f1ba530a2ed in QDialog::exec() () from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#21 0x0000000000425fe4 in MainWindow::AddNewDownload() ()
#22 0x00007f1ba3e57e7a in QMetaObject::activate(QObject*, int, int, void**) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Core.so.5
#23 0x00007f1ba50fee52 in QAction::triggered(bool) () from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#24 0x00007f1ba5100c77 in QAction::activate(QAction::ActionEvent) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#25 0x00007f1ba520b0b5 in ?? () from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#26 0x00007f1ba520b374 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#27 0x00007f1ba52cf89a in QToolButton::mouseReleaseEvent(QMouseEvent*) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#28 0x00007f1ba514723c in QWidget::event(QEvent*) () from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#29 0x00007f1ba52d0730 in QToolButton::event(QEvent*) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#30 0x00007f1ba510b8f4 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#31 0x00007f1ba510f071 in QApplication::notify(QObject*, QEvent*) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#32 0x00007f1ba3e25c84 in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
from /opt/Qt/5.4/gcc_64/lib/libQt5Core.so.5
#33 0x00007f1ba510df88 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) () from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#34 0x00007f1ba5162387 in ?? () from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
#35 0x00007f1ba5164e78 in ?? () from /opt/Qt/5.4/gcc_64/lib/libQt5Widgets.so.5
---Type <return> to continue, or q <return> to quit---
It appears that my app is stuck waiting to be woken up when a certain condition is met. The presence of dbus in the back trace suggests that it was trying to talk to another process, which I am guessing is a GUI-related process. I however do not know why the wait condition is met 98% of the time, but fails 2% of the time. When using strace, I was able to find that the system call that blocked is:
futex(0x7f403c00690c, FUTEX_WAIT_PRIVATE, 1, NULL)
I am not using QThreads or mutexes in my code, so I am guessing this problem is Qt-internal. Does anyone with knowledge of low-level workings of Qt know what is happening?
Related
I am building a custom protoc-compiler that is based on googles c++ libraries for protobuf.
I ran into a strange error when running it on linux, while it runs fine on MacOS
terminate called after throwing an instance of 'std::system_error'
what(): Unknown error -1
After setting up and trying around with my debugger this is the stacktrace:
#1 0x00007f61c097b897 in abort () from /usr/lib/libc.so.6
#2 0x00007f61c0d1381d in __gnu_cxx::__verbose_terminate_handler () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#3 0x00007f61c0d204da in __cxxabiv1::__terminate (handler=<optimized out>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
#4 0x00007f61c0d20537 in std::terminate () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
#5 0x00007f61c0d2078e in __cxxabiv1::__cxa_throw (obj=obj#entry=0x5568aec89df0, tinfo=tinfo#entry=0x7f61c0e5a750 <typeinfo for std::system_error>, dest=dest#entry=0x7f61c0d4cc60 <std::system_error::~system_error()>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95
#6 0x00007f61c0d167ff in std::__throw_system_error (__i=-1) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/ext/new_allocator.h:89
#7 0x00007f61c14b5c63 in std::call_once<void (&)(google::protobuf::internal::DescriptorTable const*), google::protobuf::internal::DescriptorTable const*&> (__f=#0x7f61c14c0780: {void (const google::protobuf::internal::DescriptorTable *)} 0x7f61c14c0780 <google::protobuf::(anonymous namespace)::AssignDescriptorsImpl(google::protobuf::internal::DescriptorTable const*)>, __once=...) at /usr/include/c++/7/mutex:698
#8 google::protobuf::internal::AssignDescriptors (table=<optimized out>, table#entry=0x7f61c17dddc0 <descriptor_table_google_2fprotobuf_2fdescriptor_2eproto>) at google/protobuf/generated_message_reflection.cc:2407
#9 0x00007f61c148f440 in google::protobuf::FileDescriptorProto::GetMetadataStatic () at ./google/protobuf/descriptor.pb.h:623
#10 google::protobuf::FileDescriptorProto::GetMetadata (this=<optimized out>) at google/protobuf/descriptor.pb.cc:2281
#11 0x00005568acbb22ed in google::protobuf::Message::GetReflection (this=0x7ffd47e4efc0) at /home/leo/CLionProjects/protoc-gen-java-leo/protoc/include/google/protobuf/message.h:333
#12 0x00005568acbad61f in google::protobuf::compiler::java_leo::(anonymous namespace)::CollectExtensions (message=..., extensions=0x7ffd47e4eef0) at /home/leo/CLionProjects/protoc-gen-java-leo/src/google/protobuf/compiler/java_leo/java_file.cc:84
#13 0x00005568acbad8ca in google::protobuf::compiler::java_leo::(anonymous namespace)::CollectExtensions (file_proto=..., alternate_pool=..., extensions=0x7ffd47e4eef0, file_data="\n\021addressbook.proto\022\btutorial\032\037google/protobuf/timestamp.proto\032\roptions.proto\"\255\002\n\006Person\022\"\n\002id\030\001 \001(\tB\022\222\202\031\016java.util.UUIDR\002id\022\022\n\004name\030\002 \001(\tR\004name\022\020\n\003age\030\003 \001(\005R\003age\022\024\n\005email\030\004 \001(\tR\005email\022\064\n\006phones\030\005 \003(\v2\034.tutorial.Person.PhoneNumberR\006phones\022=\n\flast_updated\030\006 \001(\v2\032.google.protobuf.TimestampR\vlastUpdated\032N\n\vPhoneNumber\022\026\n\006number\030\001 \001(\tR\006number\022'\n\004type\030\002 \001(\016\062\023.tutorial.PhoneTypeR\004type\"7\n\vAddressBook\022(\n\006people\030\001 \003(\v2\020.tutorial.PersonR\006people*+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\b\n\004HOME\020\001\022\b\n\004WORK\020\002B+\n\024com.example.tutorialB\021AddressBookProtosP\001b\006proto3") at /home/leo/CLionProjects/protoc-gen-java-leo/src/google/protobuf/compiler/java_leo/java_file.cc:122
#14 0x00005568acbaf23f in google::protobuf::compiler::java_leo::FileGenerator::GenerateDescriptorInitializationCodeForImmutable (this=0x5568aec7d590, printer=0x7ffd47e4f380) at /home/leo/CLionProjects/protoc-gen-java-leo/src/google/protobuf/compiler/java_leo/java_file.cc:439
#15 0x00005568acbaed2a in google::protobuf::compiler::java_leo::FileGenerator::Generate (this=0x5568aec7d590, printer=0x7ffd47e4f380) at /home/leo/CLionProjects/protoc-gen-java-leo/src/google/protobuf/compiler/java_leo/java_file.cc:351
#16 0x00005568acbb73ea in google::protobuf::compiler::java_leo::JavaGenerator::Generate (this=0x7ffd47e4f788, file=0x5568aec77500, parameter="", context=0x7ffd47e4f5f0, error=0x7ffd47e4f5d0) at /home/leo/CLionProjects/protoc-gen-java-leo/src/google/protobuf/compiler/java_leo/java_generator.cc:158
#17 0x00007f61c0f06fae in google::protobuf::compiler::CodeGenerator::GenerateAll (this=0x7ffd47e4f788, files=std::vector of length 2, capacity 2 = {...}, parameter="", generator_context=0x7ffd47e4f5f0, error=0x7ffd47e4f5d0) at google/protobuf/compiler/code_generator.cc:58
#18 0x00007f61c0f16733 in google::protobuf::compiler::GenerateCode (request=..., generator=..., response=response#entry=0x7ffd47e4f6a0, error_msg=error_msg#entry=0x7ffd47e4f680) at google/protobuf/compiler/plugin.cc:133
#19 0x00007f61c0f16b17 in google::protobuf::compiler::PluginMain (argc=<optimized out>, argv=0x7ffd47e4f8c8, generator=0x7ffd47e4f788) at google/protobuf/compiler/plugin.cc:169
#20 0x00005568acbe9ed5 in main (argc=1, argv=0x7ffd47e4f8c8) at /home/leo/CLionProjects/protoc-gen-java-leo/main.cpp:10
#21 0x00007f61c097d153 in __libc_start_main () from /usr/lib/libc.so.6
#22 0x00005568acb9598e in _start ()
Since I'm a total C++ noob, it took me around 8 hours trying stuff out and googleing around before I found out the reason, so I wanted to share it here for the next person that might run into this problem.
It turns out, that the "pthread"-library is required and it crashes while calling the "call_once"-method if it's not present. A better error-message would have been great, "what(): Unknown error -1" didn't help out a lot :D
All I did was to add this line in my CMakeLists.txt:
target_link_libraries(${CMAKE_PROJECT_NAME} pthread)
Now it runs like a charm :)
Hope this helps someone.
I have no idea where this problem might come from:
(Debugging with GDB):
terminate called after throwing an instance of '[Thread 0x7ffff5e68700 (LWP 24945) exited]
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'
Thread 1 "random_walkerta" received signal SIGSEGV, Segmentation fault.
tcache_get (tc_idx=1) at malloc.c:2943
StackTrace:
#0 tcache_get (tc_idx=1) at malloc.c:2943
#1 __GI___libc_malloc (bytes=31) at malloc.c:3050
#2 0x00007ffff6ec154c in operator new(unsigned long) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff6f56dbf in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff6f584bb in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00005555555bee66 in boost::system::system_error::what (
this=0x5555558a1bf0) at /usr/include/boost/system/system_error.hpp:70
#6 0x00007ffff6eba8ba in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00007ffff6ec0d3a in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#8 0x00007ffff6ebfd59 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#9 0x00007ffff6ec0708 in __gxx_personality_v0 ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#10 0x00007ffff6888763 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#11 0x00007ffff688907d in _Unwind_Resume ()
from /lib/x86_64-linux-gnu/libgcc_s.so.1
#12 0x00005555555cb8d6 in boost::asio::detail::do_throw_error (err=...,
location=0x555555610dba "close")
at /usr/include/boost/asio/detail/impl/throw_error.ipp:37
---Type <return> to continue, or q <return> to quit---
#13 0x00005555555cb741 in boost::asio::detail::throw_error (err=...,
location=0x555555610dba "close")
at /usr/include/boost/asio/detail/throw_error.hpp:42
#14 0x00005555555de022 in boost::asio::basic_socket<boost::asio::ip::udp, boost::asio::datagram_socket_service<boost::asio::ip::udp> >::close (
this=0x555555887ea0) at /usr/include/boost/asio/basic_socket.hpp:356
#15 0x00005555555d7ebe in Vast::net_overhearing_handler::handle_close (
this=0x555555889490) at net_overhearing_handler.cpp:160
#16 0x00005555555d7e4c in Vast::net_overhearing_handler::close (
this=0x555555889490) at net_overhearing_handler.cpp:141
#17 0x00005555555c9b85 in Vast::net_overhearing::stop (this=0x5555558870e0)
at net_overhearing.cpp:88
#18 0x00005555555ba77f in Vast::VASTnet::~VASTnet (this=0x55555587f180,
__in_chrg=<optimized out>) at VASTnet.cpp:63
#19 0x000055555556ca7a in Vast::destroyNet (net=0x55555587f180)
at VASTVerse.cpp:93
#20 0x000055555556d036 in Vast::VASTVerse::~VASTVerse (this=0x55555587e4c0,
__in_chrg=<optimized out>) at VASTVerse.cpp:196
#21 0x000055555556bce4 in main (argc=1, argv=0x7fffffffe598)
at random_walkertalker.cpp:266
The setup is a follows:
I have a Boost UDP socket running on seperate thread io_service, listening for packets. Everything works according to expectation until I try to shutdown the program, UDP socket and io_service. I am guessing I am not correctly shutting something down.
Here is the code for shutting down the UDP and io_services:
if (_io_service != NULL) {
_io_service->reset();
_udp->close(); //This line is giving the error (160)
_io_service->stop();
_iosthread->join();
}
Starting up, I do the following:
_udp = new ip::udp::socket(*_io_service);
_udp->open(ip::udp::v4());
_udp->async_receive_from(
boost::asio::buffer(_buf, VAST_BUFSIZ), _remote_endpoint_,
boost::bind(&net_overhearing_handler::handle_input, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
_iosthread = new boost::thread(boost::bind(&boost::asio::io_service::run, io_service));
Remove this line
_io_service->reset();
because as per the reference io_service::reset
This function must not be called while there are any unfinished calls
to the run(), run_one(), poll() or poll_one() functions.
It seems run method works in thread when you call restart.
You don't need to call this method to stop io_service::run method. All pending operations in run will be cancelled by calling _io_service->stop(); then run stops and your thread also terminates.
The following program paints a red background. Pressing the left mouse button paints a white rectangle onto it. The rectangle has a child rectangle and a QGraphicsDropShadowEffect. (QGraphicsOpacityEffect and QGraphicsColorizeEffect also lead to the problem, but less frequently.)
Pressing the right mouse button removes the white rectangle.
Sometimes when removing the rectangle it causes a segmentation fault.
This does not happen if the QGraphicsDropShadowEffect is not applied. It also does not happen when there either is no child item in MyRect or the background is ommited.
(When searching for this issue, I found several hints that a segfault like this could be related to changing the boundingRect() of an item without calling prepareGeometryChange().)
I am really at a loss here. This is part of a bigger project and I boiled it down to the following example:
Main.cc:
#include<QApplication>
#include<QGraphicsView>
#include<QGraphicsScene>
#include<QGraphicsSceneMouseEvent>
#include<QGraphicsRectItem>
#include<QGraphicsDropShadowEffect>
#include<QScreen>
class MyRect: public QGraphicsRectItem
{
public:
MyRect(QGraphicsItem* parent = nullptr):
QGraphicsRectItem{QRectF{0.0f, 0.0f, 100.0f, 100.0f}, parent}
{
setPen(QPen{Qt::white});
setBrush(QBrush{Qt::white, Qt::SolidPattern});
my_child_=new QGraphicsRectItem{this};
}
private:
QGraphicsRectItem* my_child_=nullptr;
};
class MyScene: public QGraphicsScene
{
public:
MyScene()
{
background_=new QGraphicsRectItem{0.0f, 0.0f, 500.0f, 500.0f};
background_->setPen(QPen{Qt::white});
background_->setBrush(QBrush{Qt::red, Qt::SolidPattern});
addItem(background_);
}
void mouseReleaseEvent(QGraphicsSceneMouseEvent* me) override
{
if (me->button()==Qt::LeftButton)
{
if (my_rect_==nullptr)
{
my_rect_=new MyRect{};
shadow_=new QGraphicsDropShadowEffect{};
shadow_->setBlurRadius(15.0f);
my_rect_->setGraphicsEffect(shadow_);
addItem(my_rect_);
my_rect_->setPos(me->scenePos());
}
}
else if (me->button()==Qt::RightButton)
{
if (my_rect_!=nullptr)
{
removeItem(my_rect_);
my_rect_->setGraphicsEffect(0);
shadow_=nullptr;
delete my_rect_;
my_rect_=nullptr;
}
}
else
{
QGraphicsScene::mouseReleaseEvent(me);
}
}
private:
QGraphicsRectItem* background_=nullptr;
MyRect* my_rect_=nullptr;
QGraphicsDropShadowEffect* shadow_=nullptr;
};
int
main(int argc, char** argv)
{
QApplication qapp{argc, argv};
QGraphicsView view;
MyScene scene;
QRect rect=QGuiApplication::primaryScreen()->geometry();
scene.setSceneRect(0.0f, 0.0f, rect.width(), rect.height());
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setFrameShape(QFrame::NoFrame);
view.setBackgroundBrush(QBrush(Qt::black, Qt::SolidPattern));
view.setScene(&scene);
view.showFullScreen();
return qapp.exec();
}
Compiler call:
g++ --std=c++14 -fPIC -Wall -Woverloaded-virtual -Werror -pedantic -g -O0 -fPIC -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/x86_64-linux-gnu/qt5 -o test Main.cc -lQt5Gui -lQt5Core -lQt5Widgets
Backtrace:
#0 0x0000555555a9a840 in ?? ()
#1 0x00007ffff71e017c in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#2 0x00007ffff71e0a3a in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#3 0x00007ffff720289a in QGraphicsView::paintEvent(QPaintEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#4 0x00007ffff6f10278 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#5 0x00007ffff6ff89fe in QFrame::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#6 0x00007ffff72013ab in QGraphicsView::viewportEvent(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#7 0x00007ffff7650701 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8 0x00007ffff6ec8b65 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#9 0x00007ffff6ed0341 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#10 0x00007ffff76509a0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#11 0x00007ffff6f08fda in QWidgetPrivate::sendPaintEvent(QRegion const&) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007ffff6f09646 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007ffff6ed8f1e in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007ffff6ed9147 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007ffff6ef7f8f in QWidgetPrivate::syncBackingStore() () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007ffff6f10348 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007ffff6ff89fe in QFrame::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007ffff7081de3 in QAbstractScrollArea::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007ffff6ec8b8c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007ffff6ed0341 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007ffff76509a0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x00007ffff765312d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#23 0x00007ffff71d2a22 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#24 0x00007ffff71d8299 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#25 0x00007ffff767d459 in QObject::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#26 0x00007ffff71e4e6b in QGraphicsScene::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#27 0x00007ffff6ec8b8c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#28 0x00007ffff6ed0341 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#29 0x00007ffff76509a0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#30 0x00007ffff765312d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#31 0x00007ffff76a4c03 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#32 0x00007ffff446f7f7 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#33 0x00007ffff446fa60 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#34 0x00007ffff446fb0c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#35 0x00007ffff76a500f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#36 0x00007ffff764e98a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#37 0x00007ffff76570fc in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#38 0x000055555555768b in main (argc=1, argv=0x7fffffffe5b8) at Main.cc:89
EDIT: I rewritten the code example for better readability.
As I was educated on on the Qt forums this is not expected behaviour and might be a bug in Qt.
The best workaround is to call QGraphicsItem::prepareGeometryChange() on my_rect_ before removing it from the scene. This might be done be exposing the protected prepareGeometryChange() or by calling it inside ~MyRect() and then simply deleting my_rect_ without calling QGraphicsScene::removeItem(). ~QGraphicsItem(), which of course is called after ~MyRect(), will automatically remove the item from the scene.
#0 0x0000003d7e432925 in raise () from /lib64/libc.so.6
#1 0x0000003d7e43408d in abort () from /lib64/libc.so.6
#2 0x00007ff601e3ba55 in os::abort(bool) () from /usr/java/jdk1.7.0_67-cloudera/jre/lib/amd64/server/libjvm.so
#3 0x00007ff601fbbf87 in VMError::report_and_die() () from /usr/java/jdk1.7.0_67-cloudera/jre/lib/amd64/server/libjvm.so
#4 0x00007ff601e4096f in JVM_handle_linux_signal () from /usr/java/jdk1.7.0_67-cloudera/jre/lib/amd64/server/libjvm.so
#5 <signal handler called>
#6 0x00007ff5fe8f218e in LdiInterFromArray () from /home/zhaojuan/project/DataType/thirdparty/occi-11.2/lib/libclntsh.so.11.1
#7 0x00007ff5ff85a1eb in kpcceiyd2iyd () from /home/zhaojuan/project/DataType/thirdparty/occi-11.2/lib/libclntsh.so.11.1
#8 0x00007ff600138c1d in ttccfpg () from /home/zhaojuan/project/DataType/thirdparty/occi-11.2/lib/libclntsh.so.11.1
#9 0x00007ff600136e90 in ttcfour () from /home/zhaojuan/project/DataType/thirdparty/occi-11.2/lib/libclntsh.so.11.1
#10 0x00007ff5fe5c45f3 in kpufcpf () from /home/zhaojuan/project/DataType/thirdparty/occi-11.2/lib/libclntsh.so.11.1
#11 0x00007ff5fe5c2872 in kpufch0 () from /home/zhaojuan/project/DataType/thirdparty/occi-11.2/lib/libclntsh.so.11.1
#12 0x00007ff5fe5c110f in kpufch () from /home/zhaojuan/project/DataType/thirdparty/occi-11.2/lib/libclntsh.so.11.1
#13 0x00007ff5fe556a03 in OCIStmtFetch () from /home/zhaojuan/project/DataType/thirdparty/occi-11.2/lib/libclntsh.so.11.1
#14 0x00007ff600a29b33 in oracle::occi::ResultSetImpl::next(unsigned int) () from /home/zhaojuan/project/DataType/thirdparty/occi-11.2/lib/libocci.so.11.1
#15 0x0000000000c6f481 in xcloud::xos::OracleLoader::RunLoadMain (this=0x78e6680) at /home/zhaojuan/project/DataType/be/src/exec_xos/OracleLoader.cpp:366
#16 0x0000000000c70f49 in xcloud::xos::OracleLoaderThread (This=<value optimized out>)
at /home/zhaojuan/project/DataType/be/src/exec_xos/OracleLoader.cpp:43
#17 0x0000003d7e8079d1 in start_thread () from /lib64/libpthread.so.0
#18 0x0000003d7e4e8b6d in clone () from /lib64/libc.so.6
hi , I met a occi problem, I want to get interval value from oracle, but it was core dump ,why?
the simplest code is
if (ttype == oracle::occi::OCCI_SQLT_INTERVAL_YM) {
LOG(INFO) << "set YM buffer";
m_res->setDataBuffer(i + 1, m_colBuf[i], ttype, 5, &(m_resultInfos[i].fieldLens[0]),
&(m_resultInfos[i].fieldFlags[0]), &(m_resultInfos[i].fieldRCs[0]));
} else if (ttype == oracle::occi::OCCI_SQLT_INTERVAL_DS) {
m_res->setDataBuffer(i + 1, m_colBuf[i], ttype, 11, &(m_resultInfos[i].fieldLens[0]),
&(m_resultInfos[i].fieldFlags[0]), &(m_resultInfos[i].fieldRCs[0]));
}
m_res is a type of oracle::occi::ResultSet*
m_colBuf[i] is alloc(colWidth[i] * fetchsize)
and it was crashed at:
if (0 == m_res->next(m_fetchSize)) {
LOG(INFO) << "Oracle Fetch finished!";
break;
}
My linux(ubuntu 12.04) process crash when I use ACE_5.7.1. My code:
ACE_INET_Addr remote_addr(server_addr.c_str());
ACE_SOCK_Stream stream;
ACE_SOCK_Connector connector;
ACE_Time_Value to(1, 0), to2(2,0);
ret = connector.connect(stream, remote_addr, &to);
Stack info:
Program terminated with signal 6, Aborted
#0 0x00002b47daf8d425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00002b47daf8d425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00002b47daf90b8b in __GI_abort () at abort.c:91
#2 0x00002b47dafcb39e in __libc_message (do_abort=2, fmt=0x2b47db0d2e3f "*** %s ***: %s terminated\n") at ../sysdeps/unix/sysv/linux/libc_fatal.c:201
#3 0x00002b47db061817 in __GI___fortify_fail (msg=0x2b47db0d2dd6 "buffer overflow detected") at fortify_fail.c:32
#4 0x00002b47db060710 in __GI___chk_fail () at chk_fail.c:29
#5 0x00002b47db0617ce in __fdelt_chk (d=<optimized out>) at fdelt_chk.c:26
#6 0x00002b47d9ee9c3b in is_set (handle=1537, this=0x2b48883e9d90) at /home/cfcheng/MSP4.0/source/source/engine/ivs/../../share/ACE-5.7.1/ace/Handle_Set.inl:84
#7 set_bit (handle=1537, this=0x2b48883e9d90) at /home/cfcheng/MSP4.0/source/source/engine/ivs/../../share/ACE-5.7.1/ace/Handle_Set.inl:103
#8 ACE::handle_timed_complete (h=1537, timeout=0x2b48883ea110, is_tli=0) at ACE.cpp:2547
#9 0x00002b47d9f4e5c7 in ACE_SOCK_Connector::complete (this=<optimized out>, new_stream=..., remote_sap=0x0, tv=<optimized out>) at SOCK_Connector.cpp:262
#10 0x00002b47d9f4e737 in ACE_SOCK_Connector::shared_connect_finish (this=0x2b48883ea17f, new_stream=..., timeout=0x2b48883ea110, result=-1) at SOCK_Connector.cpp:155
#11 0x000000000044f4a9 in res_update_work::send_notify(std::string const&, std::string const&) ()
#12 0x000000000044fe7e in res_update_work::batch_send(std::string const&, ACE_Time_Value const&, bool) ()
#13 0x00000000004506c5 in res_update_work::update_all_res() ()
#14 0x0000000000450ada in res_update_work::svc() ()
#15 0x00002b47d9f56427 in ACE_Task_Base::svc_run (args=0x3e5a490) at Task.cpp:275
#16 0x00002b47d9f578c4 in ACE_Thread_Adapter::invoke (this=0x3e5ae90) at Thread_Adapter.cpp:98
#17 0x00002b47dad41e9a in start_thread (arg=0x2b4888401700) at pthread_create.c:308
#18 0x00002b47db04accd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#19 0x0000000000000000 in ?? ()
Who know why these code cause exception.
Thanks very much.
You are passing automatic objects to connect , I suspect this is causing the problem. Try to allocate the objects passed to connect dynamically, or make them attributes of an object which is still alive after the function where you call connect terminates. The same with the connector object.