[erlang-questions] Half word emulators and NIFs

Sverker Eriksson sverker@REDACTED
Mon Jun 27 12:03:15 CEST 2011

Have you tested with a debug built emulator. That may catch faulty NIF 
behaviors earlier. Otherwise if a NIF builds broken terms on the process 
heap it might not be discovered until later when those terms are matched 
or maybe garbage collected.

There is no difference to make NIF's for the halfword emulator. Just use 
the NIF API as intended and don't cheat (make assumptions about 
sizeof(ERL_NIF_TERM) for example).

/Sverker, Erlang/OTP

Paolo Negri wrote:
> Dear list,
> We're running some test using the half word emulator and we're seeing
> few regressions.
> Our application runs with no problem on 32 and 64 VMs and regressions
> are specific to this emulator.
> While we're still looking at shrinking the broken test in order to
> identify exactly the failure, so far it seems - but we're not sure yet
> - that regressions are due to some interaction with a NIF [1]
> The behavior we're observing is that function clauses in pure erlang
> code (code not involving NIF calls) stop matching after the invocation
> of such a NIF.
> So far we couldn't build very simple ad hoc test cases to reproduce
> the failure, while more elaborated ones part of our application tests
> are consistent and always fail (while always pass using plain 32 or 64
> bit VMs).
> All function clauses that we seem to "lose" are very simple matches
> like integers and atoms.
> What I would like to ask is
> - Is it possible for a NIF to somehow break such basic features of the
> VM because of the NIF non compliance with the half word machine?
> - How is it possible to recognize if a NIF is or not safe to be used
> with the half word emulator?
> While cutting out the minimal piece of code to reproduce the failure
> in order to publish it might take us some time, we're open to provide
> access to an environment where is possible to consistently reproduce
> the failure if someone is interested into looking into this matter.
> [1] https://github.com/davisp/jiffy
> Thanks in advance for your answers,
> Paolo
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list