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.
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.