MiniZinc / libminizinc

The MiniZinc compiler
http://www.minizinc.org
Other
499 stars 78 forks source link

Segmentation fault with "minizinc" command #202

Closed scand1sk closed 6 years ago

scand1sk commented 6 years ago

I run MiniZinc 2.1.7 on Debian Unstable. I got the following error with mzn-* commands (whichever solver is run):

*** Mercury runtime: caught segmentation violation ***
cause: address not mapped to object
address involved: 0xffffffffff600000
This may have been caused by a stack overflow, due to unbounded recursion.
exiting from signal handler
Segmentation fault

Note that mzn2fzn and fzn-* commands work well. I could design a workaround by rewritting mzn-gecode as a quick & dirty bash script, but it would be better if it worked as expected :)

Dekker1 commented 6 years ago

I'm afraid that the error by itself won't give us any clues unless you post the model (instance) that you are compiling.

Note that minizinc is merely a driver for FlatZinc solvers, it uses the installed version of mzn2fzn, that stems from MiniZinc 1.*. In the new version of the compiler we have an replacement: mzn-fzn; however this binary is not yet widely used. mzn-gecode is already a shell script that, in the gecode repository, falls back on mzn-fzn.

scand1sk commented 6 years ago

I do not need any model instance. The segfault happens even with no arguments or simply --help. I see that mzn-gecode uses the binary minizinc to launch the solver, and the minizinc binary fails. I get the same error by running ./minizinc with no arguments.

My workaround shell script succeeds by avoiding to call the minizinc binary.

Note that the errors happens both with the Debian packaged release of MiniZinc (although mzn-gecode is missing in the Debian package, the minizinc command fails as well) and the download available on the MiniZinc website.

The issue is very probably linked to the specific environment I work in (although Debian unstable is a fairly popular distribution), but I am not familiar enough with mercury or C++ to investigate this by myself.

guidotack commented 6 years ago

It's possible that some libraries have changed on Debian Unstable that mean it's no longer compatible with the old runtime used for the minizinc binary. There is a replacement driver (called mzn-fzn) that isn't 100% ready for release yet but it's built by default when you build libminizinc from sources, so that may be an alternative for you. It will replace the minizinc binary starting with release 2.2.0.

HelgeS commented 6 years ago

Can confirm the same error with minizinc-ide v2.1.7-1 under Arch Linux. Although I'm unsure which package update caused the error.

Running minizinc -Ggecode model.fzn causes the error, fzn-gecode model.fzn works fine.

edouardklein commented 6 years ago

I, too, was bitten by this bug, just before the deadline of the coursera course... I wrote a shell script wrapper as a workaround:

#!/usr/bin/env sh
MZN_FILE=$1
DATA_FILE=$2

mzn2fzn $MZN_FILE $DATA_FILE && fzn-gecode -a $(basename $MZN_FILE .mzn).fzn | sed -E 's/array1d\([0-9]+\.\.[0-9]+, //' | sed -E 's/\)//' 

Would it be possible to compile minizinc as a statically linked executable ?

Dekker1 commented 6 years ago

@edouardklein It's a shame you ran into the same problem when you where on a deadline. As said before, we intend to replace the minizinc executable in the next release. The easiest solution is still to replace minizinc with mzn-fzn

Note that your script will actually not use any output statement from the provided MiniZinc model. Instead of using sed you would have to use solns2out, a tool provided which will use the output model.

guidotack commented 6 years ago

You should also be able to use the MiniZinc IDE for submitting your solutions to Coursera, since it doesn't use the minizinc binary.

Cheers, Guido

On Mon, Mar 12, 2018 at 10:56 AM, Jip J. Dekker notifications@github.com wrote:

@edouardklein https://github.com/edouardklein It's a shame you ran into the same problem when you where on a deadline. As said before, we intend to replace the minizinc executable in the next release. The easiest solution is still to replace minizinc with mzn-fzn

Note that your script will actually not use any output statement from the provided MiniZinc model. Instead of using sed you would have to use solns2out, a tool provided which will use the output model.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MiniZinc/libminizinc/issues/202#issuecomment-372161272, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ7eTKcCqyvEX4RnMja0XK2-FE2p7b17ks5tdbmdgaJpZM4SJ3Uu .

-- GUIDO TACK Senior Lecturer

Information Technology Monash University Level 6, Room 6.40, Building H, Caulfield Campus 900 Dandenong Road Caulfield East VIC 3145 Australia T: +61 3 9903 1214 E: guido.tack@monash.edu http://users.monash.edu/~guidot/

scand1sk commented 6 years ago

I also had the issue with Coursera. Coursera provides scripts that rely on the minizinc command with various command-line parameters. This makes tricky to design workarounds.

Le lun. 12 mars 2018 à 01:14, Guido Tack notifications@github.com a écrit :

You should also be able to use the MiniZinc IDE for submitting your solutions to Coursera, since it doesn't use the minizinc binary.

Cheers, Guido

On Mon, Mar 12, 2018 at 10:56 AM, Jip J. Dekker notifications@github.com wrote:

@edouardklein https://github.com/edouardklein It's a shame you ran into the same problem when you where on a deadline. As said before, we intend to replace the minizinc executable in the next release. The easiest solution is still to replace minizinc with mzn-fzn

Note that your script will actually not use any output statement from the provided MiniZinc model. Instead of using sed you would have to use solns2out, a tool provided which will use the output model.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/MiniZinc/libminizinc/issues/202#issuecomment-372161272 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AJ7eTKcCqyvEX4RnMja0XK2-FE2p7b17ks5tdbmdgaJpZM4SJ3Uu

.

-- GUIDO TACK Senior Lecturer

Information Technology Monash University Level 6, Room 6.40, Building H, Caulfield Campus 900 Dandenong Road https://maps.google.com/?q=900+Dandenong+Road+%0D%0ACaulfield+East+VIC+3145+%0D%0AAustralia&entry=gmail&source=g Caulfield East VIC 3145 https://maps.google.com/?q=900+Dandenong+Road+%0D%0ACaulfield+East+VIC+3145+%0D%0AAustralia&entry=gmail&source=g Australia https://maps.google.com/?q=900+Dandenong+Road+%0D%0ACaulfield+East+VIC+3145+%0D%0AAustralia&entry=gmail&source=g T: +61 3 9903 1214 <+61%203%209903%201214> E: guido.tack@monash.edu http://users.monash.edu/~guidot/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MiniZinc/libminizinc/issues/202#issuecomment-372162520, or mute the thread https://github.com/notifications/unsubscribe-auth/AC67Nc8jN1Wa8JP5TYMLga0bNu-YaOHuks5tdb3NgaJpZM4SJ3Uu .

guidotack commented 6 years ago

The minizinc command in release 2.2.0 is a complete rewrite that hopefully fixes these problems.