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

Tribler main does not run on Python 3.10 #7728

Closed
xoriole opened this issue Nov 27, 2023 · 8 comments · Fixed by #7945
Closed

Tribler main does not run on Python 3.10 #7728

xoriole opened this issue Nov 27, 2023 · 8 comments · Fixed by #7945
Assignees

Comments

@xoriole
Copy link
Contributor

xoriole commented Nov 27, 2023

Running Tribler main from the source does not work. It crashes with the following stack trace.
Commit: c09b5b5

Windows 10, Python 3.10

C:\Users\tribler\PycharmProjects\tribler\venv\Scripts\python.exe C:\Users\tribler\PycharmProjects\tribler\src\run_tribler.py
INFO:__main__:Run Tribler: Namespace(torrent='', core=False, gui_test_mode=False, allow_code_injection=False, trace_exception=False, trace_debug=False, testnet=False, chant_testnet=False, trustchain_testnet=False, tunnel_testnet=False)
INFO:__main__:Root state dir: C:\Users\tribler\Application Data\.Tribler
INFO:__main__:Sentry has been initialised in normal mode
INFO:tribler.gui.start_gui:Running GUI in normal mode
INFO:tribler.core.logger.logger:Load logger config: app_mode=tribler-gui, config_path=C:\Users\tribler\PycharmProjects\tribler\src\tribler\core\logger\logger.yaml, dir=C:\Users\tribler\Application Data\.Tribler
[tribler-gui PID:1484] 2023-11-27 16:22:32,203 - INFO - tribler.core.logger.logger(82) - Config loaded for app_mode=tribler-gui
[tribler-gui PID:1484] 2023-11-27 16:22:32,203 - INFO - tribler.core.check_os(115) - Check and enable code tracing. Process name: "gui". Log dir: "C:\Users\tribler\Application Data\.Tribler"
[tribler-gui PID:1484] 2023-11-27 16:22:32,204 - INFO - tribler.core.check_os(97) - Enable fault handler: "C:\Users\tribler\Application Data\.Tribler"
[tribler-gui PID:1484] 2023-11-27 16:22:32,205 - INFO - tribler.core.check_os(44) - Check environment
[tribler-gui PID:1484] 2023-11-27 16:22:32,207 - INFO - tribler.core.check_os(49) - Check free space
[tribler-gui PID:1484] 2023-11-27 16:22:32,208 - INFO - TriblerApplication(25) - Start Tribler application. Win id: "triblerapp". Sys argv: "['C:\\Users\\tribler\\PycharmProjects\\tribler\\src\\run_tribler.py']"
[tribler-gui PID:1484] 2023-11-27 16:22:32,224 - INFO - TriblerApplication(51) - No running instances (socket error: 2)
[tribler-gui PID:1484] 2023-11-27 16:22:32,610 - INFO - tribler.gui.utilities(507) - Available Tribler translations {'Spanish': 'es_ES', 'Portuguese': 'pt_BR', 'Russian': 'ru_RU', 'Chinese': 'zh_CN', 'English': 'en_US'}
[tribler-gui PID:1484] 2023-11-27 16:22:32,610 - INFO - tribler.gui.utilities(508) - System language: ['en-US'], Tribler language: ['en', 'en-US', 'en-Latn-US']
[tribler-gui PID:1484] 2023-11-27 16:22:32,611 - INFO - tribler.gui.start_gui(73) - Start Tribler Window
[tribler-gui PID:1484] 2023-11-27 16:22:32,638 - INFO - Tribler Config(86) - Init. State dir: C:\Users\tribler\Application Data\.Tribler. File: C:\Users\tribler\Application Data\.Tribler\triblerd.conf
[tribler-gui PID:1484] 2023-11-27 16:22:32,639 - INFO - VersionHistory(306) - Files to copy: ['ec_multichain.pem', 'ecpub_multichain.pem', 'secondary_key.pem', 'ec_trustchain_testnet.pem', 'triblerd.conf', 'lt.state']
[tribler-gui PID:1484] 2023-11-27 16:22:32,639 - INFO - VersionHistory(314) - Load: C:\Users\tribler\Application Data\.Tribler\version_history.json
[tribler-gui PID:1484] 2023-11-27 16:22:32,644 - INFO - VersionHistory(333) - Loaded versions: OrderedDict([((7, 12), <TriblerVersion{7.12.1}>), ((7, 13), <TriblerVersion{7.13.1-RC1}>)])
[tribler-gui PID:1484] 2023-11-27 16:22:32,645 - INFO - VersionHistory(248) - Current Tribler version is 7.13.0-GIT
[tribler-gui PID:1484] 2023-11-27 16:22:32,645 - INFO - VersionHistory(258) - The previous version 7.13.1-RC1 used the same state directory as the current version 7.13.0-GIT
[tribler-gui PID:1484] 2023-11-27 16:22:34,560 - INFO - TriblerWindow(409) - Available screen geometry: PyQt5.QtCore.QRect(0, 0, 1280, 920)
[tribler-gui PID:1484] 2023-11-27 16:22:34,561 - INFO - TriblerWindow(410) - Restored window size: PyQt5.QtCore.QSize(1280, 874)
[tribler-gui PID:1484] 2023-11-27 16:22:34,561 - INFO - TriblerWindow(416) - Resize window to the bounded size: PyQt5.QtCore.QSize(1280, 874)
[tribler-gui PID:1484] 2023-11-27 16:22:34,561 - INFO - TriblerWindow(421) - Restored window position: PyQt5.QtCore.QPoint()
[tribler-gui PID:1484] 2023-11-27 16:22:34,562 - INFO - TriblerWindow(427) - Is window outside the screen: False
[tribler-gui PID:1484] 2023-11-27 16:22:34,562 - INFO - TriblerWindow(430) - Move the window to the: PyQt5.QtCore.QPoint()
[tribler-gui PID:1484] 2023-11-27 16:22:35,037 - INFO - UpgradeManager(201) - Start upgrade process
[tribler-gui PID:1484] 2023-11-27 16:22:35,038 - INFO - UpgradeManager(158) - Should cleanup old versions
[tribler-gui PID:1484] 2023-11-27 16:22:35,038 - INFO - VersionHistory(388) - Getting disposable versions...
[tribler-gui PID:1484] 2023-11-27 16:22:35,038 - INFO - VersionHistory(395) - Disposable versions: [<TriblerVersion{7.12.1}>]
[tribler-gui PID:1484] 2023-11-27 16:22:35,039 - INFO - VersionHistory(398) - Disposable versions without skipped: []
[tribler-gui PID:1484] 2023-11-27 16:22:35,039 - INFO - UpgradeManager(166) - No disposable versions. Exit cleanup procedure.
[tribler-gui PID:1484] 2023-11-27 16:22:35,044 - INFO - StateDirUpgradeWorker(47) - Run
[tribler-gui PID:1484] 2023-11-27 16:22:35,045 - INFO - StateDirUpgradeWorker(70) - Upgrade state dir for <VersionHistory[(7, 13), (7, 12)]>
[tribler-gui PID:1484] 2023-11-27 16:22:35,045 - INFO - VersionHistory(366) - State directory should not be copied
[tribler-gui PID:1484] 2023-11-27 16:22:35,045 - INFO - VersionHistory(343) - Save version history
[tribler-gui PID:1484] 2023-11-27 16:22:35,047 - INFO - Tribler Config(100) - Load: C:\Users\tribler\Application Data\.Tribler\7.13\triblerd.conf. State dir: C:\Users\tribler\Application Data\.Tribler\7.13. Reset config on error: True
[tribler-gui PID:1484] 2023-11-27 16:22:35,051 - INFO - Tribler Config(86) - Init. State dir: None. File: None
[tribler-gui PID:1484] 2023-11-27 16:22:35,052 - INFO - TriblerUpgrader(97) - Run
[tribler-gui PID:1484] 2023-11-27 16:22:35,053 - INFO - TriblerUpgrader(384) - Upgrading GigaChannel DB from version 8 to 10
[tribler-gui PID:1484] 2023-11-27 16:22:35,058 - INFO - TriblerUpgrader(203) - Upgrade Pony DB 10 to 11
[tribler-gui PID:1484] 2023-11-27 16:22:35,093 - INFO - tribler.core.upgrade.config_converter(12) - Upgrade config to 7.6
[tribler-gui PID:1484] 2023-11-27 16:22:35,094 - INFO - TriblerUpgrader(220) - Upgrade bandwidth accounting DB 8 to 9
[tribler-gui PID:1484] 2023-11-27 16:22:35,098 - INFO - TriblerUpgrader(187) - Upgrade Pony DB 11 to 12
[tribler-gui PID:1484] 2023-11-27 16:22:35,119 - INFO - TriblerUpgrader(172) - Upgrade Pony DB 12 to 13
[tribler-gui PID:1484] 2023-11-27 16:22:35,138 - INFO - TriblerUpgrader(152) - Upgrade Pony DB from version 13 to version 14
[tribler-gui PID:1484] 2023-11-27 16:22:35,158 - INFO - TriblerUpgrader(136) - Upgrade tags to knowledge
[tribler-gui PID:1484] 2023-11-27 16:22:35,159 - INFO - MigrationTagsToKnowledge(29) - Tags DB path: C:\Users\tribler\Application Data\.Tribler\7.13\sqlite\tags.db
[tribler-gui PID:1484] 2023-11-27 16:22:35,159 - INFO - MigrationTagsToKnowledge(30) - Knowledge DB path: C:\Users\tribler\Application Data\.Tribler\7.13\sqlite\knowledge.db
[tribler-gui PID:1484] 2023-11-27 16:22:35,160 - INFO - MigrationTagsToKnowledge(33) - Starting upgrade procedure for tags DB
[tribler-gui PID:1484] 2023-11-27 16:22:35,160 - INFO - MigrationTagsToKnowledge(36) - Tags DB doesn't exist. Stop procedure.
[tribler-gui PID:1484] 2023-11-27 16:22:35,161 - INFO - TriblerUpgrader(115) - Remove old logs
[tribler-gui PID:1484] 2023-11-27 16:22:35,357 - INFO - TriblerUpgrader(141) - Upgrade Pony DB from version 14 to version 15
[tribler-gui PID:1484] 2023-11-27 16:22:35,388 - INFO - TriblerUpgrader(428) - Upgrade knowledge to tribler.db
[tribler-gui PID:1484] 2023-11-27 16:22:35,389 - INFO - MigrationKnowledgeToTriblerDB(16) - Knowledge DB path: C:\Users\tribler\Application Data\.Tribler\7.13\sqlite\knowledge.db
[tribler-gui PID:1484] 2023-11-27 16:22:35,389 - INFO - MigrationKnowledgeToTriblerDB(17) - Tribler DB path: C:\Users\tribler\Application Data\.Tribler\7.13\sqlite\tribler.db
[tribler-gui PID:1484] 2023-11-27 16:22:35,467 - INFO - MigrationKnowledgeToTriblerDB(31) - File moved successfully.
[tribler-gui PID:1484] 2023-11-27 16:22:35,467 - INFO - TriblerDatabaseMigrationChain(28) - Tribler DB path: C:\Users\tribler\Application Data\.Tribler\7.13\sqlite\tribler.db
[tribler-gui PID:1484] 2023-11-27 16:22:35,527 - INFO - StateDirUpgradeWorker(60) - Finished
Process finished with exit code -1073741819 (0xC0000005)

