Skip to content

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

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
  2. sslTryHandshake calls _ssl_connect which returns -1
  3. sslTryHandshake calls _ssl_get_error which returns 5 (SSL_ERROR_SYSCALL)
  4. sslTryHandshake calls throwSSLException which in this case is throw SSLIOError
  5. 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.

Trac metadata
Trac field Value
Version 7.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Runtime System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information