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

Multiple 'n' after exception takes to py IPython core, threading and logging library paths and results in TypeError #216

Open
dshivashankar1994 opened this issue Oct 7, 2022 · 11 comments
Assignees

Comments

@dshivashankar1994
Copy link
Collaborator

Reproducer:

> cat a.py 
import time
a=1
while True:
    a += 1
    time.sleep(1)
    if a > 10:
       raise TimeoutError("FAILE")
> python  a.py &
[1] 128178

For debugger output, refer to the attached file

pyflyby output.txt

@Carreau Carreau self-assigned this Nov 9, 2022
@peytondmurray peytondmurray assigned asmeurer and unassigned Carreau Feb 21, 2023
@aktech
Copy link
Collaborator

aktech commented Mar 20, 2023

I tried to triage this last week, but seems like pyflyby's debugger requires gdb and gdb is not supported on M1 Macs.

(pyflyby)  $ python a.py &                                                                                                                                                                                          [0/269]
[1] 87930
(pyflyby)  $ py -d 87930
Traceback (most recent call last):
  File "/Users/aktech/miniconda3/envs/pyflyby/bin/py", line 33, in <module>
    sys.exit(load_entry_point('pyflyby', 'console_scripts', 'py')())
  File "/Users/aktech/quansight/pyflyby/lib/python/pyflyby/_py.py", line 2052, in py_main
    _PyMain(args).run()
  File "/Users/aktech/quansight/pyflyby/lib/python/pyflyby/_py.py", line 1787, in run
    self._run_action()
  File "/Users/aktech/quansight/pyflyby/lib/python/pyflyby/_py.py", line 1989, in _run_action
    attach_debugger(int(arg0, 10))
  File "/Users/aktech/quansight/pyflyby/lib/python/pyflyby/_dbg.py", line 1201, in attach_debugger
    gdb_pid = inject(pid, statements=";".join(statements), wait=False)
  File "/Users/aktech/quansight/pyflyby/lib/python/pyflyby/_dbg.py", line 1052, in inject
    process = subprocess.Popen(command,
  File "/Users/aktech/miniconda3/envs/pyflyby/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/aktech/miniconda3/envs/pyflyby/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gdb'

@peytondmurray peytondmurray assigned aktech and unassigned asmeurer Mar 22, 2023
@aktech
Copy link
Collaborator

aktech commented Apr 22, 2023

I tried reproducing on ubuntu 18.04, I get the following:

(pyflyby) $ python a.py &
[1] 119278
(pyflyby) $ py -d 119278
Traceback (most recent call last):
                                    File "/home/aktech/work/pyflyby/foo.py", line 7, in <module>
                                                                                                    raise TimeoutError("FAILE")
                                                                                                                               TimeoutError: FAILE
                                                                                                                                                  [1]  + 112745 exit 1     python foo.py

Debugging complete.
[1]+  Exit 1                  python a.py
(pyflyby) $

@aktech
Copy link
Collaborator

aktech commented Apr 22, 2023

Tried with Ubuntu 22.04 as well, same result:

(venv) $ python a.py &
[1] 22701
(venv) $ py -d 22701
Traceback (most recent call last):
                                    File "/root/pyflyby/a.py", line 7, in <module>
                                                                                      raise TimeoutError("FAILE")
                                                                                                                 TimeoutError: FAILE

Debugging complete.
[1]+  Exit 1                  python a.py

GDB Version:

(venv) $ gdb --version
GNU gdb (Ubuntu 12.1-3ubuntu2) 12.1

@aktech
Copy link
Collaborator

aktech commented Apr 22, 2023

@dshivashankar1994 Can you confirm you still see this issue in the latest master and with which OS/version and GDB version?

@sac111gp
Copy link
Collaborator

I tried it and was able to reproduce.
we are using 11.2 version of gdb.

$ gdb --version
GNU gdb (GDB) 11.2

@aktech
Copy link
Collaborator

aktech commented May 1, 2023

I installed GDB 11.2 from here: https://sourceware.org/pub/gdb/releases/ and tried reproducing the issue, still the same results, I might be doing something wrong.

When I run the command py -d <PID>, pyflyby doesn't even takes me to the debugger, it just continues the execution, from what I can see.

cc @sac111gp @dshivashankar1994 I have written the exact commands/steps I used for reproduction, can you spot the difference?

Script

(venv) $ cat a.py
import time
a=1
while True:
    a += 1
    time.sleep(1)
    if a > 10:
       raise TimeoutError("FAILE")

Reproduction

(venv) $ python a.py &
[1] 68317
(venv) $ py -d 68317
Traceback (most recent call last):
                                    File "/root/pyflyby/a.py", line 7, in <module>
                                                                                      raise TimeoutError("FAILE")
                                                                                                                 TimeoutError: FAILE

Debugging complete.
[1]+  Exit 1                  python a.py

GDB Version

(venv) $ gdb --version
GNU gdb (GDB) 11.2
Copyright (C) 2022 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.

OS Version

(venv) $ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.10
...

pyflyby version and latest commit

(venv) $ py --version
pyflyby 1.8.4 (py)

(venv) root@ubuntu-s-4vcpu-8gb-amd-fra1-01:~/pyflyby# git log -1
commit 238edc28fb00160f385ad5807cbb536b6417c866 (HEAD -> master, tag: 1.8.4, origin/master, origin/HEAD)
Author: Swapnil Ojha <[email protected]>
Date:   Mon Apr 17 21:22:34 2023 +0530

    Bump version 1.8.3 -> 1.8.4
(venv) root@ubuntu-s-4vcpu-8gb-amd-fra1-01:~/pyflyby#

@dshivashankar1994
Copy link
Collaborator Author

OS version

> cat /etc/*release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.9 (Maipo)"

GDB version

> gdb --version
GNU gdb (GDB) 11.2

pyflyby version - Also reproducible with master version

> py --version
pyflyby 1.8.4 (py)

@aktech
Copy link
Collaborator

aktech commented May 3, 2023

@dshivashankar1994 What terminal emulator are you using to test that and can you try another by any chance?

@Carreau
Copy link
Collaborator

Carreau commented May 17, 2023

@aktech
I had a few more success trying to attach to the python process and execute code manually to see the error messages.

First it seem my gdb is a bit stricter and I need to do some casting to make sure it works call (int)PyGILState_Ensure() (added (int)) and call (void)PyRun_SimpleString (added (void)).

Recent gdb should also let you run Python code with python subcommand, it might be easier to debug thigns by hand.

@aktech
Copy link
Collaborator

aktech commented May 22, 2023

I had a few more success trying to attach to the python process and execute code manually to see the error messages.

Hey @Carreau can you share an example script of how that worked for you?

First it seem my gdb is a bit stricter and I need to do some casting to make sure it works call (int)PyGILState_Ensure() (added (int)) and call (void)PyRun_SimpleString (added (void)).

Did you wrote an extension or something?

@dshivashankar1994
Copy link
Collaborator Author

@dshivashankar1994 What terminal emulator are you using to test that and can you try another by any chance?

I was earlier using MATE terminal (xterm). Used GNOM (xterm) and the issue was still reproducible.
Same is the case with putty as well

@peytondmurray peytondmurray assigned Carreau and unassigned aktech Nov 14, 2023
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

No branches or pull requests

5 participants