Ubuntu 22.04, Python 3.10

INFO:__main__:Run Tribler: Namespace(torrent='', core=False, gui_test_mode=False, allow_code_injection=False, trace_exception=False, trace_debug=False, testnet=False, chant_testnet=False, trustchain_testnet=False, tunnel_testnet=False)
INFO:__main__:Root state dir: /home/sysadmin/.Tribler
INFO:__main__:Sentry has been initialised in normal mode
INFO:tribler.gui.start_gui:Running GUI in normal mode
INFO:tribler.gui.start_gui:Enabling a workaround for Ubuntu 21.04+ wayland environment
INFO:tribler.core.logger.logger:Load logger config: app_mode=tribler-gui, config_path=/home/sysadmin/tudelft/github/tribler/src/tribler/core/logger/logger.yaml, dir=/home/sysadmin/.Tribler
[tribler-gui PID:1239760] 2023-11-27 16:35:25,339 - INFO - tribler.core.logger.logger(82) - Config loaded for app_mode=tribler-gui
[tribler-gui PID:1239760] 2023-11-27 16:35:25,339 - INFO - tribler.core.check_os(115) - Check and enable code tracing. Process name: "gui". Log dir: "/home/sysadmin/.Tribler"
[tribler-gui PID:1239760] 2023-11-27 16:35:25,339 - INFO - tribler.core.check_os(97) - Enable fault handler: "/home/sysadmin/.Tribler"
[tribler-gui PID:1239760] 2023-11-27 16:35:25,339 - INFO - tribler.core.check_os(44) - Check environment
[tribler-gui PID:1239760] 2023-11-27 16:35:25,339 - INFO - tribler.core.check_os(49) - Check free space
[tribler-gui PID:1239760] 2023-11-27 16:35:25,339 - INFO - TriblerApplication(25) - Start Tribler application. Win id: "triblerapp". Sys argv: "['/home/sysadmin/tudelft/github/tribler/src/run_tribler.py']"
[tribler-gui PID:1239760] 2023-11-27 16:35:25,394 - INFO - TriblerApplication(51) - No running instances (socket error: 0)
[tribler-gui PID:1239760] 2023-11-27 16:35:25,394 - INFO - TriblerApplication(53) - Received QLocalSocket.ConnectionRefusedError; removing server.
[tribler-gui PID:1239760] 2023-11-27 16:35:25,394 - INFO - TriblerApplication(61) - Cleaning up crashed server...
[tribler-gui PID:1239760] 2023-11-27 16:35:25,394 - INFO - TriblerApplication(69) - Crashed server was removed
[tribler-gui PID:1239760] 2023-11-27 16:35:25,461 - INFO - tribler.gui.utilities(507) - Available Tribler translations {'Portuguese': 'pt_BR', 'Spanish': 'es_ES', 'Chinese': 'zh_CN', 'Russian': 'ru_RU', 'English': 'en_US'}
[tribler-gui PID:1239760] 2023-11-27 16:35:25,461 - INFO - tribler.gui.utilities(508) - System language: ['en-US'], Tribler language: ['en', 'en-US', 'en-Latn-US']
[tribler-gui PID:1239760] 2023-11-27 16:35:25,462 - INFO - tribler.gui.start_gui(73) - Start Tribler Window
[tribler-gui PID:1239760] 2023-11-27 16:35:25,466 - INFO - Tribler Config(86) - Init. State dir: /home/sysadmin/.Tribler. File: /home/sysadmin/.Tribler/triblerd.conf
[tribler-gui PID:1239760] 2023-11-27 16:35:25,467 - INFO - VersionHistory(306) - Files to copy: ['ec_multichain.pem', 'ecpub_multichain.pem', 'secondary_key.pem', 'ec_trustchain_testnet.pem', 'triblerd.conf', 'lt.state']
[tribler-gui PID:1239760] 2023-11-27 16:35:25,467 - INFO - VersionHistory(314) - Load: /home/sysadmin/.Tribler/version_history.json
[tribler-gui PID:1239760] 2023-11-27 16:35:25,467 - INFO - VersionHistory(333) - Loaded versions: OrderedDict([((7, 13), <TriblerVersion{7.13.0-GIT}>)])
[tribler-gui PID:1239760] 2023-11-27 16:35:25,468 - INFO - VersionHistory(248) - Current Tribler version is 7.13.0-GIT
[tribler-gui PID:1239760] 2023-11-27 16:35:25,468 - INFO - VersionHistory(255) - The previously started version is the same as the current one
[tribler-gui PID:1239760] 2023-11-27 16:35:25,901 - INFO - TriblerWindow(409) - Available screen geometry: PyQt5.QtCore.QRect(0, 91, 1920, 1080)
[tribler-gui PID:1239760] 2023-11-27 16:35:25,901 - INFO - TriblerWindow(410) - Restored window size: PyQt5.QtCore.QSize(1233, 600)
[tribler-gui PID:1239760] 2023-11-27 16:35:25,901 - INFO - TriblerWindow(416) - Resize window to the bounded size: PyQt5.QtCore.QSize(1233, 600)
[tribler-gui PID:1239760] 2023-11-27 16:35:25,901 - INFO - TriblerWindow(421) - Restored window position: PyQt5.QtCore.QPoint(313, 339)
[tribler-gui PID:1239760] 2023-11-27 16:35:25,901 - INFO - TriblerWindow(427) - Is window outside the screen: False
[tribler-gui PID:1239760] 2023-11-27 16:35:25,902 - INFO - TriblerWindow(430) - Move the window to the: PyQt5.QtCore.QPoint(313, 339)
[tribler-gui PID:1239760] 2023-11-27 16:35:26,070 - INFO - UpgradeManager(201) - Start upgrade process
[tribler-gui PID:1239760] 2023-11-27 16:35:26,070 - INFO - UpgradeManager(158) - Should cleanup old versions
[tribler-gui PID:1239760] 2023-11-27 16:35:26,071 - INFO - UpgradeManager(161) - Last run version is the same as the current version. Exit cleanup procedure.
[tribler-gui PID:1239760] 2023-11-27 16:35:26,071 - INFO - StateDirUpgradeWorker(47) - Run
[tribler-gui PID:1239760] 2023-11-27 16:35:26,072 - INFO - StateDirUpgradeWorker(70) - Upgrade state dir for <VersionHistory[(7, 13)]>
[tribler-gui PID:1239760] 2023-11-27 16:35:26,072 - INFO - VersionHistory(366) - State directory should not be copied
[tribler-gui PID:1239760] 2023-11-27 16:35:26,072 - INFO - Tribler Config(100) - Load: /home/sysadmin/.Tribler/7.13/triblerd.conf. State dir: /home/sysadmin/.Tribler/7.13. Reset config on error: True
[tribler-gui PID:1239760] 2023-11-27 16:35:26,074 - INFO - Tribler Config(86) - Init. State dir: None. File: None
[tribler-gui PID:1239760] 2023-11-27 16:35:26,074 - INFO - TriblerUpgrader(97) - Run
[tribler-gui PID:1239760] 2023-11-27 16:35:26,075 - INFO - TriblerUpgrader(384) - Upgrading GigaChannel DB from version 8 to 10
[tribler-gui PID:1239760] 2023-11-27 16:35:26,076 - INFO - TriblerUpgrader(203) - Upgrade Pony DB 10 to 11
[tribler-gui PID:1239760] 2023-11-27 16:35:26,085 - INFO - tribler.core.upgrade.config_converter(12) - Upgrade config to 7.6
[tribler-gui PID:1239760] 2023-11-27 16:35:26,086 - INFO - TriblerUpgrader(220) - Upgrade bandwidth accounting DB 8 to 9
[tribler-gui PID:1239760] 2023-11-27 16:35:26,086 - INFO - TriblerUpgrader(187) - Upgrade Pony DB 11 to 12
[tribler-gui PID:1239760] 2023-11-27 16:35:26,095 - INFO - TriblerUpgrader(172) - Upgrade Pony DB 12 to 13
[tribler-gui PID:1239760] 2023-11-27 16:35:26,101 - INFO - TriblerUpgrader(152) - Upgrade Pony DB from version 13 to version 14
[tribler-gui PID:1239760] 2023-11-27 16:35:26,109 - INFO - TriblerUpgrader(136) - Upgrade tags to knowledge
[tribler-gui PID:1239760] 2023-11-27 16:35:26,109 - INFO - MigrationTagsToKnowledge(29) - Tags DB path: /home/sysadmin/.Tribler/7.13/sqlite/tags.db
[tribler-gui PID:1239760] 2023-11-27 16:35:26,110 - INFO - MigrationTagsToKnowledge(30) - Knowledge DB path: /home/sysadmin/.Tribler/7.13/sqlite/knowledge.db
[tribler-gui PID:1239760] 2023-11-27 16:35:26,110 - INFO - MigrationTagsToKnowledge(33) - Starting upgrade procedure for tags DB
[tribler-gui PID:1239760] 2023-11-27 16:35:26,110 - INFO - MigrationTagsToKnowledge(36) - Tags DB doesn't exist. Stop procedure.
[tribler-gui PID:1239760] 2023-11-27 16:35:26,110 - INFO - TriblerUpgrader(115) - Remove old logs
[tribler-gui PID:1239760] 2023-11-27 16:35:26,110 - INFO - TriblerUpgrader(141) - Upgrade Pony DB from version 14 to version 15
[tribler-gui PID:1239760] 2023-11-27 16:35:26,118 - INFO - TriblerUpgrader(428) - Upgrade knowledge to tribler.db
[tribler-gui PID:1239760] 2023-11-27 16:35:26,118 - INFO - MigrationKnowledgeToTriblerDB(16) - Knowledge DB path: /home/sysadmin/.Tribler/7.13/sqlite/knowledge.db
[tribler-gui PID:1239760] 2023-11-27 16:35:26,119 - INFO - MigrationKnowledgeToTriblerDB(17) - Tribler DB path: /home/sysadmin/.Tribler/7.13/sqlite/tribler.db
[tribler-gui PID:1239760] 2023-11-27 16:35:26,119 - INFO - MigrationKnowledgeToTriblerDB(21) - Knowledge DB doesn't exist. Stop procedure.
[tribler-gui PID:1239760] 2023-11-27 16:35:26,119 - INFO - TriblerDatabaseMigrationChain(28) - Tribler DB path: /home/sysadmin/.Tribler/7.13/sqlite/tribler.db
[tribler-gui PID:1239760] 2023-11-27 16:35:26,126 - INFO - Migration (TriblerDB)(30) - Function scheme_migration_0 is not executed because DB version is not equal to 0. The current db version is 1
[tribler-gui PID:1239760] 2023-11-27 16:35:26,126 - INFO - StateDirUpgradeWorker(60) - Finished

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
@drew2a
Copy link
Contributor

