question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

naming a variable starting with a '+' crashes all MiniZinc's subsolvers

See original GitHub issue

Solver: all Minizinc’s subsolvers CPMpy: version v0.9.9 commit e79b3afedc934a9437c2ddb3a9f54d7e2d7bd3ee minizinc-python release version 0.7.0 commit {https://github.com/MiniZinc/minizinc-python/commit/a195cf63fcfbc98665d70ab64efb5424db25bd7e)

This one was a fun one to find, I made a typo when naming a variable and the MiniZinc subsolvers crashed. It works with other symbols as well, I tried -, #, %, * and more. It does not occur with ‘ortools’ or ‘gurobi’.

from cpmpy import *

b = boolvar(name="+")
m = Model()
m += b==0
m.solve(solver="minizinc:ortools")

expected behavior: Treat the variable name as a name instead of code.

Bug found while working on my master thesis.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Wout4commented, Dec 9, 2022

So we decided not to clean the variables because this can lead to duplicate names (for example ‘6var’ and ‘5var’ would both be cleaned to var because names cannot start with a number)

However this can still occur for names with any of the following characters: ‘,’ ’ ’ ‘.’ ‘[’ and ‘]’ (not much we can do about that because these get introduced with np arrays)

0reactions
Wout4commented, Nov 29, 2022

@tias Already had a bit of code in there that cleaned the variable name from some illegal characters (but only a handful of them).

Do you think it’s best to clean all possible variable names, or to throw an exception saying which names are allowed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · CPMpy/cpmpy - GitHub
naming a variable starting with a '+' crashes all MiniZinc's subsolvers bug ... from_file seems to create two separate references for the same...
Read more >
Crashes while renaming variables - Forum - Jamovi
I have downloaded XLSX files from Google Forms. These files have some variable names containing the square bracket ([]) symbol.
Read more >
GENERATE_SCRIPT_VARS with Variables names that are ...
When GENERATE_SCRIPT_VARS is used on VARA key field that exceeds 32 characters and the underlying AE database is Oracle, the WP crash.
Read more >
Variable Names - IBM
Observe the following rules when establishing variable names or referring to variables by their names on commands: Each variable name must be unique; ......
Read more >
language agnostic - How to name variables - Stack Overflow
In practice, I don't need to spend much energy figuring out variable names. I put all of that cognitive effort into naming types,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found