It turns out that the improperly initialised struct was a coincidence and unrelated to the ReadOnlyMemoryError() we were getting on Windows.
We have tracked the issue down, and it was very subtle. Basically the dll we built for MPIR (our GMP drop-in replacement) was being built incorrectly. It was using linux assembly code instead of Windows, causing all sorts of problems. The following is a bit off topic, but just in case anyone else encounters this issue themselves, here is the correct way to build MPIR and MPFR dlls on Windows 64 under msys2 with mingw-w64 compiler installed and in the PATH (assuming MPIR's ./config.guess claims you have a core2): wget http://mpir.org/mpir-2.7.2.tar.bz2 tar -xvf mpir-2.7.2.tar.bz2 cd mpir-2.7.2 ./configure --enable-shared --disable-static --enable-gmpcompat --build=core2-w64-mingw64 LDFLAGS=-static-libgcc ABI=64 cd .. wget http://www.mpfr.org/mpfr-current/mpfr-3.1.4.tar.bz2 tar -xvf mpfr-3.1.4.tar.bz2 cd mpfr-3.1.4 ./configure --with-gmp-build=/home/User/mpir-2.7.2 --enable-shared --disable-static make -j cd .. Bill.