[erlang-bugs] Bug in enif_compare/2 for bignums

Filipe David Manana <>
Thu Sep 1 03:11:13 CEST 2011

Nasty bug.

I've found this apparently can only happen in 64 bits machines, where
sizeof(Sint) is smaller than sizeof(int).
The following patch fixes the issue for me:



On Wed, Aug 31, 2011 at 11:20 AM, Paul Davis
<> wrote:
> Hello,
> I think I've uncovered a bug in enif_compare/2 for bignums. Converting
> the same arguments to ErlNifSInt64 values and using C comparison
> returns the correct result when enif_compare does not. There's a
> reduced test case at [1]. If there's nothing obvious I'll spend some
> time later digging into Erlang to see if I can spot the bug.
> Thanks,
> Paul Davis
> [1] https://github.com/davisp/enif_cmp_bug
> _______________________________________________
> erlang-bugs mailing list
> http://erlang.org/mailman/listinfo/erlang-bugs

Filipe David Manana,

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

More information about the erlang-bugs mailing list