erl_arith.c

Tony Rogvall <>
Tue Nov 30 10:29:44 CET 1999


Hi there!

I have found a potential problem in erl_arith.c. I found it while
working on a libbeam.so for building standalone apps. (I modified the
sae stuff to link with a shared object, this makes it possible to write
small "real" executable as well)

The problem:

in erl_arith.c the tmp_big_buff is declared as

static Eterm tmp_big_buff[4];

and is used for temporary bignums, but on what address do you find
tmp_big_buff????

this buffer MUST be safe_allocated!

Solution:

in erl_arith.c

static Eterm* tmp_big_buff;

void init_arith()
{
      tmp_big_buff = (Eterm*) safe_alloc(sizeof(Eterm)*4);
}

in beam_emu (or some other place)

void init_emulator()
{
    ....

    init_arith();
    ....
}

and some declaration in global.h

I did not want to send a patch since this must be given some thought?

/Tony





More information about the erlang-questions mailing list