Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mallocPlainForeignPtrBytes: size must be >= 0 on Windows #2035

Closed
3noch opened this issue Aug 8, 2014 · 25 comments
Closed

mallocPlainForeignPtrBytes: size must be >= 0 on Windows #2035

3noch opened this issue Aug 8, 2014 · 25 comments

Comments

@3noch
Copy link

3noch commented Aug 8, 2014

Using 1.18.0.5 on Windows 8.1 x64 from the Haskell Platform 2014.2.0 RC4:

> cabal update -v3
Downloading the latest package list from hackage.haskell.org
Sending:
GET /packages/archive/00-index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.18.0.5

Creating new connection to hackage.haskell.org
Received:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.0
Date: Fri, 08 Aug 2014 20:52:25 GMT
Content-Type: text/plain; charset=UTF-8
Connection: keep-alive
Location: /packages/index.tar.gz
Content-Length: 0

301 - redirect
Redirecting to http://hackage.haskell.org/packages/index.tar.gz ...
Sending:
GET /packages/index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.18.0.5

Recovering connection to hackage.haskell.org
cabal: mallocPlainForeignPtrBytes: size must be >= 0
@3noch
Copy link
Author

3noch commented Aug 8, 2014

I've tried turning off Windows firewall, Internet filter, VPN, etc. to no avail.

@23Skidoo
Copy link
Member

23Skidoo commented Aug 9, 2014

Are you using the 64-bit version of HP?

@23Skidoo
Copy link
Member

23Skidoo commented Aug 9, 2014

I tried to reproduce with both 32-bit and 64-bit versions, but everything
works fine on my machine (Windows 7 x64).

On 8 August 2014 22:54, Elliot Cameron [email protected] wrote:

I've tried turning off Windows firewall, Internet filter, VPN, etc. to no
avail.


Reply to this email directly or view it on GitHub
#2035 (comment).

@3noch
Copy link
Author

3noch commented Aug 9, 2014

Yes, HP x86_64.

@3noch
Copy link
Author

3noch commented Aug 9, 2014

I should mention that standalone cabal doesn't work either, but with a different error:

Desktop> cabal --version
cabal-install version 1.20.0.3
using version 1.20.0.1 of the Cabal library

Desktop> cabal update -v3
Downloading the latest package list from hackage.haskell.org
Sending:
GET /packages/archive/00-index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.20.0.3 (windows; i386)

Creating new connection to hackage.haskell.org
Received:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.0
Date: Sat, 09 Aug 2014 14:11:35 GMT
Content-Type: text/plain; charset=UTF-8
Connection: keep-alive
Location: /packages/index.tar.gz
Content-Length: 0

301 - redirect
Redirecting to http://hackage.haskell.org/packages/index.tar.gz ..
Sending:
GET /packages/index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.20.0.3 (windows; i386)

Recovering connection to hackage.haskell.org
cabal: <socket: 368>: invalid argument

@23Skidoo
Copy link
Member

23Skidoo commented Aug 9, 2014

These errors are likely coming from the network library. @tibbe, do they look familiar to you?

mallocPlainForeignPtrBytes is used inside bytestring (which is used by network to allocate buffers), and the <socket: > error also looks network-related.

@23Skidoo
Copy link
Member

23Skidoo commented Aug 9, 2014

One thing to try is to recompile cabal-install with profiling enabled and then run cabal update with +RTS -xc to generate a stack trace. This can give us a clue about what is happening.

@23Skidoo
Copy link
Member

23Skidoo commented Aug 9, 2014

One thing to try is to recompile cabal-install with profiling enabled.

See here for instructions on how to do that. Something like cabal get cabal-install-1.18.0.5 && cd cabal-install-1.18.0.5 && cabal configure --enable-executable-profiling --ghc-options="-auto-all -caf-all" && cabal build should work (HP already comes with profiling versions of all libraries).

@3noch
Copy link
Author

3noch commented Aug 9, 2014

Should I install the package index manually somehow?

> cabal get cabal-install-1.18.0.5 && cd cabal-install-1.18.0.5 && cabal configure --enable-e
xecutable-profiling --with-ghc-options="-auto-all -caf-all" && cabal build
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
cabal: There is no package named 'cabal-install'.
You may need to run 'cabal update' to get the latest list of available
packages.

@23Skidoo
Copy link
Member

23Skidoo commented Aug 9, 2014

Well, you can always download and unpack the tarball manually if cabal get doesn't work.

@tibbe
Copy link
Member

tibbe commented Aug 9, 2014

@23Skidoo doesn't look familiar to me.

@3noch
Copy link
Author

3noch commented Aug 9, 2014

cabal-install-1.18.0.5> cabal --version
cabal-install version 1.20.0.3
using version 1.20.0.1 of the Cabal library

cabal-install-1.18.0.5> ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.3

cabal-install-1.18.0.5> cabal configure --enable-executable-profiling --ghc-options="-auto-all" --ghc-options="-caf-all" && cabal build
[...]

cabal-install-1.18.0.5> dist\build\cabal\cabal.exe update -v3 +RTS -xc
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Distribution.Client.Config.readConfigFile.handleNotExists,
  called from Distribution.Client.Config.readConfigFile,
  called from Distribution.Client.Config.loadConfig.addBaseConf,
  called from Distribution.Client.Config.loadConfig,
  called from Main.updateAction,
  called from Main.mainWorker,
  called from Main.main
Downloading the latest package list from hackage.haskell.org
*** Exception (reporting due to +RTS -xc): (THUNK), stack trace:
  Distribution.Client.FetchUtils.downloadIndex,
  called from Distribution.Client.Update.updateRepo,
  called from Distribution.Client.Update.update,
  called from Main.updateAction,
  called from Main.mainWorker,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Distribution.Client.HttpUtils.downloadURI,
  called from Distribution.Client.FetchUtils.downloadIndex,
  called from Distribution.Client.Update.updateRepo,
  called from Distribution.Client.Update.update,
  called from Main.updateAction,
  called from Main.mainWorker,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Distribution.Client.HttpUtils.downloadURI,
  called from Distribution.Client.FetchUtils.downloadIndex,
  called from Distribution.Client.Update.updateRepo,
  called from Distribution.Client.Update.update,
  called from Main.updateAction,
  called from Main.mainWorker,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Distribution.Client.HttpUtils.downloadURI,
  called from Distribution.Client.FetchUtils.downloadIndex,
  called from Distribution.Client.Update.updateRepo,
  called from Distribution.Client.Update.update,
  called from Main.updateAction,
  called from Main.mainWorker,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Distribution.Client.HttpUtils.downloadURI,
  called from Distribution.Client.FetchUtils.downloadIndex,
  called from Distribution.Client.Update.updateRepo,
  called from Distribution.Client.Update.update,
  called from Main.updateAction,
  called from Main.mainWorker,
  called from Main.main
Sending:
GET /packages/archive/00-index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.18.0.5

Creating new connection to hackage.haskell.org
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Distribution.Client.HttpUtils.cabalBrowse,
  called from Distribution.Client.HttpUtils.getHTTP,
  called from Distribution.Client.HttpUtils.downloadURI,
  called from Distribution.Client.FetchUtils.downloadIndex,
  called from Distribution.Client.Update.updateRepo,
  called from Distribution.Client.Update.update,
  called from Main.updateAction,
  called from Main.mainWorker,
  called from Main.main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Distribution.Client.HttpUtils.cabalBrowse,
  called from Distribution.Client.HttpUtils.getHTTP,
  called from Distribution.Client.HttpUtils.downloadURI,
  called from Distribution.Client.FetchUtils.downloadIndex,
  called from Distribution.Client.Update.updateRepo,
  called from Distribution.Client.Update.update,
  called from Main.updateAction,
  called from Main.mainWorker,
  called from Main.main
Received:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.0
Date: Sat, 09 Aug 2014 20:47:58 GMT
Content-Type: text/plain; charset=UTF-8
Connection: keep-alive
Location: /packages/index.tar.gz
Content-Length: 0

301 - redirect
Redirecting to http://hackage.haskell.org/packages/index.tar.gz ...
Sending:
GET /packages/index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.18.0.5

Recovering connection to hackage.haskell.org
[runs indefinitely...]

Notice that cabal freezes at that point and cannot be closed with Ctrl+C.

@23Skidoo
Copy link
Member

23Skidoo commented Aug 9, 2014

So it looks like it dies somewhere in the bowels of HTTP/network.

Might be an x64-only issue. Does the 32-bit version of cabal-install work for you?

@3noch
Copy link
Author

3noch commented Aug 9, 2014

Sadly, I tried that already:

