nochowderforyou / clams

Clam Project
MIT License
62 stars 58 forks source link

RPC broken on Windows #202

Closed dooglus closed 9 years ago

dooglus commented 9 years ago

See https://bitcointalk.org/index.php?topic=623147.msg11897391#msg11897391

Apparently the content-type header is having a 'u' appended.

dooglus commented 9 years ago

util.h defines the formats:

/* Format characters for (s)size_t and ptrdiff_t */
#if defined(_MSC_VER) || defined(__MSVCRT__)
  /* (s)size_t and ptrdiff_t have the same size specifier in MSVC:
     http://msdn.microsoft.com/en-us/library/tcxf1dw6%28v=vs.100%29.aspx
   */
  #define PRIszx    "Ix"
  #define PRIszu    "Iu"
  #define PRIszd    "Id"
  #define PRIpdx    "Ix"
  #define PRIpdu    "Iu"
  #define PRIpdd    "Id"
#else /* C99 standard */
  #define PRIszx    "zx"
  #define PRIszu    "zu"
  #define PRIszd    "zd"
  #define PRIpdx    "tx"
  #define PRIpdu    "tu"
  #define PRIpdd    "td"
#endif

So that's where the problem should be fixed?

l0rdicon commented 9 years ago

Your suggestion on the form of changing

bitcoin/src/rpcprotocol.cpp to:

        "Content-Length: %u\r\n"

was what I ended on as well. I think thats the way to go.

creativecuriosity commented 9 years ago

The Blackcoin commit for reference:

c974b211f048e33138ad760571e53ef7dee19670

dooglus commented 9 years ago

The blackcoin commit replaces PRIszu with u throughout? Wouldn't it be better to fix just the #define line if it's wrong?

I tried getting set up with gitian but am getting errors all over the place so I've so far been unable to experiment with the Windows compiler.

ghost commented 9 years ago

I encountered this in another altcoin (can't recall which, wasn't CLAMS tho'). Was under Linux (ubuntu 14.04) and bracketing the PRIszu with whitespace worked for me, as per the SO question on using symbols in a string referenced by dooglus in the bct thread.

See if this works:

"Content-Length: %" PRIszu "\r\n"

Cheers

Graham

dooglus commented 9 years ago

Fixed by #206 in release v1.4.15.

dooglus commented 9 years ago

@gjhiggins We tried adding spaces as you suggested, but it had no effect. It turned out the problem was that we were using gitian to cross-compile for Windows, which uses MinGW, which is a GNU c++ compiler and so doesn't know the non-ANSI Microsoft format codes.

See #205 for details of my testing and #206 for the resolution.

casinobitcoin commented 9 years ago

Cheers Guys!