drew2a commented Nov 27, 2023

It works for me if I run Tribler from the commit you specified.

OS: macOS.

Also, all checks on GitHub seem to work correctly with the latest main: https://github.com/Tribler/tribler/actions/workflows/!main.yml

@qstokkink
Copy link
Contributor

qstokkink commented Nov 27, 2023

This sounds pretty severe. More info: cannot reproduce on Ubuntu 20.04.6 LTS + Python 3.8 with latest main (c09b5b5). Both a clean and dirty ~/.Tribler work for me.

@egbertbouman
Copy link
Member

I can't reproduce this either (Windows 10 + Python 3.8).

@xoriole
Copy link
Contributor Author

xoriole commented Nov 27, 2023

I can consistently reproduce the issue both on my office PC and home PC, both Ubuntu 22.04. Here is a screen recording of it.
Screencast from 27-11-23 18:35:03.webm

Here are the exact steps to reproduce:

  1. Move/Delete the current state directory
  2. Run Tribler. On the fresh state directory, it works fine. Shutdown Tribler.
  3. Run Tribler second time onwards. It crashes with segfault.

On a fresh state directory, there is no issue so it is consistent with GitHub Actions success run since those actions likely run on fresh state directory. The issue lies on the second run onwards and is likely related to the upgrading process which requires further investigation.

