This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_gdb fails for Python 2.7.15
Type: compile error Stage: resolved
Components: Build Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: vibhutisawant, vstinner, xtreak
Priority: normal Keywords:

Created on 2018-06-20 10:39 by vibhutisawant, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (8)
msg320060 - (view) Author: Vibhuti (vibhutisawant) Date: 2018-06-20 10:39
======================================================================
FAIL: test_down_at_bottom (test.test_gdb.StackNavigationTests)
Verify handling of "py-down" at the bottom of the stack
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/test/Python-2.7.15/Lib/test/test_gdb.py", line 708, in test_down_at_bottom
    cmds_after_breakpoint=['py-down'])
  File "/home/test/Python-2.7.15/Lib/test/test_gdb.py", line 221, in get_stack_trace
    self.assertEqual(unexpected_errlines, [])
AssertionError: Lists differ: ['Cannot create process: Opera... != []

First list contains 4 additional elements.
First extra element 0:
'Cannot create process: Operation not permitted'

+ []
- ['Cannot create process: Operation not permitted',
-  'During startup program exited with code 127.',
-  "Python Exception <class 'gdb.error'> No frame is currently selected.: ",
-  'Error occurred in Python command: No frame is currently selected.']

----------------------------------------------------------------------
Ran 49 tests in 0.170s

FAILED (failures=1, skipped=48)
test test_gdb failed -- Traceback (most recent call last):
  File "/home/test/Python-2.7.15/Lib/test/test_gdb.py", line 708, in test_down_at_bottom
    cmds_after_breakpoint=['py-down'])
  File "/home/test/Python-2.7.15/Lib/test/test_gdb.py", line 221, in get_stack_trace
    self.assertEqual(unexpected_errlines, [])
