[rabbitmq-discuss] BasicPublish() from .NET client hangs after upgrading server to 1.7.1
Matthew Sackman
matthew at lshift.net
Thu Jan 28 16:34:30 GMT 2010
On Thu, Jan 28, 2010 at 04:04:43PM +0000, Matthew Sackman wrote:
> We shall investigate further. Many thanks for your help,
Yup, it's a bug in win32sysinfo.c which Erlang uses to call Windows to
find out how much memory it has. It has the following code:
void get_avail_mem_ext() {
char answer[512];
MEMORYSTATUSEX ms;
ms.dwLength=sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&ms);
sprintf(answer,"%d %I64d %I64d %I64d %I64d %I64d %I64d\n",
ms.dwMemoryLoad,
ms.ullTotalPhys,
ms.ullAvailPhys,
ms.ullTotalPageFile,
ms.ullAvailPageFile,
ms.ullTotalVirtual,
ms.ullAvailVirtual
);
return_answer(answer);
/*
DWORD dwLength;
DWORD dwMemoryLoad;
DWORDLONG ullTotalPhys;
DWORDLONG ullAvailPhys;
DWORDLONG ullTotalPageFile;
DWORDLONG ullAvailPageFile;
DWORDLONG ullTotalVirtual;
DWORDLONG ullAvailVirtual;
*/
}
Sadly, whoever wrote that didn't notice the fact that DWORD and DWORDLONG
are unsigned, whereas %I64d says to interpret the value as signed.
$ cat foo.c
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
main()
{
uint64_t n = 4293308416;
printf("%I64d\n", n);
printf("%I64u\n", n);
return 0;
}
$ gcc -o foo foo.c && ./foo
-1658880
4293308416
This is exactly what is happening. We'll file a bug with the erlang
people and try and work around it. I don't suppose by any chance you're
compiling erlang from source under Windows are you?
Best wishes,
Matthew
More information about the rabbitmq-discuss
mailing list