Note: Python version used is 3.10.

@xoriole
Copy link
Contributor Author

xoriole commented Nov 27, 2023

The issue can also be reproduced using the binary built using GitHub actions - Ubuntu build with Python 3.10
Here is the build artifact: https://github.com/Tribler/tribler/actions/runs/7009415435

Checking the coredump, here is the stack trace top
image

Here is the thread stacktrace

Thread 1 (Thread 0x7f39acbff640 (LWP 33965)):
#0  __pthread_kill_implementation (no_tid=0, signo=11, threadid=139885688124992) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=11, threadid=139885688124992) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=139885688124992, signo=signo@entry=11) at ./nptl/pthread_kill.c:89
#3  0x00007f3a43c42476 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
#4  <signal handler called>
#5  0x00007f3a43822e80 in PyObject_GC_Del () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#6  0x00007f3a41b6bed6 in ?? () from /home/user/github/tribler/tribler/dist/tribler/lib-dynload/_sqlite3.cpython-310-x86_64-linux-gnu.so
#7  0x00007f3a43716c2d in ?? () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#8  0x00007f3a4371bf68 in ?? () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#9  0x00007f3a43716ec8 in ?? () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#10 0x00007f3a4371afd2 in _PyDict_DelItem_KnownHash () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#11 0x00007f3a4388572c in ?? () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#12 0x00007f3a4372868e in ?? () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#13 0x00007f3a4379618e in PyObject_ClearWeakRefs () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#14 0x00007f3a43882eea in ?? () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#15 0x00007f3a43716c2d in ?? () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#16 0x00007f3a4371bf68 in ?? () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#17 0x00007f3a438053b5 in PyThreadState_Clear () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#18 0x00007f3a43809fa8 in PyGILState_Release () from /home/user/github/tribler/tribler/dist/tribler/libpython3.10.so.1.0
#19 0x00007f3a4021cb47 in PyQtSlotProxy::qt_metacall(QMetaObject::Call, int, void**) () from /home/user/github/tribler/tribler/dist/tribler/PyQt5/QtCore.abi3.so
#20 0x00007f3a3fad4877 in void doActivate<false>(QObject*, int, void**) () from /home/user/github/tribler/tribler/dist/tribler/libQt5Core.so.5
#21 0x00007f3a3f8b16e7 in QThread::started(QThread::QPrivateSignal) () from /home/user/github/tribler/tribler/dist/tribler/libQt5Core.so.5
#22 0x00007f3a3f8b382c in QThreadPrivate::start(void*) () from /home/user/github/tribler/tribler/dist/tribler/libQt5Core.so.5
#23 0x00007f3a43c94ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#24 0x00007f3a43d26a40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

This is likely the underlying issue?

@xoriole
Copy link
Contributor Author

xoriole commented Nov 27, 2023

On further investigation, it seems TriblerDatabaseMigrationChain (#7622) has unexpected results when running on QT Thread.

Here are two minimal reproducible examples for Python3.10

# example1.py
from pathlib import Path
from PyQt5.QtCore import QThread
from tribler.core.upgrade.tribler_db.migration_chain import TriblerDatabaseMigrationChain

STATE_DIR = '/home/user/.Tribler/7.13'


class WorkerThread(QThread):
    def run(self):
        print("Thread Starting")
        migration_chain = TriblerDatabaseMigrationChain(Path(STATE_DIR))
        migration_chain.execute()  # <-- This is where segfault is triggered when the thread finishes
        print("Thread Finished")


if __name__ == "__main__":
    thread = WorkerThread()
    thread.start()
    thread.wait()
    print("Main Thread Finished")
# example2.py
from PyQt5.QtCore import QThread
from tribler.core.components.database.db.tribler_database import TriblerDatabase
from tribler.core.upgrade.tribler_db.scheme_migrations.scheme_migration_0 import scheme_migration_0

STATE_DIR = '/home/user/.Tribler/7.13'
DB_PATH = f'{STATE_DIR}/sqlite/tribler.db'


class WorkerThread(QThread):
    def run(self):
        print("Thread Starting")
        db = TriblerDatabase(DB_PATH, check_tables=False)
        scheme_migration_0(db, state_dir=STATE_DIR)  # <-- This is where segfault is triggered when the thread finishes
        print("Thread Finished")


if __name__ == "__main__":
    thread = WorkerThread()
    thread.start()
    thread.wait()
    print("Main Thread Finished")

Running these example codes result in:

Thread Starting
Thread Finished

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

@xoriole xoriole changed the title Tribler main does not run from source Tribler main does not run on Python 3.10 Nov 27, 2023
@qstokkink
Copy link
Contributor

Reproduced with Python 3.10.

screenshot

@kozlovsky
Copy link
Contributor

I was able to reproduce and fix the issue; I need a bit more time to check the details. As @xoriole found, the problem is indeed sqlite-related, and to fix it, we need to properly close the database connection when we stop using some thread. I'll try to implement a generic solution at the db_session level that handles this case automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants