You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS EC2 Ubuntu实例调试x86程序时动态翻译器缓冲区分配失败的解决方法

问题

我需要调试x86 Intel架构的程序,但设备是M1 MacBook,因此使用亚马逊EC2 Ubuntu Server免费版实例。在Python脚本中通过pwntools获取可执行文件ELF信息时,脚本代码如下:

from pwn import *

p = process("./rtl")
e = ELF("./rtl")

def slog(name, addr): return success(": ".join([name, hex(addr)]))

buf = b'A'*0x39
p.sendafter("Buf: ", buf)
p.recvuntil(buf)
cnry = u64(b'\x00' + p.recvn(7))
slog('canary', cnry)

执行脚本后收到错误提示:

Could not allocate dynamic translator buffer

同时使用gdb和pwndbg调试时也出现该错误:

pwndbg: loaded 157 pwndbg commands and 43 shell commands. Type pwndbg [--shell | --all] [filter] for a list.
pwndbg: created $rebase, $ida gdb functions (can be used with print/break)
Reading symbols from rtl...
(No debugging symbols found in rtl)
------- tip of the day (disable with set show-tips off) -------
The $heap_base GDB variable can be used to refer to the starting address of the heap after running the heap command
pwndbg> start
Temporary breakpoint 1 at 0x4011de

Temporary breakpoint 1, 0x00000000004011de in main ()
Could not allocate dynamic translator buffer

请问该如何解决这个缓冲区分配问题?

解决方法

这个错误是EC2免费实例(t2.micro)内存不足导致的——t2.micro仅配备1GB内存,运行QEMU用户态模拟x86程序时,动态翻译器所需的内存分配失败。可通过以下方式解决:

  • 升级EC2实例规格:临时切换到内存更大的实例(如t3.small,2GB内存),调试完成后切回t2.micro避免额外费用:
    1. 停止当前t2.micro实例
    2. 在实例设置中选择「更改实例类型」,切换到t3.small
    3. 启动实例后重新调试程序
  • 优化系统内存占用:若不想升级实例,先关闭不必要的进程释放内存:
    1. 用top或htop查看高内存占用进程
    2. 关闭闲置服务(如systemctl stop apache2,根据实际运行服务调整)
    3. 清理系统缓存:执行sync && echo 3 > /proc/sys/vm/drop_caches
  • 调整QEMU内存配额:启动程序时手动指定更大的内存额度,在pwntools脚本中修改process参数:
    p = process("./rtl", env={"QEMU_X86_MEM": "512M"})
    
    或直接在终端运行程序前设置环境变量:
    QEMU_X86_MEM=512M ./rtl
    

内容的提问来源于stack exchange,提问作者Chung

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 10:20:41