haskell-game / sdl2

Haskell bindings to the SDL2 library
Other
361 stars 87 forks source link

segfault with multithreaded code #73

Closed mitchellwrosen closed 8 years ago

mitchellwrosen commented 9 years ago

Crossposting HeinrichApfelmus/reactive-banana#103, I'll update this ticket tomorrow with a more minimal example.

ocharles commented 9 years ago

I think I will need a minimal example, because

{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Main where

import Control.Concurrent
import Control.Monad
import Data.Function (fix)
import Foreign.C.Types (CInt)
import Linear.Affine
import Linear.V2
import Linear.V4
import Reactive.Banana
import Reactive.Banana.Frameworks
import SDL

data InputEvent
    = UpPressed
    | DownPressed
    deriving Show

main :: IO ()
main = do
    SDL.initialize [SDL.InitEverything]
    window <- SDL.createWindow "Pong" SDL.defaultWindow
    renderer <- SDL.createRenderer window (-1) SDL.defaultRenderer

    (frameAddHandler,   fireFrame) <- newAddHandler
    (eventAddHandler, fireEvent) <- newAddHandler
    network <- compile (makeNetwork renderer frameAddHandler eventAddHandler)
    actuate network

    forkIO . forever $ do
        fireFrame ()
        threadDelay 1000000 -- 1 fps

    fix $ \loop -> do
         e <- SDL.pollEvent
         case e of
           Just e ->
             case SDL.eventPayload e of
                 SDL.KeyboardEvent (SDL.KeyboardEventData _ pressed _ (SDL.Keysym _ keycode _)) ->
                     case (keycode, pressed) of
                         (SDL.KeycodeUp,   SDL.Pressed)  -> fireEvent UpPressed    >> loop
                         (SDL.KeycodeDown, SDL.Pressed)  -> fireEvent DownPressed  >> loop
                         (SDL.KeycodeQ,    SDL.Pressed)  -> pure ()
                         _                               -> loop
                 _ -> loop
           Nothing -> loop

makeNetwork :: forall t. Frameworks t => SDL.Renderer -> AddHandler () -> AddHandler InputEvent -> Moment t ()
makeNetwork renderer frameAddHandler eventAddHandler = do
    frames <- fromAddHandler frameAddHandler
    events <- fromAddHandler eventAddHandler

    let bpaddle :: Behavior t Paddle
        bpaddle = accumB initPaddle (f <$> events)
          where
            f :: InputEvent -> Paddle -> Paddle
            f UpPressed   = paddleUp
            f DownPressed = paddleDown

        epaddle = bpaddle <@ frames

    reactimate $ renderPaddle renderer <$> epaddle

type Paddle = Rectangle CInt

initPaddle :: Paddle
initPaddle = Rectangle (P (V2 100 100)) (V2 20 20)

paddleDown :: Paddle -> Paddle
paddleDown (Rectangle x y) = Rectangle (x + (P (V2 0 1))) y

paddleUp :: Paddle -> Paddle
paddleUp (Rectangle x y) = Rectangle (x - (P (V2 0 1))) y

renderPaddle :: Renderer -> Paddle -> IO ()
renderPaddle renderer p = do
    renderDrawColor renderer $= V4 0 0 255 255
    renderFillRect renderer (Just p)
    renderPresent renderer

Does not seg fault, for me. I'm using an unreleased version of reactive-banana (the gc-new branch) and the new-api branch of SDL2.

mitchellwrosen commented 9 years ago
{-# LANGUAGE OverloadedStrings #-}

module Main where

import Control.Concurrent
import Control.Monad
import Linear.Affine
import Linear.V2
import SDL

main :: IO ()
main = do
    SDL.initialize [SDL.InitEverything]
    window <- SDL.createWindow "" SDL.defaultWindow
    renderer <- SDL.createRenderer window (-1) SDL.defaultRenderer
    forkIO $ renderFillRect renderer (Just (Rectangle (P (V2 0 0)) (V2 10 10)))
    threadDelay 500000

This is segfaulting for me, compiled with -O0 -threaded. I'm on OSX 10.9.5 using sdl2 2.0.3, commit 99d5e0974456b06d42e8cb9406c9a8cba55621cf of haskell-game/sdl.

ocharles commented 9 years ago

Perfect, thank you! I'll see what's up.

ocharles commented 9 years ago

Unfortunately I can't reproduce the problem with your paste :( Are you able to obtain a stack trace of the segfault? In Linux I'd recommend running under gdb, but I'm not sure what the OS X equivalent is.

mitchellwrosen commented 9 years ago

I have this (the binary I ran is called junk):

Process:         junk [69200]
Path:            /Users/USER/*/junk
Identifier:      junk
Version:         0
Code Type:       X86-64 (Native)
Parent Process:  stack [69193]
Responsible:     iTerm [1091]
User ID:         1346372900

Date/Time:       2015-09-01 20:45:38.960 -0700
OS Version:      Mac OS X 10.9.5 (13F34)
Report Version:  11
Anonymous UUID:  A7CBB21B-E759-1739-4971-430024C8DD7D

Sleep/Wake UUID: 511CB01F-AA96-4FAE-B8E6-B8A071BC0345

Crashed Thread:  14

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000

VM Regions Near 0:
--> 
    __TEXT                 000000010effd000-000000010fa8d000 [ 10.6M] r-x/rwx SM=COW  /Users/USER/*

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff8eeb0716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff90539c3b _pthread_cond_wait + 727
2   junk                            0x000000010fa48e16 waitCondition + 6
3   junk                            0x000000010fa1e0a3 0x10effd000 + 10621091

Thread 1:
0   libsystem_kernel.dylib          0x00007fff8eeb164a kevent + 10
1   junk                            0x000000010f9b2b87 0x10effd000 + 10181511
2   junk                            0x000000010f9b3910 0x10effd000 + 10184976

Thread 2:
0   libsystem_kernel.dylib          0x00007fff8eeb164a kevent + 10
1   junk                            0x000000010f9b2b87 0x10effd000 + 10181511
2   junk                            0x000000010f9b3910 0x10effd000 + 10184976

Thread 3:
0   libsystem_kernel.dylib          0x00007fff8eeb164a kevent + 10
1   junk                            0x000000010f9b2b87 0x10effd000 + 10181511
2   junk                            0x000000010f9b3910 0x10effd000 + 10184976

Thread 4:
0   libsystem_kernel.dylib          0x00007fff8eeb164a kevent + 10
1   junk                            0x000000010f9b2b87 0x10effd000 + 10181511
2   junk                            0x000000010f9b3910 0x10effd000 + 10184976

Thread 5:
0   libsystem_kernel.dylib          0x00007fff8eeb164a kevent + 10
1   junk                            0x000000010f9b2b87 0x10effd000 + 10181511
2   junk                            0x000000010f9b3910 0x10effd000 + 10184976

Thread 6:
0   libsystem_kernel.dylib          0x00007fff8eeb164a kevent + 10
1   junk                            0x000000010f9b2b87 0x10effd000 + 10181511
2   junk                            0x000000010f9b3910 0x10effd000 + 10184976

Thread 7:
0   libsystem_kernel.dylib          0x00007fff8eeb164a kevent + 10
1   junk                            0x000000010f9b2b87 0x10effd000 + 10181511
2   junk                            0x000000010f9b3910 0x10effd000 + 10184976

Thread 8:
0   libsystem_kernel.dylib          0x00007fff8eeb164a kevent + 10
1   junk                            0x000000010f9b2b87 0x10effd000 + 10181511
2   junk                            0x000000010f9b3910 0x10effd000 + 10184976

Thread 9:
0   libsystem_kernel.dylib          0x00007fff8eeb0716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff90539c3b _pthread_cond_wait + 727
2   junk                            0x000000010fa48e16 waitCondition + 6
3   junk                            0x000000010fa1e0a3 0x10effd000 + 10621091
4   ???                             0x00000000434f4e44 0 + 1129270852

Thread 10:
0   libsystem_kernel.dylib          0x00007fff8eeb0716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff90539c3b _pthread_cond_wait + 727
2   junk                            0x000000010fa48e16 waitCondition + 6
3   junk                            0x000000010fa1e0a3 0x10effd000 + 10621091
4   ???                             0x00000000434f4e44 0 + 1129270852

Thread 11:
0   libsystem_kernel.dylib          0x00007fff8eeb0716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff90539c3b _pthread_cond_wait + 727
2   junk                            0x000000010fa48e16 waitCondition + 6
3   junk                            0x000000010fa1e0a3 0x10effd000 + 10621091
4   ???                             0x00000000434f4e44 0 + 1129270852

Thread 12:
0   libsystem_kernel.dylib          0x00007fff8eeb0716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff90539c3b _pthread_cond_wait + 727
2   junk                            0x000000010fa48e16 waitCondition + 6
3   junk                            0x000000010fa1e0a3 0x10effd000 + 10621091
4   ???                             0x00000000434f4e44 0 + 1129270852

Thread 13:
0   libsystem_kernel.dylib          0x00007fff8eeb0716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff90539c3b _pthread_cond_wait + 727
2   junk                            0x000000010fa48e16 waitCondition + 6
3   junk                            0x000000010fa1e0a3 0x10effd000 + 10621091
4   ???                             0x00000000434f4e44 0 + 1129270852

Thread 14 Crashed:
0   libGL.dylib                     0x00007fff8e50e5af glTexEnvf + 17
1   libSDL2-2.0.0.dylib             0x00000001101058fa GL_SetDrawingState + 218
2   libSDL2-2.0.0.dylib             0x0000000110104116 GL_RenderFillRects + 38
3   libSDL2-2.0.0.dylib             0x00000001100fd60b SDL_RenderFillRects_REAL + 235
4   libSDL2-2.0.0.dylib             0x00000001100fd518 SDL_RenderFillRect_REAL + 136
5   junk                            0x000000010f09ce17 0x10effd000 + 654871

Thread 15:
0   libsystem_kernel.dylib          0x00007fff8eeb0716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff90539c3b _pthread_cond_wait + 727
2   junk                            0x000000010fa48e16 waitCondition + 6
3   junk                            0x000000010fa1e0a3 0x10effd000 + 10621091
4   ???                             0x00000000434f4e44 0 + 1129270852

Thread 16:
0   libsystem_kernel.dylib          0x00007fff8eeb194a poll + 10
1   junk                            0x000000010f9cbe44 0x10effd000 + 10284612

Thread 17:
0   libsystem_kernel.dylib          0x00007fff8eeb0716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff90539c3b _pthread_cond_wait + 727
2   junk                            0x000000010fa48e16 waitCondition + 6
3   junk                            0x000000010fa1e0a3 0x10effd000 + 10621091
4   ???                             0x00000000434f4e44 0 + 1129270852

Thread 18:: SDLTimer
0   libsystem_kernel.dylib          0x00007fff8eeb0716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff90539c3b _pthread_cond_wait + 727
2   libSDL2-2.0.0.dylib             0x000000011016d56e SDL_CondWaitTimeout_REAL + 142
3   libSDL2-2.0.0.dylib             0x000000011016d120 SDL_SemWaitTimeout_REAL + 80
4   libSDL2-2.0.0.dylib             0x000000011011d183 SDL_TimerThread + 83
5   libSDL2-2.0.0.dylib             0x000000011011cd6c SDL_RunThread + 60
6   libSDL2-2.0.0.dylib             0x000000011016ce59 RunThread + 9
7   libsystem_pthread.dylib         0x00007fff90537899 _pthread_body + 138
8   libsystem_pthread.dylib         0x00007fff9053772a _pthread_start + 137
9   libsystem_pthread.dylib         0x00007fff9053bfc9 thread_start + 13

Thread 19:
0   libsystem_kernel.dylib          0x00007fff8eeb0e6a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff90538f08 _pthread_wqthread + 330
2   libsystem_pthread.dylib         0x00007fff9053bfb9 start_wqthread + 13

Thread 20:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib          0x00007fff8eeb1662 kevent64 + 10
1   libdispatch.dylib               0x00007fff910f2421 _dispatch_mgr_invoke + 239
2   libdispatch.dylib               0x00007fff910f2136 _dispatch_mgr_thread + 52

Thread 21:
0   libsystem_kernel.dylib          0x00007fff8eeb0e6a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff90538f08 _pthread_wqthread + 330
2   libsystem_pthread.dylib         0x00007fff9053bfb9 start_wqthread + 13

Thread 22:
0   libsystem_kernel.dylib          0x00007fff8eeb0e6a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff90538f08 _pthread_wqthread + 330
2   libsystem_pthread.dylib         0x00007fff9053bfb9 start_wqthread + 13

Thread 23:
0   libsystem_kernel.dylib          0x00007fff8eeb0716 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff90539c3b _pthread_cond_wait + 727
2   junk                            0x000000010fa48e16 waitCondition + 6
3   junk                            0x000000010fa1e0a3 0x10effd000 + 10621091
4   ???                             0x00000000434f4e44 0 + 1129270852

Thread 14 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000000  rcx: 0x0000000000002300  rdx: 0x0000000000002200
  rdi: 0x0000000000002300  rsi: 0x0000000000002200  rbp: 0x0000000110f0bd70  rsp: 0x0000000110f0bd70
   r8: 0x0000000000000000   r9: 0x0000000110f0bd00  r10: 0x0000000110196b18  r11: 0x00000001100e4740
  r12: 0x0000000110a04ba8  r13: 0x00007fbb7a818880  r14: 0x00007fbb7a81fce0  r15: 0x00007fbb7a818880
  rip: 0x00007fff8e50e5af  rfl: 0x0000000000010217  cr2: 0x0000000000000000

Logical CPU:     2
Error Code:      0x00000004
Trap Number:     14

Binary Images:
       0x10effd000 -        0x10fa8cff7 +junk (0) <EDE75F5D-0E3E-3628-BC5B-36814DA7A2C1> /Users/USER/*/junk
       0x1100bf000 -        0x110185fff +libSDL2-2.0.0.dylib (0) <85C9E5D4-87EA-3554-9A7B-508BAFE18EEA> /opt/local/lib/libSDL2-2.0.0.dylib
       0x110202000 -        0x110204fff  com.apple.ForceFeedback (1.0.6 - 1.0.6) <2B5A6745-4587-302F-9466-5213B76C050A> /System/Library/Frameworks/ForceFeedback.framework/Versions/A/ForceFeedback
    0x123400000000 -     0x123400435ff7  com.apple.driver.AppleIntelHD5000GraphicsGLDriver (8.28.32 - 8.2.8) <2450F625-33C8-3471-BA0D-10705FDE366C> /System/Library/Extensions/AppleIntelHD5000GraphicsGLDriver.bundle/Contents/MacOS/AppleIntelHD5000GraphicsGLDriver
    0x123440000000 -     0x123440882ff7  com.apple.GeForceGLDriver (8.26.28 - 8.2.6) <7748942D-BB8D-3ECF-BE8E-ED5AB2F2893B> /System/Library/Extensions/GeForceGLDriver.bundle/Contents/MacOS/GeForceGLDriver
    0x7fff60802000 -     0x7fff60835817  dyld (239.4) <7AD43B9B-5CEA-3C7E-9836-A06909F9CA56> /usr/lib/dyld
    0x7fff84254000 -     0x7fff843bafff  libGLProgrammability.dylib (9.6.1) <07700B99-8542-32D7-BB96-29472EFE75EF> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLProgrammability.dylib
    0x7fff843c8000 -     0x7fff847fbffb  com.apple.vision.FaceCore (3.0.0 - 3.0.0) <30FD8146-D6EB-3588-A7E5-ADC3110B3DCC> /System/Library/PrivateFrameworks/FaceCore.framework/Versions/A/FaceCore
    0x7fff847fc000 -     0x7fff84834ff7  com.apple.RemoteViewServices (2.0 - 94) <B17FAA76-61DB-33D0-90B7-4117A72A2B28> /System/Library/PrivateFrameworks/RemoteViewServices.framework/Versions/A/RemoteViewServices
    0x7fff84835000 -     0x7fff848e5ff7  libvMisc.dylib (423.32) <049C0735-1808-39B9-943F-76CB8021744F> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
    0x7fff848e6000 -     0x7fff848e6fff  com.apple.Accelerate (1.9 - Accelerate 1.9) <CFEF9CBE-4A1A-33FD-9174-D44314BB28F3> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
    0x7fff848e7000 -     0x7fff848effff  libsystem_dnssd.dylib (522.92.1) <17B03FFD-92C5-3282-9981-EBB28B456207> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff848f0000 -     0x7fff849e1ff9  libiconv.2.dylib (41) <BB44B115-AC32-3877-A0ED-AEC6232A4563> /usr/lib/libiconv.2.dylib
    0x7fff849e2000 -     0x7fff849e3ffb  libremovefile.dylib (33) <26266E3F-FDDC-3CFC-B27F-78B49BDC9BDC> /usr/lib/system/libremovefile.dylib
    0x7fff84a4c000 -     0x7fff84ab0fff  com.apple.datadetectorscore (5.0 - 354.5) <0AE9749A-6BFC-3032-B802-210DF59AEDB0> /System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore
    0x7fff84ab4000 -     0x7fff84afbff7  libcups.2.dylib (372.4) <36EA4350-43B4-3A5C-9904-10685BFDA7D4> /usr/lib/libcups.2.dylib
    0x7fff84afc000 -     0x7fff84b7dfff  com.apple.CoreSymbolication (3.0.1 - 141.0.5) <20E484C4-9F0E-3DF6-BB27-D509859FF57A> /System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication
    0x7fff84bc8000 -     0x7fff84bccfff  com.apple.CommonPanels (1.2.6 - 96) <5744A1F1-1FA5-35DD-B924-F8983E81FC76> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
    0x7fff84c87000 -     0x7fff84d49ff5  com.apple.CoreText (367.20 - 367.20) <B80D086D-93A9-3C35-860E-9C3FDD027F3B> /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
    0x7fff84d4a000 -     0x7fff84d4cffb  libutil.dylib (34) <DAC4A6CF-A1BB-3874-9569-A919316D30E8> /usr/lib/libutil.dylib
    0x7fff84d4d000 -     0x7fff84d51fff  com.apple.IOAccelerator (98.23 - 98.23) <A5174BEC-A27D-34D8-AB7B-B86962FFAEBA> /System/Library/PrivateFrameworks/IOAccelerator.framework/Versions/A/IOAccelerator
    0x7fff84d52000 -     0x7fff84d97fff  libcurl.4.dylib (78.94.1) <88F27F9B-052E-3375-938D-2603E90D8AD5> /usr/lib/libcurl.4.dylib
    0x7fff851e7000 -     0x7fff851efff7  com.apple.speech.recognition.framework (4.2.4 - 4.2.4) <A816D8B1-6B7B-3E5B-9FAE-CBDA70192E7E> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
    0x7fff856b6000 -     0x7fff856dbff7  com.apple.CoreVideo (1.8 - 117.2) <FE12553A-9B5A-337E-92BD-EA8A8194C91A> /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
    0x7fff8615f000 -     0x7fff86178ff7  com.apple.Ubiquity (1.3 - 289) <664F5B33-708D-33E9-81E1-C45CBE9AAB6E> /System/Library/PrivateFrameworks/Ubiquity.framework/Versions/A/Ubiquity
    0x7fff86179000 -     0x7fff861a0ff7  libsystem_network.dylib (241.3) <A499D688-9165-3776-8C8E-C018897B5B13> /usr/lib/system/libsystem_network.dylib
    0x7fff861a1000 -     0x7fff861c8ffb  libsystem_info.dylib (449.1.3) <395D8CD6-616A-3BD3-A195-C6D68EB9AB22> /usr/lib/system/libsystem_info.dylib
    0x7fff8656b000 -     0x7fff865b9fff  libcorecrypto.dylib (161.1) <F3973C28-14B6-3006-BB2B-00DD7F09ABC7> /usr/lib/system/libcorecrypto.dylib
    0x7fff865c7000 -     0x7fff865c7ffd  com.apple.audio.units.AudioUnit (1.10 - 1.10) <68B21135-55A6-3563-A3D6-3E692A7DEB7F> /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
    0x7fff8696e000 -     0x7fff86bd2ffd  com.apple.security (7.0 - 55471.14.21) <B3C61C91-E9D6-3A3C-99CF-665D54D13C34> /System/Library/Frameworks/Security.framework/Versions/A/Security
    0x7fff86be4000 -     0x7fff86be6fff  com.apple.EFILogin (2.0 - 2) <84014F35-7E0E-3270-819A-48ECCADA687E> /System/Library/PrivateFrameworks/EFILogin.framework/Versions/A/EFILogin
    0x7fff86c0d000 -     0x7fff86c5ffff  libc++.1.dylib (120) <2CB96D10-1E3E-39B1-B90D-C56C3818321E> /usr/lib/libc++.1.dylib
    0x7fff86c60000 -     0x7fff86f34fc7  com.apple.vImage (7.0 - 7.0) <1DDB8AB7-03D5-3D20-9D77-C69074C6FD26> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
    0x7fff86f69000 -     0x7fff86f75ff7  com.apple.OpenDirectory (10.9 - 173.90.1) <F08601E8-F7E8-3222-AD05-6A26003779CF> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
    0x7fff86f90000 -     0x7fff8705bfff  libvDSP.dylib (423.32) <3BF732BE-DDE0-38EB-8C54-E4E3C64F77A7> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
    0x7fff87108000 -     0x7fff87194ff7  com.apple.ink.framework (10.9 - 207) <96A56EAC-B4AC-3C9A-8C40-64E6196753CC> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
    0x7fff87195000 -     0x7fff8719afff  libmacho.dylib (845) <B2BE3C25-CF1F-309B-AB99-1F0B54621445> /usr/lib/system/libmacho.dylib
    0x7fff876a5000 -     0x7fff8775dff7  com.apple.DiscRecording (8.0 - 8000.4.6) <FCBB5558-A702-3658-AEE4-7D129AFBF350> /System/Library/Frameworks/DiscRecording.framework/Versions/A/DiscRecording
    0x7fff8775e000 -     0x7fff87a5eff7  com.apple.Foundation (6.9 - 1056.16) <24349208-3603-3F5D-95CC-B379616FBEF8> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
    0x7fff87a85000 -     0x7fff87aa9ff7  libJPEG.dylib (1044) <BE0ED4E1-F7FC-3038-86D3-0456DD173FCB> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
    0x7fff87aaa000 -     0x7fff881f9fff  libclh.dylib (4.0.3 - 4.0.3) <FCBB60B6-D389-337F-A930-BDC56F6B34FA> /System/Library/Extensions/GeForceGLDriver.bundle/Contents/MacOS/libclh.dylib
    0x7fff88586000 -     0x7fff885b6fff  com.apple.IconServices (25 - 25.17) <36811973-8777-3211-863A-76B2C20B0ED0> /System/Library/PrivateFrameworks/IconServices.framework/Versions/A/IconServices
    0x7fff886b0000 -     0x7fff886baff7  com.apple.CrashReporterSupport (10.9 - 539) <B25A09EC-A021-32EC-86F8-05B4837E0EDE> /System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport
    0x7fff886bb000 -     0x7fff886c1ff7  libsystem_platform.dylib (24.90.1) <3C3D3DA8-32B9-3243-98EC-D89B9A1670B3> /usr/lib/system/libsystem_platform.dylib
    0x7fff886c2000 -     0x7fff889acfff  com.apple.CoreServices.CarbonCore (1077.17 - 1077.17) <3A2E92FD-DEE2-3D45-9619-11500801A61C> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
    0x7fff889ad000 -     0x7fff88c7eff4  com.apple.CoreImage (9.4.0) <2C636ECD-0F1A-357C-9EFF-0452476FDDF5> /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/CoreImage.framework/Versions/A/CoreImage
    0x7fff88c7f000 -     0x7fff88c98ff7  com.apple.Kerberos (3.0 - 1) <59427E11-37D6-34C9-95BB-D4438BFACA5B> /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
    0x7fff88f0e000 -     0x7fff88f9eff7  com.apple.Metadata (10.7.0 - 800.28) <E85AEB1B-CB17-38BC-B5C6-AAB50B47AF05> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
    0x7fff88f9f000 -     0x7fff8913bff3  com.apple.QuartzCore (1.8 - 332.3) <72003E51-1287-395B-BCBC-331597D45C5E> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
    0x7fff8913c000 -     0x7fff892aaff7  libBLAS.dylib (1094.5) <D862E2B7-91FA-3704-8F62-C1B65D381A84> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
    0x7fff892ab000 -     0x7fff892aeffa  libCGXType.A.dylib (599.35.4) <A2B493FD-2EDE-3BC2-A281-2381E0156411> /System/Library/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCGXType.A.dylib
    0x7fff89311000 -     0x7fff89311fff  com.apple.CoreServices (59 - 59) <67A369BA-2326-383F-995B-853DAD7BFF43> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
    0x7fff89312000 -     0x7fff8931cff7  com.apple.bsd.ServiceManagement (2.0 - 2.0) <9556885C-22DD-3392-ACCB-2B413434D8D3> /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
    0x7fff8931d000 -     0x7fff89324ffb  libcopyfile.dylib (103.92.1) <CF29DFF6-0589-3590-834C-82E2316612E8> /usr/lib/system/libcopyfile.dylib
    0x7fff89325000 -     0x7fff89328fff  com.apple.TCC (1.0 - 1) <F25B5875-081A-3877-B70E-374D54B54C5F> /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
    0x7fff893fc000 -     0x7fff89405ffd  com.apple.CommonAuth (4.0 - 2.0) <32BA436F-6319-3A0B-B5D2-2EB75FF36B5B> /System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth
    0x7fff8994c000 -     0x7fff89999ff2  com.apple.print.framework.PrintCore (9.0 - 428) <A2F7B9D2-7907-31D8-8462-E2E2E7C3AF2E> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
    0x7fff899ac000 -     0x7fff89a90ff7  com.apple.coreui (2.2 - 231.1) <187DF89C-8A64-366D-8782-F90315FA3CD7> /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
    0x7fff89ade000 -     0x7fff89af9ff7  libsystem_malloc.dylib (23.10.1) <A695B4E4-38E9-332E-A772-29D31E3F1385> /usr/lib/system/libsystem_malloc.dylib
    0x7fff89afa000 -     0x7fff8a419797  com.apple.CoreGraphics (1.600.0 - 599.35.4) <C8CBC664-0CD2-3C7D-A301-9B3BA731250C> /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
    0x7fff8b2c3000 -     0x7fff8b2e7fff  libxpc.dylib (300.90.2) <AB40CD57-F454-3FD4-B415-63B3C0D5C624> /usr/lib/system/libxpc.dylib
    0x7fff8b2f0000 -     0x7fff8b37bff7  libCoreStorage.dylib (380.70.2) <BD993BC8-ED54-3DC1-B28B-3B6AC77E8E5C> /usr/lib/libCoreStorage.dylib
    0x7fff8b389000 -     0x7fff8b392ff7  libcldcpuengine.dylib (2.3.58) <E3A84FEC-4060-39C2-A469-159A443D2B6D> /System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/libcldcpuengine.dylib
    0x7fff8b393000 -     0x7fff8b398ff7  libunwind.dylib (35.3) <95D4D118-3368-3474-989D-271DE18C8365> /usr/lib/system/libunwind.dylib
    0x7fff8b3e7000 -     0x7fff8b3f2ff7  com.apple.NetAuth (5.0 - 5.0) <C811E662-9EC3-3B74-808A-A75D624F326B> /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
    0x7fff8b3f3000 -     0x7fff8b3faff8  liblaunch.dylib (842.92.1) <A40A0C7B-3216-39B4-8AE0-B5D3BAF1DA8A> /usr/lib/system/liblaunch.dylib
    0x7fff8b4e4000 -     0x7fff8b4e5ff7  libSystem.B.dylib (1197.1.1) <E303F2F8-A8CF-3DF3-84B3-F2D0EE41CCF6> /usr/lib/libSystem.B.dylib
    0x7fff8b534000 -     0x7fff8b61bff7  libxml2.2.dylib (26) <A1DADD11-89E5-3DE4-8802-07186225967F> /usr/lib/libxml2.2.dylib
    0x7fff8b61c000 -     0x7fff8b64bfd2  libsystem_m.dylib (3047.16) <9D96AACD-5870-3A5C-B849-7F9C0F6EBB09> /usr/lib/system/libsystem_m.dylib
    0x7fff8b659000 -     0x7fff8b6bcffb  com.apple.SystemConfiguration (1.13.1 - 1.13.1) <2C8E1A73-5AD6-3A7D-8ED8-D6755555A993> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
    0x7fff8b703000 -     0x7fff8b833ff7  com.apple.desktopservices (1.8.3 - 1.8.3) <225BEC20-F8E0-3F22-9560-890A1A5B9050> /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
    0x7fff8b834000 -     0x7fff8b85cffb  libRIP.A.dylib (599.35.4) <F3C60582-1F27-335D-9C97-8CF307670F7B> /System/Library/Frameworks/CoreGraphics.framework/Versions/A/Resources/libRIP.A.dylib
    0x7fff8b8eb000 -     0x7fff8b903ff7  com.apple.openscripting (1.4 - 157) <B3B037D7-1019-31E6-9D17-08E699AF3701> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
    0x7fff8bb4e000 -     0x7fff8bf2fffe  libLAPACK.dylib (1094.5) <7E7A9B8D-1638-3914-BAE0-663B69865986> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
    0x7fff8c05f000 -     0x7fff8c14efff  libFontParser.dylib (111.1) <835A8253-6AB9-3AAB-9CBF-171440DEC486> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
    0x7fff8c151000 -     0x7fff8c161fff  libbsm.0.dylib (33) <2CAC00A2-1352-302A-88FA-C567D4D69179> /usr/lib/libbsm.0.dylib
    0x7fff8c40b000 -     0x7fff8c478fff  com.apple.SearchKit (1.4.0 - 1.4.0) <33298263-5B12-340D-BB9D-D52303849561> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
    0x7fff8c479000 -     0x7fff8c619ff7  GLEngine (9.6.1) <28300FBD-E3B2-35D2-BB54-77DCE62FC371> /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine
    0x7fff8c61a000 -     0x7fff8c668ff7  com.apple.opencl (2.3.59 - 2.3.59) <9F43F471-C3C3-352D-889D-EC418DC1F5B2> /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
    0x7fff8c669000 -     0x7fff8c733ff7  com.apple.LaunchServices (572.28 - 572.28) <FC72C089-A069-3374-B80A-E041AF149F24> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
    0x7fff8c78c000 -     0x7fff8c79efff  com.apple.ImageCapture (9.0 - 9.0) <D9269440-8E56-3C03-88F5-F8AD662D17DB> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
    0x7fff8c79f000 -     0x7fff8c7acfff  com.apple.Sharing (132.2 - 132.2) <3DFB1133-8FD3-3B60-8E9C-0FE62AACFD7B> /System/Library/PrivateFrameworks/Sharing.framework/Versions/A/Sharing
    0x7fff8cb85000 -     0x7fff8cb86ff7  libDiagnosticMessagesClient.dylib (100) <4CDB0F7B-C0AF-3424-BC39-495696F0DB1E> /usr/lib/libDiagnosticMessagesClient.dylib
    0x7fff8cb87000 -     0x7fff8cbcefff  libFontRegistry.dylib (127) <A77A0480-AA5D-3CC8-8B68-69985CD546DC> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib
    0x7fff8cbcf000 -     0x7fff8cbd0fff  libsystem_sandbox.dylib (278.11.1) <0D0B13EA-6B7A-3AC8-BE60-B548543BEB77> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff8cef5000 -     0x7fff8cef5ffd  libOpenScriptingUtil.dylib (157) <19F0E769-0989-3062-9AFB-8976E90E9759> /usr/lib/libOpenScriptingUtil.dylib
    0x7fff8cf01000 -     0x7fff8cf0affb  libsystem_notify.dylib (121.20.1) <9B34B4FE-F5AD-3F09-A5F0-46AFF3571323> /usr/lib/system/libsystem_notify.dylib
    0x7fff8cf8f000 -     0x7fff8cfa6ff7  com.apple.CFOpenDirectory (10.9 - 173.90.1) <7BC0194E-1B40-3FCA-ACD2-235CE5D65DFA> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
    0x7fff8cff9000 -     0x7fff8d02dfff  libssl.0.9.8.dylib (52) <51C844FF-D7CD-3525-9ABB-84B8DD11D5E4> /usr/lib/libssl.0.9.8.dylib
    0x7fff8d02e000 -     0x7fff8d02eff7  libkeymgr.dylib (28) <D7045F25-BFA4-3840-847D-AF95DF8B6CCA> /usr/lib/system/libkeymgr.dylib
    0x7fff8d12c000 -     0x7fff8d280ff3  com.apple.audio.toolbox.AudioToolbox (1.10 - 1.10) <69B273E8-5A8E-3FC7-B807-C16B657662FE> /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
    0x7fff8d2ed000 -     0x7fff8d315ffb  libxslt.1.dylib (13) <C9794936-633C-3F0C-9E71-30190B9B41C1> /usr/lib/libxslt.1.dylib
    0x7fff8d316000 -     0x7fff8d317ff7  com.apple.print.framework.Print (9.0 - 260) <C4C40E2E-6130-3D73-B1EF-97FF3F70CF2C> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
    0x7fff8d50a000 -     0x7fff8d517ff7  libxar.1.dylib (202) <5572AA71-E98D-3FE1-9402-BB4A84E0E71E> /usr/lib/libxar.1.dylib
    0x7fff8d518000 -     0x7fff8d51afff  libRadiance.dylib (1044) <461482C9-CADB-3B36-B023-597C64AD4B00> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
    0x7fff8d6fd000 -     0x7fff8d715ff7  com.apple.GenerationalStorage (2.0 - 160.3) <64749B08-0212-3AC8-9B49-73D662B09304> /System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage
    0x7fff8d79f000 -     0x7fff8d7a7ff3  libCGCMS.A.dylib (599.35.4) <67AD122A-B8DA-3C05-8B8C-1939F5064FAE> /System/Library/Frameworks/CoreGraphics.framework/Versions/A/Resources/libCGCMS.A.dylib
    0x7fff8d7a8000 -     0x7fff8d817ff1  com.apple.ApplicationServices.ATS (360 - 363.3) <546E89D9-2AE7-3111-B2B8-2366650D22F0> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
    0x7fff8d818000 -     0x7fff8d81ffff  libcompiler_rt.dylib (35) <2A890004-0A78-3E33-9AC5-A7D63BD4F879> /usr/lib/system/libcompiler_rt.dylib
    0x7fff8d820000 -     0x7fff8d828ffc  libGFXShared.dylib (9.6.1) <25BBF325-AC57-3BAA-9427-2D14CC243AE6> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
    0x7fff8d829000 -     0x7fff8d852fff  com.apple.DictionaryServices (1.2 - 208) <A4E4EA9E-08A1-3F77-8B57-A5A1ADD70B52> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
    0x7fff8d853000 -     0x7fff8d898ff6  com.apple.HIServices (1.23 - 468) <5970AF5C-F5BD-3B6A-97C9-95B2CA98D71D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
    0x7fff8dc63000 -     0x7fff8dc68fff  com.apple.DiskArbitration (2.6 - 2.6) <A4165553-770E-3D27-B217-01FC1F852B87> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
    0x7fff8dc69000 -     0x7fff8dc9afff  com.apple.MediaKit (15 - 709) <4AC5B9D8-7204-3CF2-AB58-69EFCDD964FC> /System/Library/PrivateFrameworks/MediaKit.framework/Versions/A/MediaKit
    0x7fff8dc9b000 -     0x7fff8dc9efff  com.apple.help (1.3.3 - 46) <6D71C959-D421-372B-A160-5317B4921F4D> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
    0x7fff8dcd2000 -     0x7fff8dcd3fff  liblangid.dylib (117) <9546E641-F730-3AB0-B3CD-E0E2FDD173D9> /usr/lib/liblangid.dylib
    0x7fff8e0b0000 -     0x7fff8e0b9fff  com.apple.speech.synthesis.framework (4.7.1 - 4.7.1) <383FB557-E88E-3239-82B8-15F9F885B702> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
    0x7fff8e0ba000 -     0x7fff8e0bafff  com.apple.Accelerate.vecLib (3.9 - vecLib 3.9) <F8D0CC77-98AC-3B58-9FE6-0C25421827B6> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
    0x7fff8e0bb000 -     0x7fff8e0e0ff7  com.apple.ChunkingLibrary (2.0 - 155.1) <B49408CD-ECE8-3785-84A4-45B03882574A> /System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary
    0x7fff8e12b000 -     0x7fff8e16dff7  libauto.dylib (185.5) <F45C36E8-B606-3886-B5B1-B6745E757CA8> /usr/lib/libauto.dylib
    0x7fff8e16e000 -     0x7fff8e258fff  libsqlite3.dylib (158) <447AA928-BCF7-3779-A7E5-210F264E0316> /usr/lib/libsqlite3.dylib
    0x7fff8e259000 -     0x7fff8e294fff  com.apple.bom (14.0 - 193.1) <EF24A562-6D3C-379E-8B9B-FAE0E4A0EF7C> /System/Library/PrivateFrameworks/Bom.framework/Versions/A/Bom
    0x7fff8e295000 -     0x7fff8e2beff7  libc++abi.dylib (49.1) <21A807D3-6732-3455-B77F-743E9F916DF0> /usr/lib/libc++abi.dylib
    0x7fff8e2bf000 -     0x7fff8e2c1ff7  libquarantine.dylib (71) <973BE51D-6465-392F-9099-D4AB21BF0D25> /usr/lib/system/libquarantine.dylib
    0x7fff8e2c2000 -     0x7fff8e50aff7  com.apple.CoreData (107 - 481.3) <E78734AA-E3D0-33CB-A014-620BBCAB2E96> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
    0x7fff8e50b000 -     0x7fff8e516fff  libGL.dylib (9.6.1) <4B65BF9F-F34A-3CD1-94E8-DB26DAA0A59D> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
    0x7fff8e878000 -     0x7fff8e949ff1  com.apple.DiskImagesFramework (10.9 - 371.1) <DCCAADEC-35D5-3968-8B39-358ACC56ADC4> /System/Library/PrivateFrameworks/DiskImages.framework/Versions/A/DiskImages
    0x7fff8e94a000 -     0x7fff8e957ff0  libbz2.1.0.dylib (29) <0B98AC35-B138-349C-8063-2B987A75D24C> /usr/lib/libbz2.1.0.dylib
    0x7fff8e95a000 -     0x7fff8e95bff7  libsystem_blocks.dylib (63) <FB856CD1-2AEA-3907-8E9B-1E54B6827F82> /usr/lib/system/libsystem_blocks.dylib
    0x7fff8e95c000 -     0x7fff8e9b5fff  libTIFF.dylib (1044) <FBC5800B-7F34-3755-A44E-7B37B3E0B32E> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
    0x7fff8ec48000 -     0x7fff8ecbbfff  com.apple.securityfoundation (6.0 - 55122.3) <0FDC8F53-104C-3938-A852-5B33C30BAAD5> /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
    0x7fff8ed01000 -     0x7fff8ed05ff7  libGIF.dylib (1044) <7E51DFC3-740A-3CD3-98A1-1EC510A4A055> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
    0x7fff8ed91000 -     0x7fff8eda2ff7  libsystem_asl.dylib (217.1.4) <B983CA60-F418-317B-B142-48A6376564FC> /usr/lib/system/libsystem_asl.dylib
    0x7fff8edc8000 -     0x7fff8edc8fff  com.apple.Cocoa (6.8 - 20) <1482E95B-0C26-38AF-9A44-50ADE6C0876C> /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
    0x7fff8edd0000 -     0x7fff8ee47fff  com.apple.CoreServices.OSServices (600.4 - 600.4) <C63562F5-6DF5-3EE9-8897-FF61A44C8251> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
    0x7fff8ee97000 -     0x7fff8ee9affc  com.apple.IOSurface (91.1 - 91.1) <D00EEB0C-8AA8-3986-90C1-C97B2486E8FA> /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
    0x7fff8ee9b000 -     0x7fff8eeb7ff7  libsystem_kernel.dylib (2422.115.4) <9EDE872E-2A9E-3A78-8E1D-AB790794A098> /usr/lib/system/libsystem_kernel.dylib
    0x7fff8eeb8000 -     0x7fff8fa2eff7  com.apple.AppKit (6.9 - 1265.21) <9DC13B27-841D-3839-93B2-3EDE66157BDE> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
    0x7fff8fb02000 -     0x7fff8fb06fff  libpam.2.dylib (20) <A63D4DA2-06A4-3FB8-AC3F-BDD69694EE5E> /usr/lib/libpam.2.dylib
    0x7fff8fb66000 -     0x7fff8fbeffff  com.apple.ColorSync (4.9.0 - 4.9.0) <E7E0D542-D77A-3E32-B146-4D0FEAF282D3> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
    0x7fff8fbf0000 -     0x7fff8fc4bffb  com.apple.AE (665.5 - 665.5) <3558CC9A-FD30-3DAD-AB40-FE6828E76FE1> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
    0x7fff8fccf000 -     0x7fff8fcebfff  libresolv.9.dylib (54) <11C2C826-F1C6-39C6-B4E8-6E0C41D4FA95> /usr/lib/libresolv.9.dylib
    0x7fff8fd9a000 -     0x7fff8fd9bfff  libunc.dylib (28) <C3737C9A-C06F-310C-B78C-7D8D882A35DE> /usr/lib/system/libunc.dylib
    0x7fff8fd9c000 -     0x7fff8fe60ff7  com.apple.backup.framework (1.5.4 - 1.5.4) <195DA868-47A5-37E6-8CF0-9BCF11846899> /System/Library/PrivateFrameworks/Backup.framework/Versions/A/Backup
    0x7fff8fe88000 -     0x7fff90132ff5  com.apple.HIToolbox (2.1.1 - 698) <A388E773-AE7B-3FD1-8662-A98E6E24EA16> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
    0x7fff90133000 -     0x7fff90136fff  libCoreVMClient.dylib (58.1) <EBC36C69-C896-3C3D-8589-3E9023E7E56F> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
    0x7fff90137000 -     0x7fff90152ff7  libCRFSuite.dylib (34) <FFAE75FA-C54E-398B-AA97-18164CD9789D> /usr/lib/libCRFSuite.dylib
    0x7fff9021c000 -     0x7fff9021eff7  com.apple.securityhi (9.0 - 55005) <18C42525-688C-3D47-B9C9-1E0F8F58FA64> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
    0x7fff9021f000 -     0x7fff90223ff7  libcache.dylib (62) <8C1EFC4F-3F51-3DE9-A973-360B461F3D65> /usr/lib/system/libcache.dylib
    0x7fff90285000 -     0x7fff902baffc  com.apple.LDAPFramework (2.4.28 - 194.5) <4ADD0595-25B9-3F09-897E-3FB790AD2C5A> /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP
    0x7fff902bf000 -     0x7fff90317ff7  com.apple.Symbolication (1.4 - 129.0.2) <B1F008C4-184D-36A2-922F-4A67A075D512> /System/Library/PrivateFrameworks/Symbolication.framework/Versions/A/Symbolication
    0x7fff90318000 -     0x7fff90384fff  com.apple.framework.IOKit (2.0.1 - 907.100.13) <057FDBA3-56D6-3903-8C0B-849214BF1985> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
    0x7fff9038b000 -     0x7fff9038eff7  libdyld.dylib (239.4) <7C9EC3B7-DDE3-33FF-953F-4067C743951D> /usr/lib/system/libdyld.dylib
    0x7fff9038f000 -     0x7fff9039bffb  com.apple.AppleFSCompression (56.92.1 - 1.0) <066255FD-DBD1-3041-8DDA-7AFC41C9096D> /System/Library/PrivateFrameworks/AppleFSCompression.framework/Versions/A/AppleFSCompression
    0x7fff9039c000 -     0x7fff90401ffb  com.apple.Heimdal (4.0 - 2.0) <F34D6627-9F80-3823-8B57-DB629307DF87> /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
    0x7fff90402000 -     0x7fff90408fff  com.apple.AOSNotification (1.7.0 - 760.3) <307D35A7-C2CB-3024-BFE1-288A0198C003> /System/Library/PrivateFrameworks/AOSNotification.framework/Versions/A/AOSNotification
    0x7fff90409000 -     0x7fff90432fff  GLRendererFloat (9.6.1) <23A2C705-F932-335D-B27B-565A30333460> /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLRendererFloat.bundle/GLRendererFloat
    0x7fff90433000 -     0x7fff9043dfff  libcommonCrypto.dylib (60049) <79B8E80F-E596-3302-8243-EC479B9546CA> /usr/lib/system/libcommonCrypto.dylib
    0x7fff9043e000 -     0x7fff9047ffff  com.apple.PerformanceAnalysis (1.47 - 47) <7B73DFF4-75DB-3403-80D2-0F3FE48764C3> /System/Library/PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/PerformanceAnalysis
    0x7fff904ab000 -     0x7fff904b9fff  com.apple.opengl (9.6.1 - 9.6.1) <B22FA400-5824-36AF-9945-5FEC31995A0E> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
    0x7fff904ba000 -     0x7fff904e9ff9  com.apple.GSS (4.0 - 2.0) <44E914BE-B0D0-3E05-9451-CA9E539AFA52> /System/Library/Frameworks/GSS.framework/Versions/A/GSS
    0x7fff90534000 -     0x7fff90535fff  com.apple.TrustEvaluationAgent (2.0 - 25) <334A82F4-4AE4-3719-A511-86D0B0723E2B> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
    0x7fff90536000 -     0x7fff9053dff7  libsystem_pthread.dylib (53.1.4) <9DA50FD0-D9AC-3051-AD4B-BA0D745BC49C> /usr/lib/system/libsystem_pthread.dylib
    0x7fff90549000 -     0x7fff90549fff  com.apple.ApplicationServices (48 - 48) <F250170A-8805-3731-9097-78CAD04481F0> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
    0x7fff9054a000 -     0x7fff90555fff  libkxld.dylib (2422.115.4) <3C678B75-F7C5-3DBB-8DBD-48483AD54D5C> /usr/lib/system/libkxld.dylib
    0x7fff90556000 -     0x7fff90565ff8  com.apple.LangAnalysis (1.7.0 - 1.7.0) <2777524A-E7EF-3B7B-B15D-F58CDEEFC736> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
    0x7fff905b6000 -     0x7fff905c1fff  libGPUSupportMercury.dylib (9.6.1) <A34D5C51-28E0-398A-881D-552B47D2DD3C> /System/Library/PrivateFrameworks/GPUSupport.framework/Versions/A/Libraries/libGPUSupportMercury.dylib
    0x7fff905e4000 -     0x7fff905eeff7  libcsfde.dylib (380.70.2) <3ACB87D7-A81C-3C45-B648-AD27F1B9D841> /usr/lib/libcsfde.dylib
    0x7fff905ef000 -     0x7fff90678ff7  libsystem_c.dylib (997.90.3) <6FD3A400-4BB2-3B95-B90C-BE6E9D0D78FA> /usr/lib/system/libsystem_c.dylib
    0x7fff906cb000 -     0x7fff907b9fff  libJP2.dylib (1044) <BE5FF765-5ECE-38B5-BF5D-BE806F5CAD18> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
    0x7fff9092e000 -     0x7fff9096cff7  libGLImage.dylib (9.6.1) <5E02B38C-9F36-39BE-8746-724F0D8BBFC0> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
    0x7fff90cf4000 -     0x7fff90d06ff7  com.apple.MultitouchSupport.framework (245.13.1 - 245.13.1) <38262B92-C63F-35A0-997D-AD2EBF2F8338> /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
    0x7fff90d07000 -     0x7fff90d40ff7  com.apple.QD (3.50 - 298) <5343278D-47B7-3AF2-9B4B-4B8B0F942CD1> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
    0x7fff90d41000 -     0x7fff90ef9ffb  libicucore.A.dylib (511.35) <6F097DA7-147C-32A1-93D2-728A64CF0DC2> /usr/lib/libicucore.A.dylib
    0x7fff91029000 -     0x7fff9103aff7  libz.1.dylib (53) <4C5FA1A5-4471-398E-9543-2E54D46E63E9> /usr/lib/libz.1.dylib
    0x7fff91061000 -     0x7fff9108dfff  com.apple.CoreServicesInternal (184.9 - 184.9) <4DEA54F9-81D6-3EDB-AA3C-1F9C497B3379> /System/Library/PrivateFrameworks/CoreServicesInternal.framework/Versions/A/CoreServicesInternal
    0x7fff9108e000 -     0x7fff91095fff  com.apple.NetFS (6.0 - 4.0) <D4FE0F16-3085-34AF-B860-3D46B98FAD2A> /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
    0x7fff91096000 -     0x7fff91098ff3  libsystem_configuration.dylib (596.15) <4998CB6A-9D54-390A-9F57-5D1AC53C135C> /usr/lib/system/libsystem_configuration.dylib
    0x7fff91099000 -     0x7fff910ecfff  com.apple.ScalableUserInterface (1.0 - 1) <19D73C6D-CA0A-3230-9644-7F01364137ED> /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/ScalableUserInterface.framework/Versions/A/ScalableUserInterface
    0x7fff910ef000 -     0x7fff91109fff  libdispatch.dylib (339.92.1) <C4E4A18D-3C3B-3C9C-8709-A4270D998DE7> /usr/lib/system/libdispatch.dylib
    0x7fff91165000 -     0x7fff91175ffb  libsasl2.2.dylib (170) <C8E25710-68B6-368A-BF3E-48EC7273177B> /usr/lib/libsasl2.2.dylib
    0x7fff9122a000 -     0x7fff9122afff  com.apple.Carbon (154 - 157) <14069023-0BBB-3925-9BA9-EB2C9E9B8C75> /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
    0x7fff91256000 -     0x7fff913f1ff8  com.apple.CFNetwork (673.5 - 673.5) <EF4DA617-D442-327A-9575-A75111A0A742> /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
    0x7fff91418000 -     0x7fff9151eff7  com.apple.ImageIO.framework (3.3.0 - 1044) <3BCCF2AE-CF1F-3324-A371-DF0A42C841A2> /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
    0x7fff9151f000 -     0x7fff91523ff7  libsystem_stats.dylib (93.90.3) <4E51D5B0-92A0-3D0D-B90E-495A1ED3E391> /usr/lib/system/libsystem_stats.dylib
    0x7fff91524000 -     0x7fff91553fff  com.apple.DebugSymbols (106 - 106) <9F66640E-277C-317E-A01E-A1E5B13E2592> /System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols
    0x7fff9157c000 -     0x7fff91597ff7  libPng.dylib (1044) <151BA92C-6E7C-3B69-8024-FDD1E2C89DD3> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
    0x7fff9161b000 -     0x7fff91800fff  com.apple.CoreFoundation (6.9 - 855.17) <729BD6DA-1F63-3E72-A148-26F21EBF52BB> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7fff91839000 -     0x7fff91878fff  libGLU.dylib (9.6.1) <AE032555-3E2F-3DBF-A26D-EA4576061605> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
    0x7fff91879000 -     0x7fff918caff7  com.apple.audio.CoreAudio (4.2.1 - 4.2.1) <BE13E840-FB45-3BC2-BCF5-031629754FD5> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
    0x7fff918cb000 -     0x7fff918d8ff4  com.apple.Librarian (1.2 - 1) <2F677B44-BCA3-313B-881E-EE322E865100> /System/Library/PrivateFrameworks/Librarian.framework/Versions/A/Librarian
    0x7fff918ec000 -     0x7fff91a99f27  libobjc.A.dylib (551.1) <F21C5742-7B9C-31F1-BBAE-1717BC6C2F1B> /usr/lib/libobjc.A.dylib
    0x7fff91cd2000 -     0x7fff91cd4fff  libCVMSPluginSupport.dylib (9.6.1) <FB37F4C4-1E84-3349-BB03-92CA0A5F6837> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCVMSPluginSupport.dylib
    0x7fff91e05000 -     0x7fff91ee1fff  libcrypto.0.9.8.dylib (52) <ED7F3865-10D4-346B-8C9C-D968EB3B5D35> /usr/lib/libcrypto.0.9.8.dylib
    0x7fff91f36000 -     0x7fff91f3aff7  libheimdal-asn1.dylib (323.92.1) <CAE21FFF-5763-399C-B7C5-EEBFFEEF2242> /usr/lib/libheimdal-asn1.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 1
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 878404
    thread_create: 0
    thread_set_state: 727

VM Region Summary:
ReadOnly portion of Libraries: Total=200.3M resident=149.5M(75%) swapped_out_or_unallocated=50.8M(25%)
Writable regions: Total=160.8M written=3096K(2%) resident=12.8M(8%) swapped_out=0K(0%) unallocated=148.0M(92%)

REGION TYPE                      VIRTUAL
===========                      =======
CG backing stores                  7776K
CG image                              4K
CG raster data                       48K
CG shared images                    172K
Dispatch continuations             16.0M
IOKit                              12.1M
IOKit (reserved)                      4K        reserved VM address space (unallocated)
Kernel Alloc Once                     8K
MALLOC                             91.6M
MALLOC (admin)                       32K
OpenGL GLSL                        1664K
STACK GUARD                        56.1M
Stack                              19.2M
VM_ALLOCATE                        21.3M
__DATA                             40.0M
__IMAGE                             528K
__LINKEDIT                         73.8M
__TEXT                            126.5M
__UNICODE                           544K
mapped file                        58.7M
shared memory                         4K
===========                      =======
TOTAL                             526.0M
TOTAL, minus reserved VM space    526.0M

Model: MacBookPro11,3, BootROM MBP112.0138.B07, 4 processors, Intel Core i7, 2.5 GHz, 16 GB, SMC 2.19f7
Graphics: Intel Iris Pro, Intel Iris Pro, Built-In
Graphics: NVIDIA GeForce GT 750M, NVIDIA GeForce GT 750M, PCIe, 2048 MB
Memory Module: BANK 0/DIMM0, 8 GB, DDR3, 1600 MHz, 0x02FE, -
Memory Module: BANK 1/DIMM0, 8 GB, DDR3, 1600 MHz, 0x02FE, -
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x134), Broadcom BCM43xx 1.0 (6.30.223.154.65)
Bluetooth: Version 4.2.7f3 14616, 3 services, 23 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
Serial ATA Device: APPLE SSD SM0512F, 500.28 GB
USB Device: Internal Memory Card Reader
USB Device: Apple Internal Keyboard / Trackpad
USB Device: BRCM20702 Hub
USB Device: Bluetooth USB Host Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 17.1

Here's the relevant bit

Thread 14 Crashed:
0   libGL.dylib                     0x00007fff8e50e5af glTexEnvf + 17
1   libSDL2-2.0.0.dylib             0x00000001101058fa GL_SetDrawingState + 218
2   libSDL2-2.0.0.dylib             0x0000000110104116 GL_RenderFillRects + 38
3   libSDL2-2.0.0.dylib             0x00000001100fd60b SDL_RenderFillRects_REAL + 235
4   libSDL2-2.0.0.dylib             0x00000001100fd518 SDL_RenderFillRect_REAL + 136
5   junk                            0x000000010f09ce17 0x10effd000 + 654871

And a similar backtrace from lldb:

* thread #15: tid = 0x26582, 0x00007fff8e50e5af libGL.dylib`glTexEnvf + 17, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00007fff8e50e5af libGL.dylib`glTexEnvf + 17
    frame #1: 0x00000001011088fa libSDL2-2.0.0.dylib`GL_SetDrawingState + 218
    frame #2: 0x0000000101107116 libSDL2-2.0.0.dylib`GL_RenderFillRects + 38
    frame #3: 0x000000010110060b libSDL2-2.0.0.dylib`SDL_RenderFillRects_REAL + 235
    frame #4: 0x0000000101100518 libSDL2-2.0.0.dylib`SDL_RenderFillRect_REAL + 136
ocharles commented 9 years ago

Hmmm, sounds like it could be an SDL bug. Could you try creating a non-accelerated renderer? That would be done by changing out defaultRenderer to something else. You might also want to try specifying windowOpenGL to the defaultWindow config.

mitchellwrosen commented 9 years ago

Same segfault with UnacceleratedRenderer, and also with windowOpenGL = Core Normal 2 1 (I do have OpenGL 2.1). Shrug!

Rydgel commented 9 years ago

I confirm being able to reproduce this as well on my OS X computer. GHC 7.10.2 / SDL2 (SDL2-2.0.3) I tried your code with stable 2.0.0. It's not only happening with renderFillRect, but also drawLine. I didn't try others, but my guess is that similar functions behave the same way. For instance:

Thread 15 Crashed:
0   libGL.dylib                     0x00007fff8b153125 glBegin + 15
1   libSDL2-2.0.0.dylib             0x000000010cefe6f7 GL_RenderDrawLines + 163
2   libSDL2-2.0.0.dylib             0x000000010cef7c76 SDL_RenderDrawLines_REAL + 244
3   libSDL2-2.0.0.dylib             0x000000010cef7b6d SDL_RenderDrawLine_REAL + 50
4   testApp                         0x000000010be69115 0x10bdfa000 + 454933
ocharles commented 9 years ago

I'll see if I can write a similar C program for you guys. With the crash happening at glBegin it makes me think there is something wrong in how we're initializing things... somewhere (or a bug in SDL)

Rydgel commented 9 years ago

I made a similar code to try with sdl2-1.3.1. And so far it looks similar.

Thread 11 Crashed:
0   libGL.dylib                     0x00007fff8b153a25 glEnable + 15
1   libSDL2-2.0.0.dylib             0x00000001057728c4 GL_UpdateTexture + 60
2   libSDL2-2.0.0.dylib             0x000000010576b8a7 SDL_UpdateTexture_REAL + 596
3   libSDL2-2.0.0.dylib             0x00000001057b75e8 SDL_UpdateWindowTexture + 138
4   libSDL2-2.0.0.dylib             0x00000001057b9eca SDL_UpdateWindowSurface_REAL + 104
5   new-template-exe                0x00000001054ac551 0x1053f5000 + 750929
ocharles commented 9 years ago

Can you share that code? That will probably help me reproduce the problem as a C example, and then I can open an issue on the SDL bug tracker.

Rydgel commented 9 years ago

It's kind of ugly, I needed to use void to make GHC compile. Also note that I put SDL.updateWindowSurface inside the thread too. It does not crash when outside, but the display is glitched. In this case the segmentation fault only occurs when both fillRect and updateWindowSurface are inside the same thread.

{-# LANGUAGE OverloadedStrings #-}

module Main where

import Control.Concurrent
import Control.Monad
import Linear.Affine
import Linear.V2
import Linear.V4
import Data.Bits
import Foreign.C.String
import Foreign.C.Types
import GHC.Word
import Foreign.Ptr
import Foreign.Storable
import qualified Graphics.UI.SDL as SDL

applyToPointer :: (Storable a) => (a -> b) -> Ptr a -> IO b
applyToPointer operation pointer = liftM operation $ peek pointer

main :: IO ()
main = do
    SDL.init SDL.SDL_INIT_VIDEO
    window <- SDL.createWindow nullPtr SDL.SDL_WINDOWPOS_UNDEFINED SDL.SDL_WINDOWPOS_UNDEFINED 640 480 SDL.SDL_WINDOW_SHOWN
    screenSurface <- SDL.getWindowSurface window
    pixelFormat <- SDL.surfaceFormat `applyToPointer` screenSurface
    color <- SDL.mapRGB pixelFormat 0xFF 0x00 0x00
    forkIO $ void $ SDL.fillRect screenSurface nullPtr color >> SDL.updateWindowSurface window
    SDL.delay 5000
    SDL.freeSurface screenSurface
ocharles commented 9 years ago

Ok, I don't think we're going to be able to do anything about this.

https://bugzilla.libsdl.org/show_bug.cgi?id=1995

And

This API is not designed to be used from multiple threads, see this bug for details.

From https://wiki.libsdl.org/CategoryRender

Rydgel commented 9 years ago

This is what I feared actually. So basically we should keep our rendering on the same thread.

ocharles commented 9 years ago

The same thread you initialize on I believe, though it may be the same thread you create the window on.

akhra commented 9 years ago

Oof. This almost makes me feel like #8 might be worth revisiting, to guarantee the renderer is fed from a single thread without having to ban async.

@phaazon's IORef asset trick also feels relevant here, though I haven't thought it through.

afwlehmann commented 9 years ago

The SDL Wiki appears to be supporting @tejon's suggestion:

The main advice is not to call SDL video or event functions from separate threads. This doesn't mean you can't call them from a thread, it means you shouldn't have two threads both calling video functions or handling events. The reason is that the SDL functions aren't designed for threads, so they don't know how to handle what happens if two video functions occured at the same time.

hadronized commented 9 years ago

Well, my “trick” doesn’t add any kind of thread safety. You can still create the renderer in a specific thread, and pass it to another thread and end up in a dramatic situation.

Maybe you can use universal quantification to disable passing the renderer around and keep it scoped in the calling thread?

ocharles commented 9 years ago

All of the tricks of regions and stuff like that add a ton of complexity. I'd rather just document it.

hadronized commented 9 years ago

Which regions are you talking about? :)

ocharles commented 9 years ago

http://okmij.org/ftp/Haskell/regions.html

hadronized commented 9 years ago

Thanks ;)

akhra commented 9 years ago

@phaazon I wasn't too clear; my thought was actually to build a wrapper around the renderer and its thread to manage inter-thread communication, and pass that around as an IORef. Like I said though, I really haven't thought it through. :)

ocharles commented 8 years ago

Closing as this is just part of how SDL works, unfortunately.