Kappa-Dev / KappaTools

Tool suite for kappa models. Documentation and binaries can be found in the release section. Try it online at
http://kappalanguage.org/
GNU Lesser General Public License v3.0
112 stars 41 forks source link

Stack overflow with very large model #503

Open webermarcolivier opened 6 years ago

webermarcolivier commented 6 years ago

Hi,

When running a very large model (165MB), KaSim throws a stack overflow error:

KaSim -i model.kappa -u time -l 5 -p 0.2 -o model.out
Parsing model.kappa...
done
+ simulation parameters
+ Sanity checks

Stack overflow

Is there any way to trace back the error? Compile KaSim in debugging mode? Is there any hard limit in the number of agents, rules, or parameters?

Bests,

Marc

pirbo commented 6 years ago

To be sure. What version of KaSim are you using? (copy/paste the result of KaSim --version)

Is there any way to trace back the error?

Can you do ./_build/main/KaSim.native model.kappa -u time -l 5 -p 0.2 -o model.out --backtrace? There should then be info before Stack overflow (a list of file names:line number). Can you copy/paste them here?

Is there any hard limit in the number of agents, rules, or parameters?

There should not be. This is definitely a bug. (even though a 165Mo large model will clearly be a challenge for the simulator to handle :-))

webermarcolivier commented 6 years ago

I am running the last version from the master branch:

Kappa Simulator: v4.0rc1-81-ga940d84

The output of ./_build/main/KaSim.native model.kappa -u time -l 5 -p 0.2 -o model.out --backtrace is:

Parsing model.kappa...
done
+ simulation parameters
+ Sanity checks

Stack overflow
Raised by primitive operation at file "array.ml", line 39, characters 13-27
pirbo commented 6 years ago

OK this is not helpful... :-) Maybe you can try to do make debug and then ./_build/main/KaSim.byte model.kappa -u time -l 5 -p 0.2 -o model.out --backtrace to see if it is better.

Else, I'm out of idea on to seek the issue remotely. Would you agree to send me the model (or any subpart of it that still fail)?

webermarcolivier commented 6 years ago

The output from the debug compiled version does not seem much more helpful...

Stack overflow
Raised by primitive operation at file "list.ml", line 101, characters 16-37
Called from file "list.ml", line 101, characters 16-37
Called from file "list.ml", line 101, characters 16-37
Called from file "list.ml", line 101, characters 16-37
...

I will try to generate a subset of the model that still fails and send it to you. Thanks a lot for your help.

pirbo commented 6 years ago

No, it is more helpful. At the other extremity of the super long list of Called from file "list.ml", line 101, characters 16-37 there must be other filenames:line number. Can you copy/paste them, please? Also, are you indeed using OCaml 4.05? (In this case, the problem is a List.fold_right ...)

pirbo commented 6 years ago

Please "pull" last master and retry in debug version. I may have found the first culprit but others may follow (or worse it can take forever without failing)...

webermarcolivier commented 6 years ago

There were no other filenames:line number at the end of the long list of identical messages. I am indeed using OCaml version 4.05.0. I pulled the master branch and compiled with make debug. The KaSim command now runs for quite a longer time, but I still get a stackoverflow error, and only 3 lines of trace.

Parsing model.kappa...
done
+ simulation parameters
+ Sanity checks

Stack overflow
Raised at file "format.ml", line 239, characters 41-52
Called from file "format.ml", line 465, characters 8-33
Called from file "format.ml", line 480, characters 6-24

If you agree I could send you the model.

pirbo commented 6 years ago

I did not forget about that but I'll have to change strategy because the easy way to figure out where the problem comes from: running your model through the OCaml debugger, takes more than a week before reaching the issue (Well I don't know how long it would take, I killed it after a week ...)

To be continued