Repository: pwndbg/pwndbg

Issue:
AttributeError: 'SymbolUnresolvableError' object has no attribute 'symbol'
I have try to run `vis` at ARM arch with strippted GLIBC and I got exception:

commit id : b9c9f12efcec8e5e11c8cd8fcedc69c856d1716a





```

The target architecture is assumed to be arm 

Traceback (most recent call last):
  File "/home/USER/pwndbg/pwndbg/commands/__init__.py", line 358, in _try2run_heap_command
    return function(*a, **kw)
  File "/home/USER/pwndbg/pwndbg/commands/__init__.py", line 340, in _OnlyWhenHeapIsInitialized
    return function(*a, **kw)
  File "/home/USER/pwndbg/pwndbg/commands/heap.py", line 672, in vis_heap_chunks
    arena = allocator.thread_arena
  File "/home/USER/pwndbg/pwndbg/heap/ptmalloc.py", line 1580, in thread_arena
    raise SymbolUnresolvableError("thread_arena")
pwndbg.heap.ptmalloc.SymbolUnresolvableError: `thread_arena` can not be resolved via heuristic

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/USER/pwndbg/pwndbg/commands/__init__.py", line 184, in __call__
    return self.function(*args, **kwargs)
  File "/home/USER/pwndbg/pwndbg/commands/__init__.py", line 315, in _OnlyWhenRunning
    return function(*a, **kw)
  File "/home/USER/pwndbg/pwndbg/commands/__init__.py", line 409, in _OnlyWithResolvedHeapSyms
    return _try2run_heap_command(function, a, kw)
  File "/home/USER/pwndbg/pwndbg/commands/__init__.py", line 360, in _try2run_heap_command
    e(f"{function.__name__}: Fail to resolve the symbol: `{err.symbol}`")
AttributeError: 'SymbolUnresolvableError' object has no attribute 'symbol'

If that is an issue, you can report it on https://github.com/pwndbg/pwndbg/issues
(Please don't forget to search if it hasn't been reported before)
To generate the report and open a browser, you may run `bugreport --run-browser`
PS: Pull requests are welcome
> /home/USER/pwndbg/pwndbg/commands/__init__.py(360)_try2run_heap_command()
-> e(f"{function.__name__}: Fail to resolve the symbol: `{err.symbol}`")
```


Discussion:
@lebr0nli 
@yooo1999 can u provide the binary so we can reproduce this issue?
@disconnect3d  Can I send the binary privately?
You need only GLIBC binary libc-2.25.so
`LF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, stripped`
@yooo1999 Yeah, you can do it either on our Discord (https://discord.gg/64tycmWP) or to my email (dominik.b.czarnota+pwndbg@gmail.com).

Btw you can also try reverting the last commits of Pwndbg and see if it works, but we can do it on our side as well.
@disconnect3d sent, update that you got it please

Resolving patch:
diff --git a/pwndbg/heap/ptmalloc.py b/pwndbg/heap/ptmalloc.py
--- a/pwndbg/heap/ptmalloc.py
+++ b/pwndbg/heap/ptmalloc.py
@@ -1252,6 +1252,7 @@ def is_initialized(self):
 class SymbolUnresolvableError(Exception):
     def __init__(self, symbol) -> None:
         super().__init__(f"`{symbol}` can not be resolved via heuristic")
+        self.symbol = symbol
 
 
 class HeuristicHeap(GlibcMemoryAllocator):


Test patch:
diff --git a/tests/gdb-tests/tests/heap/test_heap.py b/tests/gdb-tests/tests/heap/test_heap.py
--- a/tests/gdb-tests/tests/heap/test_heap.py
+++ b/tests/gdb-tests/tests/heap/test_heap.py
@@ -429,9 +429,9 @@ def _test_heuristic_fail_gracefully(name):
                 "The heuristic for pwndbg.heap.current.%s should fail with SymbolUnresolvableError"
                 % name
             )
-        except SymbolUnresolvableError:
+        except SymbolUnresolvableError as e:
             # That's the only exception we expect
-            pass
+            assert e.symbol  # we should show what symbol we failed to resolve
 
     # Mock all address and mess up the memory
     with mock_for_heuristic(mock_all=True, mess_up_memory=True):