AssertionError: Lists differ: ['Cannot create process: Opera... != []

First list contains 4 additional elements.
First extra element 0:
'Cannot create process: Operation not permitted'

+ []
- ['Cannot create process: Operation not permitted',
-  'During startup program exited with code 127.',
-  "Python Exception <class 'gdb.error'> No frame is currently selected.: ",
-  'Error occurred in Python command: No frame is currently selected.']

1 test failed:
    test_gdb
msg320144 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-06-21 09:19
I think it's a problem with user-level permission error not being able to create a process (Wild guess to try sudo?). The tests run without error for me. Please add in information regarding you environment, gdb version and perhaps the whole output of `./python -Werror -m test -v test_gdb`

# Test log

karthi@ubuntu-s-1vcpu-1gb-blr1-01:~/python-build/cpython$ ./python -Werror -m test -v test_gdb
== CPython 2.7.15+ (remotes/upstream/2.7:f291888, Jun 21 2018, 09:13:04) [GCC 5.4.0 20160609]
==   Linux-4.4.0-127-generic-x86_64-with-debian-stretch-sid little-endian
==   /home/karthi/python-build/cpython/build/test_python_13424
== CPU count: 1
Run tests sequentially
0:00:00 load avg: 1.53 [1/1] test_gdb
GDB version 7.11:
    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".
test_NULL_instance_dict (test.test_gdb.PrettyPrintTests)
Ensure that a PyInstanceObject with with a NULL in_dict is handled ... ok
test_NULL_ob_type (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with NULL ob_type is handled gracefully ... ok
test_NULL_ptr (test.test_gdb.PrettyPrintTests)
Ensure that a NULL PyObject* is handled gracefully ... ok
test_builtin_function (test.test_gdb.PrettyPrintTests) ... ok
test_builtin_method (test.test_gdb.PrettyPrintTests) ... ok
test_builtins_help (test.test_gdb.PrettyPrintTests)
Ensure that the new-style class _Helper in site.py can be handled ... ok
test_classic_class (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of classic class instances ... ok
test_corrupt_ob_type (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with a corrupt ob_type is handled gracefully ... ok
test_corrupt_tp_flags (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with a type with corrupt tp_flags is handled ... ok
test_corrupt_tp_name (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with a type with corrupt tp_name is handled ... ok
test_dicts (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of dictionaries ... ok
test_exceptions (test.test_gdb.PrettyPrintTests) ... ok
test_frames (test.test_gdb.PrettyPrintTests) ... ok
test_frozensets (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of frozensets ... ok
test_getting_backtrace (test.test_gdb.PrettyPrintTests) ... ok
test_int (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of various "int" values ... ok
test_lists (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of lists ... ok
test_long (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of various "long" values ... ok
test_modern_class (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of new-style class instances ... ok
test_selfreferential_dict (test.test_gdb.PrettyPrintTests)
Ensure that a reference loop involving a dict doesn't lead proxyval ... ok
test_selfreferential_list (test.test_gdb.PrettyPrintTests)
Ensure that a reference loop involving a list doesn't lead proxyval ... ok
test_selfreferential_new_style_instance (test.test_gdb.PrettyPrintTests) ... ok
test_selfreferential_old_style_instance (test.test_gdb.PrettyPrintTests) ... ok
test_sets (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of sets ... ok
test_singletons (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of True, False and None ... ok
test_strings (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of strings ... ok
test_subclassing_list (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of an instance of a list subclass ... ok
test_subclassing_tuple (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of an instance of a tuple subclass ... ok
test_truncation (test.test_gdb.PrettyPrintTests)
Verify that very long output is truncated ... ok
test_tuples (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of tuples ... ok
test_unicode (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of unicode values ... ok
test_basic_command (test.test_gdb.PyListTests)
Verify that the "py-list" command works ... ok
test_one_abs_arg (test.test_gdb.PyListTests)
Verify the "py-list" command with one absolute argument ... ok
test_two_abs_args (test.test_gdb.PyListTests)
Verify the "py-list" command with two absolute arguments ... ok
test_down_at_bottom (test.test_gdb.StackNavigationTests)
Verify handling of "py-down" at the bottom of the stack ... ok
test_pyup_command (test.test_gdb.StackNavigationTests)
Verify that the "py-up" command works ... ok
test_up_at_top (test.test_gdb.StackNavigationTests)
Verify handling of "py-up" at the top of the stack ... ok
test_up_then_down (test.test_gdb.StackNavigationTests)
Verify "py-up" followed by "py-down" ... ok
test_bt (test.test_gdb.PyBtTests)
Verify that the "py-bt" command works ... ok
test_bt_full (test.test_gdb.PyBtTests)
Verify that the "py-bt-full" command works ... ok
test_gc (test.test_gdb.PyBtTests)
Verify that "py-bt" indicates if a thread is garbage-collecting ... ok
test_pycfunction (test.test_gdb.PyBtTests)
Verify that "py-bt" displays invocations of PyCFunction instances ... ok
test_threads (test.test_gdb.PyBtTests)
Verify that "py-bt" indicates threads that are waiting for the GIL ... ok
test_wrapper_call (test.test_gdb.PyBtTests) ... ok
test_basic_command (test.test_gdb.PyPrintTests)
Verify that the "py-print" command works ... ok
test_print_after_up (test.test_gdb.PyPrintTests) ... ok
test_printing_builtin (test.test_gdb.PyPrintTests) ... ok
test_printing_global (test.test_gdb.PyPrintTests) ... ok
test_basic_command (test.test_gdb.PyLocalsTests) ... ok
test_locals_after_up (test.test_gdb.PyLocalsTests) ... ok

----------------------------------------------------------------------
Ran 50 tests in 35.304s

OK

== Tests result: SUCCESS ==

1 test OK.

Total duration: 36 sec
Tests result: SUCCESS


Thanks
msg320161 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-21 11:06
Vibhuti: Hi! Would you mind to describe your environment? What is your operating system (name, version)? Are you running test_gdb as root or as your normal user? How did you install Python?

Note: I recently backported python-gdb.py a few enhancements from master to 2.7: commit e36f94f204f3257a206a7766464a94230337fd18.
msg320420 - (view) Author: Vibhuti (vibhutisawant) Date: 2018-06-25 12:27
Hi ,sorry for the delayed reply
The architecture is s390x and the OS is SLES 12 SP3 
(however test_gdb fails on SLES 11 SP4 too)
Python was installed using https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tar.xz
The whole output of `./python -Werror -m test -v test_gdb` is as below:

4e227cf6c7ae">test@4e227cf6c7ae:~/Python-2.7.15> sudo ./python -Werror -m test -v test_gdb
== CPython 2.7.15 (default, Jun 25 2018, 05:10:18) [GCC 4.8.5]
==   Linux-4.15.0-22-generic-s390x-with-SuSE-12-s390x big-endian
==   /home/test/Python-2.7.15/build/test_python_21830
== CPU count: 2
Run tests sequentially
0:00:00 load avg: 4.32 [1/1] test_gdb
GDB version 8.0:
    GNU gdb (GDB; SUSE Linux Enterprise 12) 8.0.1
    Copyright (C) 2017 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 "s390x-suse-linux".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <http://bugs.opensuse.org/>.
    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".
test_NULL_instance_dict (test.test_gdb.PrettyPrintTests)
Ensure that a PyInstanceObject with with a NULL in_dict is handled ... skipped 'Python was compiled with optimizations'
test_NULL_ob_type (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with NULL ob_type is handled gracefully ... skipped 'Python was compiled with optimizations'
test_NULL_ptr (test.test_gdb.PrettyPrintTests)
Ensure that a NULL PyObject* is handled gracefully ... skipped 'Python was compiled with optimizations'
test_builtin_function (test.test_gdb.PrettyPrintTests) ... skipped 'Python was compiled with optimizations'
test_builtin_method (test.test_gdb.PrettyPrintTests) ... skipped 'Python was compiled with optimizations'
test_builtins_help (test.test_gdb.PrettyPrintTests)
Ensure that the new-style class _Helper in site.py can be handled ... skipped 'Python was compiled with optimizations'
test_classic_class (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of classic class instances ... skipped 'Python was compiled with optimizations'
test_corrupt_ob_type (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with a corrupt ob_type is handled gracefully ... skipped 'Python was compiled with optimizations'
test_corrupt_tp_flags (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with a type with corrupt tp_flags is handled ... skipped 'Python was compiled with optimizations'
test_corrupt_tp_name (test.test_gdb.PrettyPrintTests)
Ensure that a PyObject* with a type with corrupt tp_name is handled ... skipped 'Python was compiled with optimizations'
test_dicts (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of dictionaries ... skipped 'Python was compiled with optimizations'
test_exceptions (test.test_gdb.PrettyPrintTests) ... skipped 'Python was compiled with optimizations'
test_frames (test.test_gdb.PrettyPrintTests) ... skipped 'Python was compiled with optimizations'
test_frozensets (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of frozensets ... skipped 'Python was compiled with optimizations'
test_getting_backtrace (test.test_gdb.PrettyPrintTests) ... skipped 'Python was compiled with optimizations'
test_int (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of various "int" values ... skipped 'Python was compiled with optimizations'
test_lists (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of lists ... skipped 'Python was compiled with optimizations'
test_long (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of various "long" values ... skipped 'Python was compiled with optimizations'
test_modern_class (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of new-style class instances ... skipped 'Python was compiled with optimizations'
test_selfreferential_dict (test.test_gdb.PrettyPrintTests)
Ensure that a reference loop involving a dict doesn't lead proxyval ... skipped 'Python was compiled with optimizations'
test_selfreferential_list (test.test_gdb.PrettyPrintTests)
Ensure that a reference loop involving a list doesn't lead proxyval ... skipped 'Python was compiled with optimizations'
test_selfreferential_new_style_instance (test.test_gdb.PrettyPrintTests) ... skipped 'Python was compiled with optimizations'
test_selfreferential_old_style_instance (test.test_gdb.PrettyPrintTests) ... skipped 'Python was compiled with optimizations'
test_sets (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of sets ... skipped 'Python was compiled with optimizations'
test_singletons (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of True, False and None ... skipped 'Python was compiled with optimizations'
test_strings (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of strings ... skipped 'Python was compiled with optimizations'
test_subclassing_list (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of an instance of a list subclass ... skipped 'Python was compiled with optimizations'
test_subclassing_tuple (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of an instance of a tuple subclass ... skipped 'Python was compiled with optimizations'
test_truncation (test.test_gdb.PrettyPrintTests)
Verify that very long output is truncated ... skipped 'Python was compiled with optimizations'
test_tuples (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of tuples ... skipped 'Python was compiled with optimizations'
test_unicode (test.test_gdb.PrettyPrintTests)
Verify the pretty-printing of unicode values ... skipped 'Python was compiled with optimizations'
test_basic_command (test.test_gdb.PyListTests)
Verify that the "py-list" command works ... skipped 'Python was compiled with optimizations'
test_one_abs_arg (test.test_gdb.PyListTests)
Verify the "py-list" command with one absolute argument ... skipped 'Python was compiled with optimizations'
test_two_abs_args (test.test_gdb.PyListTests)
Verify the "py-list" command with two absolute arguments ... skipped 'Python was compiled with optimizations'
test_down_at_bottom (test.test_gdb.StackNavigationTests)
Verify handling of "py-down" at the bottom of the stack ... FAIL
test_pyup_command (test.test_gdb.StackNavigationTests)
Verify that the "py-up" command works ... skipped 'Python was compiled with optimizations'
test_up_at_top (test.test_gdb.StackNavigationTests)
Verify handling of "py-up" at the top of the stack ... skipped 'Python was compiled with optimizations'
test_up_then_down (test.test_gdb.StackNavigationTests)
Verify "py-up" followed by "py-down" ... skipped 'Python was compiled with optimizations'
test_bt (test.test_gdb.PyBtTests)
Verify that the "py-bt" command works ... skipped 'Python was compiled with optimizations'
test_bt_full (test.test_gdb.PyBtTests)
Verify that the "py-bt-full" command works ... skipped 'Python was compiled with optimizations'
test_gc (test.test_gdb.PyBtTests)
Verify that "py-bt" indicates if a thread is garbage-collecting ... skipped 'Python was compiled with optimizations'
test_pycfunction (test.test_gdb.PyBtTests)
Verify that "py-bt" displays invocations of PyCFunction instances ... skipped 'Python was compiled with optimizations'
test_threads (test.test_gdb.PyBtTests)
Verify that "py-bt" indicates threads that are waiting for the GIL ... skipped 'Python was compiled with optimizations'
test_basic_command (test.test_gdb.PyPrintTests)
Verify that the "py-print" command works ... skipped 'Python was compiled with optimizations'
test_print_after_up (test.test_gdb.PyPrintTests) ... skipped 'Python was compiled with optimizations'
test_printing_builtin (test.test_gdb.PyPrintTests) ... skipped 'Python was compiled with optimizations'
test_printing_global (test.test_gdb.PyPrintTests) ... skipped 'Python was compiled with optimizations'
test_basic_command (test.test_gdb.PyLocalsTests) ... skipped 'Python was compiled with optimizations'
test_locals_after_up (test.test_gdb.PyLocalsTests) ... skipped 'Python was compiled with optimizations'

======================================================================
FAIL: test_down_at_bottom (test.test_gdb.StackNavigationTests)
Verify handling of "py-down" at the bottom of the stack
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/test/Python-2.7.15/Lib/test/test_gdb.py", line 708, in test_down_at_bottom
    cmds_after_breakpoint=['py-down'])
  File "/home/test/Python-2.7.15/Lib/test/test_gdb.py", line 221, in get_stack_trace
    self.assertEqual(unexpected_errlines, [])
AssertionError: Lists differ: ['Could not trace the inferior... != []

First list contains 4 additional elements.
First extra element 0:
'Could not trace the inferior process.'

+ []
- ['Could not trace the inferior process.',
-  'Error: ptrace: Operation not permittedDuring startup program exited with code 127.',
-  "Python Exception <class 'gdb.error'> No frame is currently selected.: ",
-  'Error occurred in Python command: No frame is currently selected.']

----------------------------------------------------------------------
Ran 49 tests in 0.455s

FAILED (failures=1, skipped=48)
test test_gdb failed -- Traceback (most recent call last):
  File "/home/test/Python-2.7.15/Lib/test/test_gdb.py", line 708, in test_down_at_bottom
    cmds_after_breakpoint=['py-down'])
  File "/home/test/Python-2.7.15/Lib/test/test_gdb.py", line 221, in get_stack_trace
    self.assertEqual(unexpected_errlines, [])
AssertionError: Lists differ: ['Could not trace the inferior... != []

First list contains 4 additional elements.
First extra element 0:
'Could not trace the inferior process.'

+ []
- ['Could not trace the inferior process.',
-  'Error: ptrace: Operation not permittedDuring startup program exited with code 127.',
-  "Python Exception <class 'gdb.error'> No frame is currently selected.: ",
-  'Error occurred in Python command: No frame is currently selected.']

1 test failed:
    test_gdb

Total duration: 2 sec
Tests result: FAILURE
msg320421 - (view) Author: Vibhuti (vibhutisawant) Date: 2018-06-25 12:28
STINNER Hi
I tried the commit but it did not work.The same failure is observed.
msg320630 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-27 21:51
> Could not trace the inferior process.

Your issue doesn't seem to be related to Python, but more to gdb in general.

Can you try very basic commands like:

$ gdb -args python3 -c pass
(gdb) run
Starting program: /usr/bin/python3 -c pass
[Inferior 1 (process 20811) exited normally]
(gdb) quit

Or more advanced cases like:

vstinner@apu$ gdb -args ./python Lib/test/gdb_sample.py
(gdb) b builtin_id
Breakpoint 1 at 0x4dd7d0: file Python/bltinmodule.c, line 1205.
(gdb) run
Starting program: /home/vstinner/prog/python/master/python Lib/test/gdb_sample.py

Breakpoint 1, builtin_id (self=0x7ffff7fc0c28, v=42)
    at Python/bltinmodule.c:1205
1205	    return PyLong_FromVoidPtr(v);
(gdb) py-bt
Traceback (most recent call first):
  <built-in method id of module object at remote 0x7ffff7fc0c28>
  File "Lib/test/gdb_sample.py", line 10, in baz
    id(42)
  File "Lib/test/gdb_sample.py", line 7, in bar
    baz(a, b, c)
  File "Lib/test/gdb_sample.py", line 4, in foo
    bar(a, b, c)
  File "Lib/test/gdb_sample.py", line 12, in <module>
    foo(1, 2, 3)
(gdb) quit
A debugging session is active.
Quit anyway? (y or n) y
msg320705 - (view) Author: Vibhuti (vibhutisawant) Date: 2018-06-29 07:01
Thanks STINNER for your help.The issue has been resolved.It was related to gdb itself and not Python.
msg320716 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-29 12:44
> Thanks STINNER for your help.The issue has been resolved.It was related to gdb itself and not Python.

Oh good! Happy to see that you solved your issue!
History
Date User Action Args
2022-04-11 14:59:02adminsetgithub: 78095
2018-06-29 12:44:43vstinnersetresolution: fixed -> not a bug
2018-06-29 12:44:34vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg320716

stage: resolved
2018-06-29 07:01:15vibhutisawantsetmessages: + msg320705
2018-06-27 21:51:50vstinnersetmessages: + msg320630
2018-06-25 12:28:58vibhutisawantsetmessages: + msg320421
2018-06-25 12:27:15vibhutisawantsetmessages: + msg320420
2018-06-21 11:06:51vstinnersetnosy: + vstinner
messages: + msg320161
2018-06-21 09:20:00xtreaksetnosy: + xtreak
messages: + msg320144
2018-06-20 10:39:13vibhutisawantcreate