public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/25800] New: sys.executable is a non existing path if python is executed from gdb
@ 2020-04-07 20:20 volker.weissmann at gmx dot de
  0 siblings, 0 replies; only message in thread
From: volker.weissmann at gmx dot de @ 2020-04-07 20:20 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25800

            Bug ID: 25800
           Summary: sys.executable is a non existing path if python is
                    executed from gdb
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: volker.weissmann at gmx dot de
  Target Milestone: ---

Note: I'm not sure if this is a bug in python or in gdb. I also created an
issue in the python bug tracker: https://bugs.python.org/issue40218

Pythons documentation says that sys.executable is always either None, empty
string or a path to the python interpreter. Using gdb and python, we can
produce situations where this is not true.

Simple but unrealistic way to reproduce this bug:
Install gdb with python support. E.g using
$ pacman -S gdb
Remove all the python binaries:
$ rm /usr/bin/python
$ rm /usr/bin/python3
$ rm /usr/bin/python3.8
Run $gdb -x gdbinit$ with the contents of gdbinit being:
python
import sys
import os
print(sys.executable)
print(os.path.exists(sys.executable))
end

Result:
/usr/bin/python
False

Here, sys.executable is /usr/bin/python, but there is no python executable in
/usr/bin/python, because we just deleted it.

Complicated but realistic way to reproduce this bug:
Build gdb with
../configure --with-python=python2
and run gdb with the gdbinit being:
python
import sys
print(sys.executable)
print(sys.version)
end
Result:
/usr/bin/python
2.7.17 (default, Mar 21 2020, 00:47:07) 
[GCC 9.3.0]
Here it says that the python2 executable lies in "/usr/bin/python", even if
there is no python2 executable in /usr/bin/python.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-07 20:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 20:20 [Bug python/25800] New: sys.executable is a non existing path if python is executed from gdb volker.weissmann at gmx dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).