Opened 8 years ago

Closed 8 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 Rev(s):
Wiki Page:


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:
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 8 years ago by igloo

Milestone: 7.4.1
Owner: set to igloo
Priority: normalhigh

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

comment:2 Changed 8 years ago by mikhail.vorozhtsov

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

comment:3 Changed 8 years ago by igloo

Status: newinfoneeded

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-, network-, 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 8 years ago by igloo

Owner: igloo deleted

comment:5 Changed 8 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 8 years ago by simonmar

Resolution: fixed
Status: infoneededclosed

Thanks for getting back to us.

Note: See TracTickets for help on using tickets.