dynamic-graph
dynamic-graph copied to clipboard
Segmentation Fault on Mac OS X
I'm trying to run the demo application on Mac OS X 10.10.2, and I get a segmentation fault. The display window opens with just a black background, and then crashes.
Here's a gist of the trace that OS X throws up after it crashes.
I tried to tweak the window width and height, the number of samples, and the x resolution, but that didn't seem to do anything.
This is the output of running the demo in GHCi.
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( random.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package zlib-0.5.4.1 ... linking ... done.
Loading package primitive-0.5.2.1 ... linking ... done.
Loading package vector-0.10.9.1 ... linking ... done.
Loading package text-1.1.0.0 ... linking ... done.
Loading package hashable-1.2.2.0 ... linking ... done.
Loading package unordered-containers-0.2.4.0 ... linking ... done.
Loading package stm-2.4.2 ... linking ... done.
Loading package old-locale-1.0.0.6 ... linking ... done.
Loading package time-1.4.2 ... linking ... done.
Loading package random-1.0.1.1 ... linking ... done.
Loading package OpenGLRaw-1.5.0.0 ... linking ... done.
Loading package GLURaw-1.4.0.1 ... linking ... done.
Loading package OpenGL-2.9.2.0 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package binary-0.7.1.0 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package filepath-1.3.0.2 ... linking ... done.
Loading package unix-2.7.0.1 ... linking ... done.
Loading package directory-1.2.1.0 ... linking ... done.
Loading package bindings-DSL-1.0.22 ... linking ... done.
Loading package bindings-GLFW-3.0.3.3 ... linking ... done.
Loading package GLFW-b-1.4.6 ... linking ... done.
Loading package transformers-0.4.2.0 ... linking ... done.
Loading package mtl-2.2.1 ... linking ... done.
Loading package JuicyPixels-3.2.2 ... linking ... done.
Loading package old-time-1.1.0.2 ... linking ... done.
Loading package polyparse-1.11 ... linking ... done.
Loading package cpphs-1.18.6 ... linking ... done.
Loading package nats-1 ... linking ... done.
Loading package semigroups-0.16.0.1 ... linking ... done.
Loading package transformers-compat-0.3.3.4 ... linking ... done.
Loading package void-0.7 ... linking ... done.
Loading package contravariant-1.2.0.1 ... linking ... done.
Loading package tagged-0.7.3 ... linking ... done.
Loading package distributive-0.4.4 ... linking ... done.
Loading package comonad-4.2.2 ... linking ... done.
Loading package semigroupoids-4.2 ... linking ... done.
Loading package bifunctors-4.2 ... linking ... done.
Loading package prelude-extras-0.4 ... linking ... done.
Loading package profunctors-4.3.2 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package free-4.10.0.1 ... linking ... done.
Loading package adjunctions-4.2 ... linking ... done.
Loading package exceptions-0.6.1 ... linking ... done.
Loading package parallel-3.2.0.4 ... linking ... done.
Loading package reflection-1.5.1 ... linking ... done.
Loading package split-0.2.2 ... linking ... done.
Loading package lens-4.6.0.1 ... linking ... done.
Loading package linear-1.16 ... linking ... done.
Loading package GLUtil-0.8.2 ... linking ... done.
Loading package utf8-string-0.3.8 ... linking ... done.
Loading package cairo-0.13.0.6 ... linking ... done.
Loading package colour-2.3.3 ... linking ... done.
Loading package MonadRandom-0.3.0.1 ... linking ... done.
Loading package transformers-base-0.4.3 ... linking ... done.
Loading package monad-control-1.0.0.1 ... linking ... done.
Loading package either-4.3.2.1 ... linking ... done.
Loading package glib-0.13.0.7 ... linking ... done.
Loading package process-1.2.0.0 ... linking ... done.
Loading package pango-0.13.0.5 ... linking ... done.
Loading package mmorph-1.0.4 ... linking ... done.
Loading package pipes-4.1.4 ... linking ... done.
Loading package dynamic-graph-0.1.0.4 ... linking ... done.
Segmentation fault: 11
Thanks very much for your help.
Hi
It hasn't been tested on anything other than Linux. I should be able to get hold of a Mac soon and debug this.
Oh right. No worries—I can run it on Linux easily enough instead.
On 17 Jan 2015, at 4:47 pm, Adam Walker [email protected] wrote:
Hi
It hasn't been tested on anything other than Linux. I should be able to get hold of a Mac soon and debug this.
— Reply to this email directly or view it on GitHub.
Let me know if it works.
is this still an issue? i'm interested as well
I assume so. I haven't fixed it and don't have access to a mac, unfortunately.
Might be related to the comment under the createWindow function here:
https://hackage.haskell.org/package/GLFW-b-1.4.7.3/docs/Graphics-UI-GLFW.html
Might be fixed by: b9780bb8fe2a661ae653b128ecb2e065e58ea434
how to use the codes on qt,please?
I also get crashes on OS X. Out of the box I get,
2018-07-19 13:56:42.939 waterfall[38263:21299099] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
2018-07-19 13:56:42.939 waterfall[38263:21299099] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349.91/Misc.subproj/NSUndoManager.m:363
2018-07-19 13:56:42.941 waterfall[38263:21299099] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349.91/Misc.subproj/NSUndoManager.m:363
2018-07-19 13:56:42.941 waterfall[38263:21299099] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fffd16972cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffe64ae48d objc_exception_throw + 48
2 CoreFoundation 0x00007fffd169c042 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fffd30e4be0 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 Foundation 0x00007fffd306f093 +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 170
5 AppKit 0x00007fffcf0f94ed -[NSApplication run] + 1200
6 libglfw.3.2.dylib 0x000000010507b88e initializeAppKit + 1534
7 libglfw.3.2.dylib 0x000000010507ada0 _glfwPlatformCreateWindow + 48
8 libglfw.3.2.dylib 0x0000000105075945 glfwCreateWindow + 501
9 waterfall 0x0000000104ec820a GLFWzmbzm3zi2zi1zi0zm2RXpO5VvXer1OcGugK5djJ_GraphicsziUIziGLFW_setErrorCallback1_info + 930
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
I tried moving the createWindow
call outside the forkIO
, but since the call to pollEvents
is still in the forkIO
it crashes:
2018-07-19 14:02:44.715 waterfall[52709:21321823] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
Segmentation fault: 11
According to this page,
https://hackage.haskell.org/package/GLFW
GLFW doesn't work well with GHC threads, forkIO or threadDelay. So avoid them if you can.
Avoiding forkIO
seems like a pretty fundamental design change -- but also perhaps an unavoidable one?
Just for fun I removed the forkIO
call entirely and the window opened. But then the app crashed due to an MVar blocked indefinitely. So that seems to indicate forkIO is a problem.
I hacked all the forkIO
out of window
and now things work. Some of the stuff I removed was probably important. But with this window
function I can actually display waterfalls,
window :: IsPixelData a
=> Int -- ^ Window width
-> Int -- ^ Window height
-> IO (Consumer a IO ()) -- ^ The Consumer that draws on the window. Obtain this from one of the other modules in this package. Must be given in an IO monad so that it can be initialised with the OpenGL context created within this function.
-> ExceptT String IO (Consumer a IO ())
window width height renderPipe = do
closed <- lift $ newIORef False
res' <- lift $ createWindow width height "" Nothing Nothing
do
res <- {- runExceptT $ -} do
win <- maybe (throwE "error creating window") return res'
lift $ setWindowSizeCallback win $ Just $ \win x y ->
viewport $= (Position 0 0, Size (fromIntegral x) (fromIntegral y))
lift $ setWindowCloseCallback win $ Just $ \win -> writeIORef closed True
lift $ makeContextCurrent (Just win)
lift $ clearColor $= Color4 0 0 0 0
renderPipe <- lift renderPipe
let thePipe = forever $ do
lift pollEvents
dat <- await -- lift $ takeMVar mv
lift $ makeContextCurrent (Just win)
lift pollEvents
lift $ clear [ColorBuffer]
yield dat
lift $ swapBuffers win
return $ {- runEffect $ -} thePipe >-> renderPipe
pure res