I’m writing a NIF to process a large list of 3-element tuples. When I pass a list of length of at most 256 elements, it works fine. However when my list length is 257, I’m getting a badarg error. That’s strange because I don’t use enif_make_badarg, I prefer to report {:error, msg} tuples to help in debugging (as the code is bit long with parsing all the terms).
I need to create a grid of interpolated values from a large array of points. I want to do this in NIF as it seems it will be much faster. I chose Zig as the language.
The only enif_* functions raising badarg exception are
enif_make_badarg // of course
enif_raise_exception // if passed the atom 'badarg'
enif_make_double // for non finite values
enif_make_atom // for too long atoms
enif_make_atom_len
enif_cpu_time // if not supported
enif_schedule_nif // various error cases
You can also use enif_has_pending_exception to find where the exception is generated.