cabal-1.20.0.3-i386-unknown-mingw32> cabal update -v3
Downloading the latest package list from hackage.haskell.org
Sending:
GET /packages/archive/00-index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.20.0.3 (windows; i386)

Creating new connection to hackage.haskell.org
Received:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.0
Date: Sat, 09 Aug 2014 21:01:55 GMT
Content-Type: text/plain; charset=UTF-8
Connection: keep-alive
Location: /packages/index.tar.gz
Content-Length: 0

301 - redirect
Redirecting to http://hackage.haskell.org/packages/index.tar.gz ...
Sending:
GET /packages/index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.20.0.3 (windows; i386)

Recovering connection to hackage.haskell.org
cabal: <socket: 364>: invalid argument

@23Skidoo
Copy link
Member

23Skidoo commented Aug 9, 2014

Since this seems to happen only on Windows 8.1, maybe you should try experimenting with compatibility settings.

@3noch
Copy link
Author

3noch commented Aug 9, 2014

Running in compatibility mode for Windows 7 and Vista: same result. Running as admin: same result. I did run the latest 32-bit version that you referenced on a 32-bit Windows 7 VM without any issues.

@3noch
Copy link
Author

3noch commented Aug 9, 2014

This is bound to make your day: Just ran it on a fresh Windows 8.1 x64 VM and it worked without issue. It still looks like a bug (since cabal is the only program that is having network issues on my host machine), but it's likely some sort of rare networking shenanigans.

@3noch
Copy link
Author

3noch commented Aug 9, 2014

Just for thoroughness: tested the official release of Haskell Platform 2014.2.0 on my host machine with the same error result.

@23Skidoo
Copy link
Member

The issue likely affects every Haskell program using HTTP/network. We need to find a way to reproduce it reliably.

@3noch
Copy link
Author

3noch commented Aug 11, 2014

I'm open to any suggestions. I'm even willing to let someone remote into my machine for a bit to do some step-by-step debugging. Perhaps this bug should be forwarded to a different repository then?

@23Skidoo
Copy link
Member

@3noch

Can you try compiling and running this test program? It downloads the index-00.tar.gz file to the directory you run it from.

If the bug still happens with my test program, we can then move this ticket to the HTTP library bug tracker.

@3noch
Copy link
Author

3noch commented Aug 18, 2014

Let me know if you want me to move the ticket myself.

http-test> ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.3

http-test> ghc --make Main.hs -o test.exe
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking test.exe ...

http-test> .\test.exe
Trying to download http://hackage.haskell.org/packages/archive/00-index.tar.gz
Sending:
GET /packages/archive/00-index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.18.0.5


Creating new connection to hackage.haskell.org
Received:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.0
Date: Mon, 18 Aug 2014 22:24:44 GMT
Content-Type: text/plain; charset=UTF-8
Connection: keep-alive
Location: /packages/index.tar.gz
Content-Length: 0


301 - redirect
Redirecting to http://hackage.haskell.org/packages/index.tar.gz ...
Sending:
GET /packages/index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.18.0.5


Recovering connection to hackage.haskell.org
test.exe: <socket: 336>: hGetBufSome: failed (Unknown error)

@3noch
Copy link
Author

3noch commented Aug 18, 2014

More details:

http-test> ghc --make Main.hs -o test.exe -prof -auto-all -caf-all
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking test.exe ...

http-test> .\test.exe +RTS -xc
Trying to download http://hackage.haskell.org/packages/archive/00-index.tar.gz
Sending:
GET /packages/archive/00-index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.18.0.5


Creating new connection to hackage.haskell.org
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
Received:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.0
Date: Mon, 18 Aug 2014 22:29:21 GMT
Content-Type: text/plain; charset=UTF-8
Connection: keep-alive
Location: /packages/index.tar.gz
Content-Length: 0


301 - redirect
Redirecting to http://hackage.haskell.org/packages/index.tar.gz ...
Sending:
GET /packages/index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.18.0.5


Recovering connection to hackage.haskell.org
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
*** Exception (reporting due to +RTS -xc): (THUNK_1_0), stack trace:
  Main.main,
  called from :Main.CAF:main
test.exe: <socket: 336>: hGetBufSome: failed (Unknown error)

@23Skidoo
Copy link
Member

Let me know if you want me to move the ticket myself.

Sure, please do.

@23Skidoo
Copy link
Member

Moved to haskell/HTTP#72.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants