[erlang-bugs] inet:getstat/2 broken on some 64bit platforms

Tim Watson <>
Mon Dec 17 14:52:27 CET 2012

In the RabbitMQ Management Plugin (http://www.rabbitmq.com/management.html) we've seen _oct variants wrap after 2^32 bytes are sent, even on 64bit platforms. Looking at inet_drv.c, the code in inet_fill_stat assumes that unsigned longs are always 32 bit, which is a false assumption. The standard simply states that `unsigend long' is not smaller than 32 bits (or despite theoretically being untrue, that in practical use `sizeof(a) <= sizeof(long)' should probably hold) - anyway there are many platforms standardised on ILP64 and LP64 schemes, and on those platforms we end up with 128 bit counters and subsequently lose bits 32-63 and 96-127. Is there a compelling reason we don't want to use the definitions in stdint.h here? AFAIK this is only missing on OSF/1 4.0 (and under MSVC 9) and whilst it may be incomplete on some platforms the type defs are at least there. Either way this code appears to be wrong for many 64 bit unices.


Tim Watson
Staff Engineer
RabbitMQ / VMWare

More information about the erlang-bugs mailing list