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

Optimize persistent data #2112

Merged
merged 2 commits into from
Jan 27, 2015

Conversation

sorokin
Copy link
Contributor

@sorokin sorokin commented Nov 2, 2014

No description provided.

@sorokin
Copy link
Contributor Author

sorokin commented Nov 16, 2014

@sledgehammer999 ping

Could you review this pull request? I think it should improve situation in #646, #1203, #1235, #1542, #1592 and, probably, #674.

@sledgehammer999
Copy link
Member

-I haven't forgotten this-

@sorokin
Copy link
Contributor Author

sorokin commented Nov 16, 2014

qbittorrent constantly crashes at startup. Possibly related to this pull request:

$ ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.4 ASAN_OPTIONS=symbolize=1 ./qbittorrent

ASAN:SIGSEGV

==9117== ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x00000070c82b sp 0x7fff5e903060 bp 0x7fff5e903160 T0)
AddressSanitizer can not provide additional info.
recalculate_auto_managed_torrents
#0 0x70c82a in QHashData::firstNode() /usr/include/qt4/QtCore/qhash.h:184
#1 0x70c82a in QHash<QString, QVariant>::constBegin() const /usr/include/qt4/QtCore/qhash.h:466
#2 0x70c82a in TorrentPersistentData::hasPerTorrentRatioLimit() /home/ivan/d/qbittorrent/src/torrentpersistentdata.cpp:238
#3 0x5d5ebe in QBtSession::updateRatioTimer() /home/ivan/d/qbittorrent/src/qtlibtorrent/qbtsession.cpp:2019
#4 0x5f4802 in QBtSession::configureSession() /home/ivan/d/qbittorrent/src/qtlibtorrent/qbtsession.cpp:560
#5 0x605d86 in QBtSession::QBtSession() /home/ivan/d/qbittorrent/src/qtlibtorrent/qbtsession.cpp:159
#6 0x60619f in QBtSession::instance() /home/ivan/d/qbittorrent/src/qtlibtorrent/qbtsession.cpp:2981
#7 0x4f44e9 in MainWindow::MainWindow(QWidget*, QStringList const&) /home/ivan/d/qbittorrent/src/mainwindow.cpp:164
#8 0x4e1d89 in main /home/ivan/d/qbittorrent/src/main.cpp:385
#9 0x7ff136139ec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)
#10 0x4ad918 in _start (/home/ivan/d/qbittorrent-build/qbittorrent+0x4ad918)
SUMMARY: AddressSanitizer: SEGV /usr/include/qt4/QtCore/qhash.h:184 QHashData::firstNode()
==9117== ABORTING

@sledgehammer999
Copy link
Member

Does the crash happen with this request or not? -sorry I didn't understand what you mean-

@sorokin
Copy link
Contributor Author

sorokin commented Nov 16, 2014

I worked for weeks, but now I got this crash (100% reproducible). It looks like TorrentPersistentData is not initialized. But it should be initialized by the time we call QBtSession::instance() in mainwindow.cpp:164.

@sledgehammer999
Copy link
Member

I just had a look. I don't understand how the singleton is actually initialized with this, you probably use C++ in a way that I don't know yet. (hint I am a hobbyist).
I would prefer the singleton method used in qbtsession instead for construction/decontruction of the object. It is far easier understandable.

@sorokin
Copy link
Contributor Author

sorokin commented Nov 16, 2014

Probably miscompilation. After rebuild everything works ok.

@sorokin
Copy link
Contributor Author

sorokin commented Nov 16, 2014

I would prefer the singleton method used in qbtsession instead for construction/decontruction of the object. It is far easier understandable.

The problem with singletons arises when one singleton accesses other in its constructor/destructor.
It is difficult to predict lifetime interaction of different singletons. Thing got worse if you conditionally accesses singleton, in that case relative lifetimes may depends on config options.

In case with PersistentData I want to assert that nobody writes it after it is saved to disk.

@sorokin
Copy link
Contributor Author

sorokin commented Nov 16, 2014

Also I think you don't want to leave ticking timers after QApplication is terminated.

@sledgehammer999
Copy link
Member

And I managed to break the mergability of this. @sorokin can you rebase?

Conflicts:
	src/mainwindow.cpp
	src/mainwindow.h
Conflicts:
	src/mainwindow.cpp
	src/mainwindow.h
	src/qtlibtorrent/qbtsession.cpp
	src/qtlibtorrent/qtorrenthandle.cpp
	src/transferlistwidget.cpp
	src/webui/btjson.cpp
@sorokin
Copy link
Contributor Author

sorokin commented Jan 26, 2015

@sledgehammer999 done

@sledgehammer999
Copy link
Member

@sorokin This is still unmergable. I was just going to fire up qtcreator and work out the merge conflicts. Thankfully I saw your notification first but as I said github says it has merge conflicts.

@sledgehammer999 sledgehammer999 merged commit e334909 into qbittorrent:master Jan 27, 2015
@sledgehammer999
Copy link
Member

Thanks for the code. (I manually fixed the conflicts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants