[GHC] #12010: Incorrect return types for recv() and send() on Windows
#12010: Incorrect return types for recv() and send() on Windows --------------------------------------+---------------------------------- Reporter: enolan | Owner: enolan Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: Keywords: | Operating System: Windows Architecture: x86_64 (amd64) | Type of failure: Runtime crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+---------------------------------- They return signed 32 bit ints on Windows, even on a 64 bit OS, rather than Linux's 64 bit ssize_t. This means when recv() returned -1 to signal an error we thought it was 4294967295. It was converted to an int, -1 and the buffer was memcpy'd which caused a segfault. Other bad stuff happened with send()s. The problem is in `blockingReadRawBufferPtr` and `blockingWriteRawBufferPtr` in `GHC.IO.FD` which are only called in the threaded RTS. See also note CSsize in System.Posix.Internals. I have a patch and a test incoming. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12010> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12010: Incorrect return types for recv() and send() on Windows -----------------------------------+-------------------------------------- Reporter: enolan | Owner: enolan Type: bug | Status: patch Priority: normal | Milestone: Component: Core Libraries | Version: Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2170 Wiki Page: | -----------------------------------+-------------------------------------- Changes (by enolan): * status: new => patch * differential: => Phab:D2170 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12010#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12010: Incorrect return types for recv() and send() on Windows -----------------------------------+-------------------------------------- Reporter: enolan | Owner: enolan Type: bug | Status: patch Priority: normal | Milestone: Component: Core Libraries | Version: Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2170 Wiki Page: | -----------------------------------+-------------------------------------- Comment (by Tamar Christina <tamar@…>): In [changeset:"1ee47c1bfa35c7be435adaec5c1fa9ec92cc776d/ghc" 1ee47c1b/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="1ee47c1bfa35c7be435adaec5c1fa9ec92cc776d" Use the correct return type for Windows' send()/recv() (Fix #12010) Summary: They return signed 32 bit ints on Windows, even on a 64 bit OS, rather than Linux's 64 bit ssize_t. This means when recv() returned -1 to signal an error we thought it was 4294967295. It was converted to an int, -1 and the buffer was memcpy'd which caused a segfault. Other bad stuff happened with send()s. See also note CSsize in System.Posix.Internals. Add a test for #12010 Test Plan: - GHC testsuite (T12010) - http-conduit test (https://github.com/snoyberg/http-client/issues/191) Reviewers: austin, hvr, bgamari, Phyx Reviewed By: Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2170 GHC Trac Issues: #12010 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12010#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12010: Incorrect return types for recv() and send() on Windows -----------------------------------+-------------------------------------- Reporter: enolan | Owner: enolan Type: bug | Status: closed Priority: normal | Milestone: Component: Core Libraries | Version: Resolution: fixed | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2170 Wiki Page: | -----------------------------------+-------------------------------------- Changes (by Phyx-): * status: patch => closed * resolution: => fixed Comment: Thanks for the patch @enolan! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12010#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12010: Incorrect return types for recv() and send() on Windows -----------------------------------+-------------------------------------- Reporter: enolan | Owner: enolan Type: bug | Status: closed Priority: normal | Milestone: Component: Core Libraries | Version: Resolution: fixed | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2170 Wiki Page: | -----------------------------------+-------------------------------------- Comment (by Tamar Christina <tamar@…>): In [changeset:"a1f3bb8ca454f05fa35cb6b5c64e92f640380802/ghc" a1f3bb8/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="a1f3bb8ca454f05fa35cb6b5c64e92f640380802" Fix failing T12010 Summary: T12010 seems to be failing because it can't find the correct paths. This gives the test some more qualified paths. Test Plan: make TEST=12010 Reviewers: hvr, bgamari, austin, thomie Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D2252 GHC Trac Issues: #12010 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12010#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12010: Incorrect return types for recv() and send() on Windows -----------------------------------+-------------------------------------- Reporter: enolan | Owner: enolan Type: bug | Status: closed Priority: normal | Milestone: Component: Core Libraries | Version: Resolution: fixed | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2170 Wiki Page: | -----------------------------------+-------------------------------------- Comment (by mpickering): This test fails for me on OSX because {{{ Wrong exit code (expected 0 , actual 2 ) Stdout: Stderr: T12010.hsc:12:10: fatal error: 'HsBase.h' file not found #include "HsBase.h" ^ 1 error generated. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12010#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12010: Incorrect return types for recv() and send() on Windows -----------------------------------+-------------------------------------- Reporter: enolan | Owner: enolan Type: bug | Status: closed Priority: normal | Milestone: Component: Core Libraries | Version: Resolution: fixed | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2170 Wiki Page: | -----------------------------------+-------------------------------------- Comment (by Thomas Miedema <thomasmiedema@…>): In [changeset:"2230c8822233d6d68f930170cd51d96169649056/ghc" 2230c882/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="2230c8822233d6d68f930170cd51d96169649056" Testsuite: fix T12010 for real * Use `extra_files` instead of (the deprecated) `extra_clean` (#11980). * Don't depend on generated files from build tree (libraries/base/include/HsBaseConfig.h). Running 'make test TEST=T12010' should work, even without building GHC first (it will use the system installed ghc). Test Plan: 'make test TEST=T12010' on Linux and Windows. Reviewed by: Phyx Differential Revision: https://phabricator.haskell.org/D2256 GHC Trac Issues: #12010 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12010#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12010: Incorrect return types for recv() and send() on Windows -----------------------------------+-------------------------------------- Reporter: enolan | Owner: enolan Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Core Libraries | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2170 Wiki Page: | -----------------------------------+-------------------------------------- Changes (by bgamari): * status: closed => merge * version: => 8.0.1 * milestone: => 8.0.2 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12010#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12010: Incorrect return types for recv() and send() on Windows -----------------------------------+-------------------------------------- Reporter: enolan | Owner: enolan Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Core Libraries | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2170 Wiki Page: | -----------------------------------+-------------------------------------- Changes (by bgamari): * status: merge => closed Comment: comment:2 merged to `ghc-8.0` as 2a6ac3f18dc6e8abc779b8fbc7232e972f4a8a7d. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12010#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12010: Incorrect return types for recv() and send() on Windows -----------------------------------+-------------------------------------- Reporter: enolan | Owner: enolan Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Core Libraries | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2170 Wiki Page: | -----------------------------------+-------------------------------------- Comment (by Phyx-): Can you merge 2230c8822233d6d68f930170cd51d96169649056 as well @bgamari? Otherwise the test will fail. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12010#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC