pwndbg: 'Could not allocate dynamic translator buffer' Error when execute "start" command
Description
‘Could not allocate dynamic translator buffer’ Error when execute "start" command
pwndbg> start Temporary breakpoint 1 at 0x400400 Temporary breakpoint 1, 0x0000000000400400 in _start () Could not allocate dynamic translator buffer
Steps to reproduce
gdb blah start
My setup
OS - Oracle Cloud Instance
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION=“Ubuntu 22.04.1 LTS” PRETTY_NAME=“Ubuntu 22.04.1 LTS” NAME=“Ubuntu” VERSION_ID=“22.04” VERSION=“22.04.1 LTS (Jammy Jellyfish)” VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian
In addition, same issues on Ubuntu 18.04
GDB GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Python Python 3.10.6
Commit commit 52a479211cf58d1bdc5b42fd50471f565e6a063c (HEAD -> dev, origin/dev, origin/HEAD)
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (9 by maintainers)
Commits related to this issue
- Fix #1534: disable emulation if mmap(1G,RWX) fails TL:DR: Unicorn Engine aborts if mmap(1G, RWX) fails, so we are doing a best effort check if we can do such allocation before using it for the first ... — committed to pwndbg/pwndbg by disconnect3d a year ago
- Fix #1534: disable emulation if mmap(1G,RWX) fails (#1546) * Fix #1534: disable emulation if mmap(1G,RWX) fails TL:DR: Unicorn Engine aborts if mmap(1G, RWX) fails, so we are doing a best effort ... — committed to rivit98/pwndbg by disconnect3d a year ago
I don’t have a test binary for that but I assume it will work. Note it looks like you forget to
unmap
the test page?Cool, so this is indeed comming from Unicorn. Now, let’s try to check out why.
If we look into the
code_gen_alloc
code, it prints the"Could not allocate dynamic translator buffer"
error and exits if thealloc_code_gen_buffer(uc)
call returnsNULL
. This call seems to be used to allocate the buffer to store the generated code and it has three different implementations: one for windows, one for static buffer and one is “all else”. Let’s look at the first and last one.The first one seems to do sth with RWX memory mappings, but it also aborts on failures:
The last one allocates a RWX memory page like this:
Triggering an abort would not show us the error print. So it seems we are hitting the other implementation and that in your case the call to
mmap
withRWX
protections is failing? It is either that you don’t have enough (virtual) memory for the allocation – which I doubt it would be the case – or maybe your kernel/VM does not allow you to allocate RWX memory pages.Can you somehow confirm this? One way to do it would be:
Or even:
And I bet there will be a call from Unicorn that fails.
In my case, where it works, it is:
If this is the case that this call fails, it can be one of:
@disconnect3d Yea, Exception handled. Thx
I can perfectly reproduce this btw:
That’s cool and enables the max compatibility. I will try to get rid of 1GB requirement for the next release.
Unfortunately, “not enough memory” is exactly the case and I don’t think Oracle Ubuntu enables W^X.
Yes you are right and I’m working on propagating this error to users, which is a bit harder than I thought before because QEMU never considers this case.
@disconnect3d
This is probably wrong because Unicorn (QEMU) by default requests 1GB of memory on all platforms. You might observer some other allocation other than the code buffer.
@iiwwnnaa
AFAIK, the free tier gets 1GB per x86 instance and you could try to allocate some swap spaces as a workaround.