tomgr / libcspm

The library FDR3 uses for parsing, type checking and evaluating machine CSP.
https://www.cs.ox.ac.uk/projects/fdr/
Other
30 stars 6 forks source link

Segmentation fault? #9

Closed annonymouse closed 10 years ago

annonymouse commented 10 years ago

Whilst doing the assignment I found an issue with the use of the Set function over large sets. I'm running on OSX (Mavericks). Perhaps the Set function isn't intended to be used in this way?

Not sure whether this is down to libcspm or deeper.

Welcome to FDR 3.0.0 (521b22cd118f0a02ade8a95ac96b294148a7c122) Type :help for help

Set({1..25}) panic: the program has detected an inconsistent internal state. This means that there is a bug in libcspm, not a bug in your input script. Please report this bug using the contact link at https://www.cs.ox.ac.uk/projects/fdr/. In particular, please include the input script that caused this error and a brief description of how to reproduce the problem. Please also include the following message: stack overflow

PhilArmstrong commented 10 years ago

Looks like calculating Set({1..N}) could be a bit stricter, but even so the powerset of a 25 element set will have 225 subsets. I doubt this will fit in the memory of your machine.

PhilArmstrong commented 10 years ago

(A quick back of the envelope calculation suggests that you might fit the resultant set in 3Gb or so of memory, given the likely Haskell representation. I could be out by a factor of two or more quite easily though.)

tomgr commented 10 years ago

@annonymouse how exactly were you using it when it produced the error? For example, were you using Set in a datatype/channel declaration etc?

As Phil says, a set of size 2^25 is going to use a lot of memory so it's probably inadvisable to do that.

Thanks for letting us know though - we can certainly try and improve the situation.

annonymouse commented 10 years ago

@PhilArmstrong cheers for the sanity :) I can only blame the time of the night. In some sense it's better that it failed early or I would have been scratching my head a bit as to why things were taking so long. My approach here was bit flawed but I've changed it slightly anyway.

@tomgr For that error specifically I was using it in the interpreter, github slightly borked my copy/paste job there. I managed to reduce it to a Set({1..19}).

Welcome to FDR 3.0.0 (521b22cd118f0a02ade8a95ac96b294148a7c122)
Type :help for help
>  Set({1..19})
panic: the program has detected an inconsistent internal state.
This means that there is a bug in libcspm, not a bug in your input script.
Please report this bug using the contact link at https://www.cs.ox.ac.uk/projects/fdr/.
In particular, please include the input script that caused this error and a brief
description of how to reproduce the problem. Please also include the following message:
    stack overflow

Given the error tells me to report the bug, I felt guilty not doing so :) This is on a 4 core i7 with 16GB of memory - although I suspect the segmentation fault won't depend on that as it occurs very quickly and the FDR process doesn't seem to be consuming many resources when it does this (although I haven't actually traced it to confirm). As you say, this is a strange thing to be doing so I wouldn't worry too much.

Specifically I was using it in a comprehension to generate sets of events up front rather than generating them on the fly - which may have been flawed given that the size of the problem increases a lot very quickly :smile:

I'm happy to close this issue - but let me know if you wanted to know any more.

tomgr commented 10 years ago

Ahh ok thanks. Certainly trying to print that set might cause problems (I think there are a few space leaks in the pretty printer), but you should be able to use the set in iterations such as { x | x <- Set({...}) } etc. You will need an unfortunate quantity of RAM mind you!

Thanks for letting us know anyhow.