A very large application I am working has a segfault when I shut it down. If I use faulthandler, it says there is an access violation in atexit
Current thread 0x00000a8c (most recent call first):
File "C:\Python27\lib\atexit.py", line 24 in _run_exitfuncs
Windows exception: access violation
Current thread 0x00000a8c (most recent call first):
File "C:\Python27\lib\atexit.py", line 24 in _run_exitfuncs
Segmentation fault
That really doesn't tell me much. When I debug through the code, it goes all the way through main and out. The debugger won't step anymore after that, even though the program isn't all the way done yet. If I let it continue, it just does the segfault and doesn't show me anything.
I imagine it is some library we are using, but how to identify it?
Related
Latest PyCharm as of June 2022 (2022.1.2):
When I turn on autoreload in a cell of Jupyter:
%load_ext autoreload
%autoreload 2
Debugging Python in a cell stops working. The debugger doesn't work and it just prints out something like this:
Traceback (most recent call last):
File "/home/myUserName/pycharm-2022.1/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch_regular.py", line 429, in __call__
abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename]
KeyError: '/home/myUserName/pycharm-2022.1/plugins/python/helpers/pydev/pydevd_file_utils.py'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/myUserName/pycharm-2022.1/plugins/python/helpers/pydev/pydevd_file_utils.py", line 580, in get_abs_path_real_path_and_base_from_frame
return NORM_PATHS_AND_BASE_CONTAINER[frame.f_code.co_filename]
NameError: name 'NORM_PATHS_AND_BASE_CONTAINER' is not defined
During handling of the above exception, another exception occurred:
If I turn off the autoreload in Jupyter, then the debugger works exactly as expected, but then I lose all auto-reload-of-updated-code functionality.
I've googled extensively and can't find an answer. My PyCharm setup is pretty much stock and I think this must be occurring with many many users. I don't understand why something so simple and basic like this is still in issue in PyCharm in 2022.
EDIT: my PyCharm is configured with a mini-conda environment. Though, this is fully supported in PyCharm so it shouldn't be an issue.
When running a python3 script that generates a word document on a windows machine the following error occurs:
08:53:23 Traceback (most recent call last):
08:53:23 File "c:\python\venv\py3-32-report-generator\lib\site-packages\win32com\client\gencache.py", line 236, in GetModuleForCLSID
08:53:23 __import__(sub_mod_name)
08:53:23 ModuleNotFoundError: No module named 'win32com.gen_py.00020905-0000-0000-C000-000000000046x0x8x4.ListTemplates'
The error only occurs once in a while, thats what confuses me so much.
It reminded me of a similar AttributeError that could be resolved by deleting the gen_py folder in ../AppData/Local/Temp/. Unfortunately this fix doesnt seem to help here.
If you need any more info describing the problem let me know. Thanks:)
MCVE:
import threading
threading.Thread(target=input, daemon=True).start()
If you run the above as a script in PyCharm with the default run configuration (without entering any input), you get the following fatal error when the program terminates:
Fatal Python error: could not acquire lock for <_io.BufferedReader name='<stdin>'> at interpreter shutdown, possibly due to daemon threads
Python runtime state: finalizing (tstate=00000200EF89E1C0)
Thread 0x0000459c (most recent call first):
File "C:\Program Files\Python38\lib\threading.py", line 870 in run
File "C:\Program Files\Python38\lib\threading.py", line 932 in _bootstrap_inner
File "C:\Program Files\Python38\lib\threading.py", line 890 in _bootstrap
Current thread 0x00001b78 (most recent call first):
<no Python frame>
But if you run this from the terminal with python script.py or check the "Emulate terminal in output console" in PyCharm for this run configuration, no such error occurs.
As far as I understand, the error happens because when input is called, it suspends the thread indeterminately until input returns (and there's no way of interrupting this), blocking stdin during this time, so when the main thread terminates, since the other thread is a daemon, Python starts finalization, and when it tries to reacquire the lock for stdin, it can't because it is still locked by the input call.
But the question is, why does it make a difference whether it is run in PyCharm's output console vs a terminal/terminal emulator? Does the terminal make Python not try to reacquire the lock? Or does the error still occur but it gets silenced for some reason? Or what?
If case this helps, in CPython, this error is raised in the _enter_buffered_busy function in bufferedio.c.
UPDATE: I've filed a ticket on PyCharm's issue tracker.
What can cause this error?
I get these errors every time a client accesses my server.
it hapens only once in each request.
the script runs with seemingly no problems, but i don't know if there are hidden implications or complication that result from this error that i'm not aware of.
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/flup/server/fcgi_base.py", line 982, in _setupSocket
sock.getpeername()
fcgi_base
error: [Errno 88] Socket operation on non-socket
i'm running python as cgi ,web.py, linux (ubuntu12)
what can be the cause of this error?
How can I investigate it?
We're about to start using Esky to deploy updates to our application. On Windows 7, Esky appears to be unable to get the escalated privileges it needs to install an update.
I've narrowed it down to this simple script. It asks for escalated permissions, but will either freeze, or crash with the stacktrace below.
Script
import esky
import esky.sudo
class MyProgram(object):
#esky.sudo.allow_from_sudo()
def do_stuff(self):
pass
app = MyProgram()
sapp = esky.sudo.SudoProxy(app)
sapp.start()
sapp.do_stuff()
sapp.drop_root()
Stack Trace
$ python test.py
Traceback (most recent call last):
File "test.py", line 16, in <module>
sapp.start()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 125, in start
raise RuntimeError("sudo helper process terminated unexpectedly")
RuntimeError: sudo helper process terminated unexpectedly
$ python test.py
Traceback (most recent call last):
File "test.py", line 16, in <module>
sapp.start()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 140, in start
self.close()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 156, in close
self.pipe.read()
File "c:\Python27\lib\site-packages\esky\sudo\sudo_base.py", line 123, in read
raise EOFError
EOFError
Does anyone know of a solution, or have any suggestions?
Using:
python 2.7.3
esky 0.9.7
3 years and no answer that is very sad :(
This is a bug in esky.
Esky works fine for me besides the fact that escalating privileges fails.
I'm used to programming in python3... so once I'm done updating Esky to be python 2 and 3 compatible I'm going to tackle this issue.
If anyone wants to solve this problem let's rock and roll! To the github issue tracker!
This is super late, but if anyone in the future has this problem, try running sudo python your_program.py.