question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

context in attached process gives TypeError: argument of type 'NoneType' is not iterable

See original GitHub issue

Description

When running context in an attached process I get the following error:

Traceback (most recent call last):
  File "/usr/share/pwndbg/pwndbg/commands/__init__.py", line 130, in __call__
    return self.function(*args, **kwargs)
  File "/usr/share/pwndbg/pwndbg/commands/__init__.py", line 221, in _OnlyWhenRunning
    return function(*a, **kw)
  File "/usr/share/pwndbg/pwndbg/commands/context.py", line 334, in context
    result[target].extend(func(target=out,
  File "/usr/share/pwndbg/pwndbg/commands/context.py", line 408, in context_regs
    regs = get_regs()
  File "/usr/share/pwndbg/pwndbg/commands/context.py", line 457, in get_regs
    m = ' ' * len(change_marker) if reg not in changed else C.register_changed(change_marker)
TypeError: argument of type 'NoneType' is not iterable

Steps to reproduce

Create a process and attach to it:

$ sleep 10000 &
[2] 282936
$ gdb -p 282936

Then the error from above will occur.

Possible fix

Changing https://github.com/pwndbg/pwndbg/blob/9250cc51d8ef6cb872e66dcdc48f721d25aec582/pwndbg/commands/context.py#L440

to

changed = pwndbg.regs.changed or []

seems to fix the problem for me.

My setup

Platform: Linux-5.9.13-arch1-1-x86_64-with-glibc2.32 Gdb: 10.1 Python: 3.9.0 (default, Oct 7 2020, 23:09:01) [GCC 10.2.0] Pwndbg: 1.1.0 Capstone: 4.0.1024 Unicorn: 1.0.1 This GDB was configured as follows: configure --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu –with-auto-load-dir=$debugdir:$datadir/auto-load –with-auto-load-safe-path=$debugdir:$datadir/auto-load –with-expat –with-gdb-datadir=/usr/share/gdb (relocatable) –with-jit-reader-dir=/usr/lib/gdb (relocatable) –without-libunwind-ia64 –with-lzma –without-babeltrace –without-intel-pt –with-mpfr –without-xxhash –with-python=/usr (relocatable) –with-python-libdir=/usr/lib (relocatable) –with-debuginfod –with-guile –enable-source-highlight –with-separate-debug-dir=/usr/lib/debug (relocatable) –with-system-gdbinit=/etc/gdb/gdbinit

(“Relocatable” means the directory can be moved with the GDB installation tree, and GDB will still find it.)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
echo-Mikecommented, Jan 3, 2021

@disconnect3d

Yeah, it seems so. Did u step on this bug without loading pwndbg before program start?

Yes. Even with fix applied

If I apply the changed = pwndbg.regs.changed or [] fix, I get an error in another place, if I load pwndbg after program start.

I have similar error 'NoneType' is not iterable but I do not remember the place

0reactions
disconnect3dcommented, Aug 4, 2021

I can’t reproduce the described bug with the fix above; please let me know if it still triggers for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: argument of type 'NoneType' is not iterable
The Python "TypeError: argument of type 'NoneType' is not iterable" occurs when we use the membership test operators (in and not in) with...
Read more >
Python TypeError: argument of type 'NoneType' is not iterable
I simultaneously want to type 'inspect <item>' and have it give me the description (index 1) of that item. – SciurusDoomus. Apr 13,...
Read more >
TypeError: argument of type 'NoneType' is ... - Google Groups
So when I do obj.delete() I get this error. I also do a session.update(obj) right before to make sure the object is present...
Read more >
Int Object is Not Iterable – Python Error [Solved]
If you are running your Python code and you see the error “TypeError: 'int' object is not iterable”, it means you are trying...
Read more >
contextlib — Utilities for with-statement contexts ... - Python Docs
Source code: Lib/contextlib.py This module provides utilities for common tasks involving the with statement. For more information see also Context Manager ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found