unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.33k stars 1.31k forks source link

Function `code_gen_alloc` calls `exit()` #1921

Closed twizmwazin closed 4 months ago

twizmwazin commented 5 months ago

See here: https://github.com/unicorn-engine/unicorn/blame/dev/qemu/accel/tcg/translate-all.c#L1091

This is not good for library code, as I would like to be able to handle this error instead of having my process disappear. The ideal solution would be to see if it is possible to allocate a smaller buffer (I don't know if this is possible, but I noticed in some related code there was handling of a command line flag to limit the size, so maybe if under memory pressure it could try halving it in a loop until the allocation succeeds). Alternatively some sort of error propagation so that this could be handled by user code from the python bindings would at least allow failing more gracefully.

disconnect3d commented 4 months ago

This is a duplicate of https://github.com/unicorn-engine/unicorn/issues/1766 but I agree this should get more priority.

twizmwazin commented 4 months ago

Ah my bad, I'll follow that issue.