Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in win x64 #62

Closed
sukhmel opened this issue Jun 12, 2014 · 7 comments
Closed

Crash in win x64 #62

sukhmel opened this issue Jun 12, 2014 · 7 comments

Comments

@sukhmel
Copy link

sukhmel commented Jun 12, 2014

It seems, that event0 produces occasional crashes in Windows, below is description and an example.

There are three possible behaviours I observed:

  1. program crashes instantly, and prints error message
  2. program starts, but upon close prints same error
  3. program starts and closes fine

error message is

Segmentation fault/access violation in generated code

when amount of buttons (see below) is one, (1) never occurs
upon increase of amount of buttons, (2) seems to occure less, than before
amount of (1) or (2) is estimated to be about 30-40 %

{-# LANGUAGE ScopedTypeVariables #-}

import Control.Monad (replicateM, mapM_, void)
import Graphics.UI.WX hiding (Event)

import Reactive.Banana
import Reactive.Banana.WX

main = start $ do
       pad     <- frame []                     
       buttons <- replicateM 3 -- this amount influences on behaviour
                $ button pad []
       let network :: forall t. Frameworks t => Moment t ()
           network = void $ mapM_ (`event0` command) buttons
                                -- ^ crash inside ^
       net <- compile network
       actuate net
@HeinrichApfelmus
Copy link
Owner

That's a tough one. I don't have access to a Windows machine and can't test it.

Chances are that event0 calls the underlying wxWindows library in ways that it can't handle. However, it may also be that I messed up something with observable sharing, which would explain the non-deterministic nature of the crash. Then, the fault would be with reactive-banana.

Does the problem appear on other machines as well? Does a similar example for wxHaskell exhibit the same problem?

@sukhmel
Copy link
Author

sukhmel commented Jun 20, 2014

Sorry for long reply.
I had no other Win machine, but will try to reproduce the bug on other computers. Some time later I will also test similar scenario with pure wxHaskell. I can provide some more debug output, if I kno, what and how to collect.

@HeinrichApfelmus
Copy link
Owner

I can't reproduce the crash on OS X 10.6. That said, only a single button is shown on my screen. No idea why, but since no layout has been specified, this behavior is not forbidden, at least.

@sukhmel
Copy link
Author

sukhmel commented Jun 22, 2014

I tested compiled code on another Win-machine, behaviour is the same. Although I am not able to compile from source there.

Speaking of only one button -- that's how it's supposed to be, layout does not affect the issue.
I still haven't tried pure wxHaskell example, as I'm not sure it will be very informative if that code is supposed to create responses on command for all buttons and do nothing more.

@HeinrichApfelmus
Copy link
Owner

The pure wxHaskell version allows us to distinguish between problems in reactive-banana (which I could fix) and wxHaskell (which I can't fix). If the issue persists in a version that only uses wx and not reactive-banana, then we have the latter situation.

@sukhmel
Copy link
Author

sukhmel commented Jun 23, 2014

I have compiled under windows without reactive-banana completely.

When line with (:=), marked as (*) is used, everything is perfectly fine,
but when I use (:~) as in reactive-banana-wx event1ToAddHandler,
random crashes occur frequently.

I guess, that it might be an issue with incorrect version of wx on my machine,
nevertheless, I believe this is better be reported to maintainers of wxHaskell.
I'll post an issue to wxHaskell.

> import Control.Monad (replicateM, mapM_)
> import Graphics.UI.WX

> main = start $ do
>        pad     <- frame [ ]                     
>        buttons <- replicateM 2
>                 $ button pad  []

>        mapM_ (flip set [on command := return ()]) buttons -- (*) fine
>        mapM_ (flip set [on command :~ const (return ())]) buttons

@HeinrichApfelmus
Copy link
Owner

Looks like it's an issue with wxHaskell, then, so I can't do much about it. I'll close the issue here, but feel free to to reopen!

If wxHaskell is giving you too much trouble, you may want to have a look at my other project threepenny-gui. It's a small GUI framework that uses the web browser and has FRP built in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants