Opened 4 years ago

Closed 3 years ago

#5494 closed bug (fixed)

"PAP object entered!" error when throw is used instead of throwIO

Reported by: mikhail.vorozhtsov Owned by:
Priority: high Milestone: 7.4.1
Component: Runtime System Version: 7.3
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Runtime crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

The following program

import qualified OpenSSL.Session as SSL
import OpenSSL (withOpenSSL)
import System.Posix.Types (Fd(..))

main = withOpenSSL $ do
  ctx <- SSL.context
  ssl <- SSL.fdConnection ctx (Fd (-1))
  SSL.tryConnect ssl
  return ()

triggers a "PAP object entered!" crash in HsOpenSSL 0.10.1:

$ ghc-7.3.20110916 -fforce-recomp Bug.hs
[1 of 1] Compiling Main             ( Bug.hs, Bug.o )
Linking Bug ...
$ ./Bug 
Bug: internal error: PAP object entered!
    (GHC version 7.3.20110916 for x86_64_unknown_linux)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
zsh: abort      ./Bug

The order of things is as follows (OpenSSL.Session module):

  1. tryConnect calls sslTryHandshake
  1. sslTryHandshake calls _ssl_connect which returns -1
  1. sslTryHandshake calls _ssl_get_error which returns 5 (SSL_ERROR_SYSCALL)
  1. sslTryHandshake calls throwSSLException which in this case is throw SSLIOError
  1. Program crashes

If I either replace throw with throwIO or build HsOpenSSL with -O0, the crash goes away. I haven't checked 7.2.1, but 7.0.3 doesn't have this issue.

Change History (6)

comment:1 Changed 3 years ago by igloo

  • Milestone set to 7.4.1
  • Owner set to igloo
  • Priority changed from normal to high

Thanks for the report. I'll see if I can reproduce the problem.

comment:2 Changed 3 years ago by mikhail.vorozhtsov

Be sure to use the exact version of HsOpenSSL. I replaced throw with throwIO in 0.10.1.1.

comment:3 Changed 3 years ago by igloo

  • Status changed from new to infoneeded

I had to make a few small changes to get it to build with HEAD (commenting out a couple of type signatures for record selectors, and making sure constructors for newtypes used in FFI bindings are visible), but having done so I couldn't reproduce it (building parsec-2.1.0.1, network-2.3.0.7, HsOpenSSL-0.10.1 with a HEAD validate build on amd64/Linux).

If you can still reproduce the problem then can you please make a minimal testcase, without any dependencies on libraries that don't come with GHC?

comment:4 Changed 3 years ago by igloo

  • Owner igloo deleted

comment:5 Changed 3 years ago by mikhail.vorozhtsov

Sorry for the late reply. The bug seems to have been fixed somewhere after 7th November. At least my program no longer crashes.

comment:6 Changed 3 years ago by simonmar

  • Resolution set to fixed
  • Status changed from infoneeded to closed

Thanks for getting back to us.

Note: See TracTickets for help on using tickets.