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
mss with PyQt5 crash in segmentation fault #102
Comments
Could you upgrade to MSS 4.0.1? It includes several GNU/Linux bugfixes. |
Now I upgraded it. Same code still makes a segfault. |
Hm it is working for me 🤔 I created a specific test and you can see all tests are green. May I ask you to ensure you are using the 4.0.1 version with the snippet below ? import sys
import mss
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
assert app
assert mss.__version__ == "4.0.1"
with mss.mss() as sct:
print(sct.shot()) |
Hello BoboTiG. I copied your code above and runned it with the same result. This is the output QApplication: invalid style override passed, ignoring it.
Segmenteringsfel Was that what you expected me to do? Kind regards /Björn |
Ah! This is interesting :) It seems this is a PyQt5 error. If you execute that code, does it works? import sys
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
print(app) |
The answer was: QApplication: invalid style override passed, ignoring it.
<PyQt5.QtWidgets.QApplication object at 0x7fb142832558> Well, I have actually myself started to believe it something with PyQt5! But someone told me to make a bug report for mss so I did. =) |
So let's try to find the cause :)
import mss
assert mss.__version__ == "4.0.1"
with mss.mss() as sct:
print(sct.shot())
import mss
from PyQt5 import QtWidgets
assert mss.__version__ == "4.0.1"
with mss.mss() as sct:
print(sct.shot())
import os
print(repr(os.getenv("DISPLAY"))) |
1 and 2 works. But this do not work: import mss
from PyQt5 import QtWidgets
import sys
app = QtWidgets.QApplication(sys.argv)
assert mss.__version__ == "4.0.1"
with mss.mss() as sct:
print(sct.shot()) The output from code number 3 is: ':0' |
I have now tried to install both mss and PyQt5 into a virtual environment, but still the same problem. |
If you first instanciante MSS, does it work? import sys
import mss
from PyQt5 import QtWidgets
with mss.mss() as sct:
print(sct.shot())
app = QtWidgets.QApplication(sys.argv) |
Yes. That code actually worked. But I cant see that is the solution in a bigger program? I want to be able to call a function that do the screenshot and I cannot have the app = QtWidgets in there? |
It would mean PyQt is altering something? 🤔 I need to be able to reproduce first. I will have a look later. |
Im not sure what you mean. It breaks in the "with mss() as sct:" I have found out. Something strange is that if I run the program in console or run it from within PyCharm, it crashes with Segmentation fault. But if I Debug the code in PyCharm, even without breakpoints, it do not crash! |
I do not know if this says you so much. But I have seen on the internet that many asks for output from gdb. So here it is: gdb python3
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python3...done.
(gdb) run GUI_Exec.py
Starting program: /home/mrbear/Program/anaconda3/bin/python3 GUI_Exec.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffead76700 (LWP 6812)]
QApplication: invalid style override passed, ignoring it.
Gurka
[New Thread 0x7fffe994a700 (LWP 6814)]
Traceback (most recent call last):
File "GUI_Exec.py", line 167, in button_screen1_testpicsave
with mss() as sct:
TypeError: 'module' object is not callable
Thread 1 "python3" received signal SIGABRT, Aborted.
0x00007ffff7825428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: Filen eller katalogen finns inte.
(gdb) backtrace
#0 0x00007ffff7825428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff782702a in __GI_abort () at abort.c:89
#2 0x00007ffff48703bc in QMessageLogger::fatal(char const*, ...) const () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#3 0x00007fffee4134ce in pyqt5_err_print() () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtCore.so
#4 0x00007fffee4192d5 in PyQtSlotProxy::unislot(void**) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtCore.so
#5 0x00007fffee41a267 in PyQtSlotProxy::qt_metacall(QMetaObject::Call, int, void**) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtCore.so
#6 0x00007ffff4a7f2f4 in QMetaObject::activate(QObject*, int, int, void**) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#7 0x00007ffff59883a2 in QAbstractButton::clicked(bool) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#8 0x00007ffff59885a4 in QAbstractButtonPrivate::emitClicked() () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#9 0x00007ffff598a13e in QAbstractButtonPrivate::click() () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#10 0x00007ffff598a295 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#11 0x00007ffff6286ac3 in sipQPushButton::mouseReleaseEvent(QMouseEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtWidgets.so
#12 0x00007ffff58e0688 in QWidget::event(QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#13 0x00007ffff62ed393 in sipQPushButton::event(QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtWidgets.so
#14 0x00007ffff58a3e2c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#15 0x00007ffff58aba13 in QApplication::notify(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#16 0x00007ffff62f522e in sipQApplication::notify(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtWidgets.so
#17 0x00007ffff4a542d8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#18 0x00007ffff58aa50f in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()
from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#19 0x00007ffff58fa1dd in QWidgetWindow::handleMouseEvent(QMouseEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#20 0x00007ffff58fcae3 in QWidgetWindow::event(QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#21 0x00007ffff58a3e2c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#22 0x00007ffff58aaf60 in QApplication::notify(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#23 0x00007ffff62f522e in sipQApplication::notify(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtWidgets.so
#24 0x00007ffff4a542d8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#25 0x00007ffff5080f6f in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5
#26 0x00007ffff5082e65 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5
#27 0x00007ffff505ebdb in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5
#28 0x00007fffecc530db in QPAEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#29 0x00007ffff4a52c3a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#30 0x00007ffff4a5b640 in QCoreApplication::exec() () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#31 0x00007ffff6180800 in meth_QApplication_exec_ () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtWidgets.so
#32 0x0000555555662ad1 in _PyCFunction_FastCallDict ()
#33 0x00005555556f267c in call_function ()
#34 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#35 0x00005555556ecd7b in _PyFunction_FastCallDict ()
#36 0x0000555555662f5f in _PyObject_FastCallDict ()
#37 0x0000555555667a03 in _PyObject_Call_Prepend ()
#38 0x000055555566299e in PyObject_Call ()
#39 0x00005555556bf02b in slot_tp_init ()
#40 0x00005555556f29b7 in type_call ()
#41 0x0000555555662d7b in _PyObject_FastCallDict ()
#42 0x00005555556f27ce in call_function ()
#43 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#44 0x00005555556ed459 in PyEval_EvalCodeEx ()
#45 0x00005555556ee1ec in PyEval_EvalCode ()
#46 0x00005555557689a4 in run_mod ()
#47 0x0000555555768da1 in PyRun_FileExFlags ()
#48 0x0000555555768fa4 in PyRun_SimpleFileExFlags ()
#49 0x000055555576ca9e in Py_Main ()
#50 0x00005555556344be in main ()
(gdb) |
Could you retry with correct call to MSS? with mss.mss() as sct: Instead of with mss() as sct: |
Ohh, I have done after the examples from the infopage of mss. But here it is: (gdb) run GUI_Exec.py -style Fusion
Starting program: /home/mrbear/Program/anaconda3/bin/python3 GUI_Exec.py -style Fusion
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffead76700 (LWP 7422)]
[New Thread 0x7fffe994a700 (LWP 7423)]
Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) backtrace
#0 0x0000000000000000 in ?? ()
#1 0x00007fffe11543f1 in init_mparams.part () from /home/mrbear/Program/anaconda3/bin/../lib/libffi.so.6
#2 0x00007fffe1154c35 in ffi_closure_alloc () from /home/mrbear/Program/anaconda3/bin/../lib/libffi.so.6
#3 0x00007fffe8d0b749 in _ctypes_alloc_callback () from /home/mrbear/Program/anaconda3/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so
#4 0x00007fffe8d0c023 in PyCFuncPtr_new () from /home/mrbear/Program/anaconda3/lib/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so
#5 0x00005555556f2965 in type_call ()
#6 0x0000555555662d7b in _PyObject_FastCallDict ()
#7 0x00005555556f27ce in call_function ()
#8 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#9 0x00005555556ec70b in fast_function ()
#10 0x00005555556f2755 in call_function ()
#11 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#12 0x00005555556ed459 in PyEval_EvalCodeEx ()
#13 0x00005555556ee1ec in PyEval_EvalCode ()
#14 0x00005555557125bd in builtin_exec ()
#15 0x0000555555665a61 in PyCFunction_Call ()
#16 0x0000555555719fdb in _PyEval_EvalFrameDefault ()
#17 0x00005555556eba94 in _PyEval_EvalCodeWithName ()
#18 0x00005555556ec941 in fast_function ()
#19 0x00005555556f2755 in call_function ()
#20 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#21 0x00005555556ec70b in fast_function ()
#22 0x00005555556f2755 in call_function ()
#23 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#24 0x00005555556ec70b in fast_function ()
#25 0x00005555556f2755 in call_function ()
#26 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#27 0x00005555556ec70b in fast_function ()
#28 0x00005555556f2755 in call_function ()
#29 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#30 0x00005555556ecd7b in _PyFunction_FastCallDict ()
#31 0x0000555555662f5f in _PyObject_FastCallDict ()
#32 0x00005555556a7670 in _PyObject_CallMethodIdObjArgs ()
#33 0x0000555555659a70 in PyImport_ImportModuleLevelObject ()
#34 0x0000555555717033 in _PyEval_EvalFrameDefault ()
#35 0x00005555556ed459 in PyEval_EvalCodeEx ()
#36 0x00005555556ee1ec in PyEval_EvalCode ()
#37 0x00005555557125bd in builtin_exec ()
#38 0x0000555555665a61 in PyCFunction_Call ()
#39 0x0000555555719fdb in _PyEval_EvalFrameDefault ()
#40 0x00005555556eba94 in _PyEval_EvalCodeWithName ()
#41 0x00005555556ec941 in fast_function ()
#42 0x00005555556f2755 in call_function ()
#43 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#44 0x00005555556ec70b in fast_function ()
#45 0x00005555556f2755 in call_function ()
#46 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#47 0x00005555556ec70b in fast_function ()
#48 0x00005555556f2755 in call_function ()
#49 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#50 0x00005555556ec70b in fast_function ()
#51 0x00005555556f2755 in call_function ()
#52 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#53 0x00005555556ecd7b in _PyFunction_FastCallDict ()
#54 0x0000555555662f5f in _PyObject_FastCallDict ()
#55 0x00005555556a7670 in _PyObject_CallMethodIdObjArgs ()
#56 0x0000555555659a70 in PyImport_ImportModuleLevelObject ()
#57 0x0000555555717033 in _PyEval_EvalFrameDefault ()
#58 0x00005555556eba94 in _PyEval_EvalCodeWithName ()
#59 0x00005555556ec941 in fast_function ()
#60 0x00005555556f2755 in call_function ()
#61 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#62 0x00005555556ecd7b in _PyFunction_FastCallDict ()
#63 0x0000555555662f5f in _PyObject_FastCallDict ()
#64 0x0000555555667a03 in _PyObject_Call_Prepend ()
---Type <return> to continue, or q <return> to quit---
#65 0x000055555566299e in PyObject_Call ()
#66 0x00007fffee418af5 in PyQtSlot::call(_object*, _object*) const () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtCore.so
#67 0x00007fffee419000 in PyQtSlot::invoke(void**, _object*, void*, bool) const () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtCore.so
#68 0x00007fffee41927b in PyQtSlotProxy::unislot(void**) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtCore.so
#69 0x00007fffee41a267 in PyQtSlotProxy::qt_metacall(QMetaObject::Call, int, void**) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtCore.so
#70 0x00007ffff4a7f2f4 in QMetaObject::activate(QObject*, int, int, void**) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#71 0x00007ffff59883a2 in QAbstractButton::clicked(bool) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#72 0x00007ffff59885a4 in QAbstractButtonPrivate::emitClicked() () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#73 0x00007ffff598a13e in QAbstractButtonPrivate::click() () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#74 0x00007ffff598a295 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#75 0x00007ffff6286ac3 in sipQPushButton::mouseReleaseEvent(QMouseEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtWidgets.so
#76 0x00007ffff58e0688 in QWidget::event(QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#77 0x00007ffff62ed393 in sipQPushButton::event(QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtWidgets.so
#78 0x00007ffff58a3e2c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#79 0x00007ffff58aba13 in QApplication::notify(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#80 0x00007ffff62f522e in sipQApplication::notify(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtWidgets.so
#81 0x00007ffff4a542d8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#82 0x00007ffff58aa50f in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()
from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#83 0x00007ffff58fa1dd in QWidgetWindow::handleMouseEvent(QMouseEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#84 0x00007ffff58fcae3 in QWidgetWindow::event(QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#85 0x00007ffff58a3e2c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#86 0x00007ffff58aaf60 in QApplication::notify(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Widgets.so.5
#87 0x00007ffff62f522e in sipQApplication::notify(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtWidgets.so
#88 0x00007ffff4a542d8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#89 0x00007ffff5080f6f in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5
#90 0x00007ffff5082e65 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5
#91 0x00007ffff505ebdb in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5
#92 0x00007fffecc530db in QPAEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/../../lib/libQt5XcbQpa.so.5
#93 0x00007ffff4a52c3a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#94 0x00007ffff4a5b640 in QCoreApplication::exec() () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5Core.so.5
#95 0x00007ffff6180800 in meth_QApplication_exec_ () from /home/mrbear/Program/anaconda3/lib/python3.6/site-packages/PyQt5/QtWidgets.so
#96 0x0000555555662ad1 in _PyCFunction_FastCallDict ()
#97 0x00005555556f267c in call_function ()
#98 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#99 0x00005555556ecd7b in _PyFunction_FastCallDict ()
#100 0x0000555555662f5f in _PyObject_FastCallDict ()
#101 0x0000555555667a03 in _PyObject_Call_Prepend ()
#102 0x000055555566299e in PyObject_Call ()
#103 0x00005555556bf02b in slot_tp_init ()
#104 0x00005555556f29b7 in type_call ()
#105 0x0000555555662d7b in _PyObject_FastCallDict ()
#106 0x00005555556f27ce in call_function ()
#107 0x0000555555714cba in _PyEval_EvalFrameDefault ()
#108 0x00005555556ed459 in PyEval_EvalCodeEx ()
#109 0x00005555556ee1ec in PyEval_EvalCode ()
#110 0x00005555557689a4 in run_mod ()
#111 0x0000555555768da1 in PyRun_FileExFlags ()
#112 0x0000555555768fa4 in PyRun_SimpleFileExFlags ()
#113 0x000055555576ca9e in Py_Main ()
#114 0x00005555556344be in main ()
(gdb) |
What is the full content of |
# -*- coding: utf-8 -*-
#https://python-mss.readthedocs.io/examples.html
from PyQt5 import QtWidgets #, QtCore, QtGui,
from mss import mss
import mss
import mss.tools
import GUI
import os, time
class GUI_Exec():
monitor = 1
waittime_nextshoot = 5
run_state = "stopped"
filepath = ""
screen1_dumps = 0
screen2_dumps = 0
screen3_dumps = 0
area1_dumps = 0
area2_dumps = 0
def __init__(self):
import sys
# Nedan rad visar en varning vid start. Den går att undvika om man lägger till -style Fusion vid start av program
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
self.ui = GUI.Ui_MainWindow()
self.ui.setupUi(MainWindow)
# Start och stoppknappar
self.ui.Button_Start.clicked.connect(self.button_start_clicked)
self.ui.Button_Stop.clicked.connect(self.button_stop_clicked)
# Knapparna för nollställning av räknarna
self.ui.Button_Reset_Screen1.clicked.connect(self.button_screen1_reset)
self.ui.Button_Reset_Screen2.clicked.connect(self.button_screen2_reset)
self.ui.Button_Reset_Screen3.clicked.connect(self.button_screen3_reset)
self.ui.Button_Reset_Area1.clicked.connect(self.button_area1_reset)
self.ui.Button_Reset_Area2.clicked.connect(self.button_area2_reset)
# Knapparna för att spara en testbild från en specifik skärm
self.ui.Button_TestPic_Screen1.clicked.connect(self.button_screen1_testpicsave)
self.ui.Button_TestPic_Screen2.clicked.connect(self.button_screen2_testpicsave)
self.ui.Button_TestPic_Screen3.clicked.connect(self.button_screen3_testpicsave)
self.ui.Button_TestPic_Area1.clicked.connect(self.button_area1_testpicsave)
self.ui.Button_TestPic_Area2.clicked.connect(self.button_area2_testpicsave)
# Tidsstyrningen
self.ui.timeSlider.valueChanged.connect(self.slider_changed)
# Sökvägen
self.ui.lineEdit_path.editingFinished.connect(self.line_edit_path_changed)
self.start_init()
MainWindow.show()
sys.exit(app.exec_())
def start_init(self):
""" För att initiera olika saker direkt vid uppstart """
self.start_stop_button_fade()
self.ui.lineEdit_settime.setText(str(self.waittime_nextshoot))
self.filepath = os.getcwd()
self.ui.lineEdit_path.setText(self.filepath)
# Fyll på alla räknarfält med 0
self.ui.lineEdit_Screen1_Counter.setText(str(self.screen1_dumps))
self.ui.lineEdit_Screen2_Counter.setText(str(self.screen2_dumps))
self.ui.lineEdit_Screen3_Counter.setText(str(self.screen3_dumps))
self.ui.lineEdit_Area1_Counter.setText(str(self.area1_dumps))
self.ui.lineEdit_Area2_Counter.setText(str(self.area2_dumps))
def start_stop_button_fade(self):
""" För att sätta start och stopp knapparna till rätt fade """
if self.run_state == "stopped":
self.ui.Button_Stop.setEnabled(False)
self.ui.Button_Start.setEnabled(True)
self.ui.radioButton_screen1.setEnabled(True)
self.ui.radioButton_screen2.setEnabled(True)
self.ui.radioButton_screen3.setEnabled(True)
elif self.run_state == "running":
self.ui.Button_Stop.setEnabled(True)
self.ui.Button_Start.setEnabled(False)
self.ui.radioButton_screen1.setEnabled(False)
self.ui.radioButton_screen2.setEnabled(False)
self.ui.radioButton_screen3.setEnabled(False)
def button_start_clicked(self):
self.run_state = "running"
self.start_stop_button_fade()
# Check if folders exist or create them
if not os.path.isdir(self.filepath):
self.button_stop_clicked()
if self.ui.radioButton_screen1.isChecked() == True:
# Skapa mapp Screen1 om den inte finns
if not os.path.isdir(self.filepath + "/Screen1"):
os.mkdir(self.filepath + "/Screen1")
if self.ui.radioButton_screen2.isChecked() == True:
# Skapa mapp Screen1 om den inte finns
if not os.path.isdir(self.filepath + "/Screen2"):
os.mkdir(self.filepath + "/Screen2")
if self.ui.radioButton_screen3.isChecked() == True:
# Skapa mapp Screen1 om den inte finns
if not os.path.isdir(self.filepath + "/Screen3"):
os.mkdir(self.filepath + "/Screen3")
while self.run_state == "running":
goal_time = time.time() + self.waittime_nextshoot
while time.time() <= goal_time:
countvalue = goal_time - time.time()
if countvalue % 1 > 0.9 or countvalue < 0.1:
self.ui.lineEdit_time_nextshoot.setText(str(round(countvalue)))
if self.run_state == "stopped":
self.ui.lineEdit_time_nextshoot.setText("")
break
time.sleep(0.1)
QtWidgets.QApplication.processEvents()
if self.run_state == "running":
self.make_screendump()
def button_stop_clicked(self):
self.run_state = "stopped"
self.start_stop_button_fade()
def button_screen1_reset(self):
self.screen1_dumps = 0
self.ui.lineEdit_Screen1_Counter.setText(str(self.screen1_dumps))
def button_screen2_reset(self):
self.screen2_dumps = 0
self.ui.lineEdit_Screen2_Counter.setText(str(self.screen2_dumps))
def button_screen3_reset(self):
self.screen3_dumps = 0
self.ui.lineEdit_Screen3_Counter.setText(str(self.screen3_dumps))
def button_area1_reset(self):
self.area1_dumps = 0
self.ui.lineEdit_Area1_Counter.setText(str(self.area1_dumps))
def button_area2_reset(self):
self.area2_dumps = 0
self.ui.lineEdit_Area2_Counter.setText(str(self.area2_dumps))
def button_screen1_testpicsave(self):
# Kod för att ta en testbild från skärm 1 och spara den
with mss.mss() as sct:
filename = sct.shot(mon = 1, output = self.filepath + "/Screen1.png")
def button_screen2_testpicsave(self):
# Kod för att ta en testbild från skärm 2 och spara den
with mss() as sct:
filename = sct.shot(mon = 2, output = self.filepath + "/Screen2.png")
def button_screen3_testpicsave(self):
# Kod för att ta en testbild från skärm 3 och spara den
with mss() as sct:
filename = sct.shot(mon = 3, output = self.filepath + "/Screen3.png")
def button_area1_testpicsave(self):
# Kod för att ta en testbild från Area 1 och spara den
# TODO Fixa denna
with mss.mss() as sct:
# The screen part to capture
monitor = {"top" : 500, "left" : 3600, "width" : 400, "height" : 400}
output = "sct-{top}x{left}_{width}x{height}.png".format(**monitor)
# Grab the data
sct_img = sct.grab(monitor)
mss.tools.to_png(sct_img.rgb, sct_img.size, output = output)
print(output)
def button_area2_testpicsave(self):
# TODO Kopiera denna från ovanstående när ovan är klar
pass
def slider_changed(self):
""" För att uppdatera väntetid när slidern ändras """
self.waittime_nextshoot = self.ui.timeSlider.value() / 10
self.ui.lineEdit_settime.setText(str(self.waittime_nextshoot))
def line_edit_path_changed(self):
""" När sökvägsrutan blivit ändrad """
self.filepath = self.ui.lineEdit_path.text()
def path_updated(self):
self.filepath = self.ui.lineEdit_path.text
def make_screendump(self):
with mss() as sct:
if self.ui.radioButton_screen1.isChecked() == True:
self.screen1_dumps += 1
filename = sct.shot(mon = 1, output = self.filepath + "/Screen1/Bild" + str(self.screen1_dumps).zfill(4) + ".png")
#print(filename)
self.ui.lcdNumber_Screen1.display(self.screen1_dumps)
if self.ui.radioButton_screen2.isChecked() == True:
self.screen2_dumps += 1
filename = sct.shot(mon = 2, output = self.filepath + "/Screen2/Bild" + str(self.screen2_dumps).zfill(4) + ".png")
#print(filename)
self.ui.lcdNumber_Screen2.display(self.screen2_dumps)
if self.ui.radioButton_screen3.isChecked() == True:
self.screen3_dumps += 1
filename = sct.shot(mon = 3, output = self.filepath + "/Screen3/Bild" + str(self.screen3_dumps).zfill(4) + ".png")
#print(filename)
self.ui.lcdNumber_Screen3.display(self.screen3_dumps)
if __name__ == "__main__":
my_GUI = GUI_Exec() |
Hello again! My conclusion is this: I went into linux.py and started to put prints in every function in mss, but no result. So o runned a python console and tried: from PyQt5 import QtWidgets BOOM! There is your segfault! So, that is not your code... Will you do anything more? I have anyway learned a lot from this! |
This is a good news for MSS, but you are still stuck :)
I think you could open an issue on Anaconda. There may be an issue somewhere when instancing ctypes.
The next step, if you feel confident, it to add prints inside ctype source code to check where it breaks.
|
You have been very helpful! Take care! Kind regards /Björn |
I found a workaround! |
What is the workaround?
And could you copy the ctype code that was crashing?
|
Well, I imported ctypes in my code. Seems like PyQt5 do not like that ctypes get loaded after I do app = QtWidgets.QApplication(sys.argv) Last in the ctypes lib init file, there is a "_reset_cache()" |
Well done :)
Did you check inside that function what line exactly?
|
Yes, I checked where the function goes, but it made me no sense really. It seems that it is the amount of inparam to the function that makes it. So it is the CFUNCTYPE that leaves the segfault |
Thank you. I'm very proud to find some kind of solution. Thanks to you! I have learned a lot today. =) |
Hm yes, it is a little ovscure.
Well, thanks for the investigation!
If you are motivated, perhaps could you open an issue on Anaconda; it may help others ;)
Glad it is fixed for you!
|
I'm very happy to! It fixed because of you, thank you again! |
And thanks for your perseverance :) |
General OS information:
RELEASE=18
CODENAME=sarah
EDITION="Cinnamon 64-bit"
DESCRIPTION="Linux Mint 18 Sarah"
DESKTOP=Gnome
TOOLKIT=GTK
NEW_FEATURES_URL=http://www.linuxmint.com/rel_sarah_cinnamon_whatsnew.php
RELEASE_NOTES_URL=http://www.linuxmint.com/rel_sarah_cinnamon.php
USER_GUIDE_URL=help:linuxmint
GRUB_TITLE=Linux Mint 18 Cinnamon 64-bit
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
Description of the warning/error
I have tried to use mss to make screenshots from console code with python. Works just fine. Now I have made a GUI with PyQt5 and it is working just fine in windows. But in Linux, I get a segmentation fault
This is the smallest code that makes the error:
I have made my code in PyCharm and I have realized that if I run the debugger without even any breakpoints, the code works. But if I RUN the code from within PyCharm it crashes with seg fault. The same thing if I run the program from a console.
The text was updated successfully, but these errors were encountered: