google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
10.82k stars 2.09k forks source link

Segmentation fault in CP-SAT #4144

Closed gabriel-gehrke closed 4 months ago

gabriel-gehrke commented 4 months ago

What version of OR-Tools and what language are you using? Version: v9.9.3963 Language: Python 12.1

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi) I am using CP-SAT

What operating system (Linux, Windows, ...) and version? Reproduced on Linux Mint 21, and on Linux Fedora 39 (two different computers).

What did you do? What I did / what I am doing:

I create and solve many small-ish Cp Models in 2D packing context, and I have found at least one instance which >>sometimes<< causes a segfault.

In the terminal, the segfault just looks like this:

#14      0.03s best:17    next:[6,16]     no_lp (fixed_bools=46/189)
#15      0.03s best:16    next:[6,15]     no_lp (fixed_bools=49/189)
#16      0.04s best:15    next:[6,14]     no_lp (fixed_bools=50/191)
#17      0.04s best:14    next:[6,13]     no_lp (fixed_bools=52/193)
#Bound   0.36s best:14    next:[7,13]     max_lp
#Bound   0.37s best:14    next:[8,13]     max_lp
#Model   6.65s var:125/126 constraints:161/162
#Model   7.42s var:124/126 constraints:160/162
#Model   8.21s var:123/126 constraints:159/162
#Model   8.35s var:122/126 constraints:158/162
#Model   8.52s var:121/126 constraints:157/162
#Model   8.60s var:120/126 constraints:156/162
#Bound   8.66s best:14    next:[10,13]    no_lp
#Bound   8.69s best:14    next:[11,13]    no_lp
#Bound   8.73s best:14    next:[12,13]    no_lp
Speicherzugriffsfehler (Speicherabzug geschrieben)

To trigger this bug, the instance must be solved repeatedly, as it does not occur on every run. So, I believe it might be a race condition or similar timing-related bug.

I wrote a small script that loads the exported model proto and solves it repeatedly. The script and the model (in txt form) are appended to this issue.

model.txt trigger_segfault.py.txt

lperron commented 4 months ago

Do you have rectangles that can have zero area ?

lperron commented 4 months ago

I ran it 50 times on main. It did not crash.

gabriel-gehrke commented 4 months ago

Do you have rectangles that can have zero area ?

No, this is not possible.

I ran it 50 times on main. It did not crash.

It is very unfortunate to me that you cannot reproduce the bug. As I said, I was able to reproduce this bug on two separate machines, so I am confident that this is a real issue. For me, the segfault usually occurs in the first five iterations. Is there anything else I could provide you with to enable finding the root cause of the issue?

Maybe some information about my environments:

lperron commented 4 months ago

I am on the main branch where I fixed some crash in the 2d packing constraint. Laurent Perron | Operations Research | @.*** | (33) 1 42 68 53 00

Le jeu. 21 mars 2024 à 11:10, Gabriel Gehrke @.***> a écrit :

Do you have rectangles that can have zero area ?

No, this is not possible.

I ran it 50 times on main. It did not crash.

It is very unfortunate to me that you cannot reproduce the bug. As I said, I was able to reproduce this bug on two separate machines, so I am confident that this is a real issue. For me, the segfault usually occurs in the first five iterations. Is there anything else I could provide you with to enable finding the root cause of the issue?

Maybe some information about my environments:

  • On both PCs I use Python 12.1
  • On both PCs I use conda to create and manage Python environments

— Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/4144#issuecomment-2011819416, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3MNSLRI6FYYUCW3IVLYZKWYJAVCNFSM6AAAAABFALKW22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJRHAYTSNBRGY . You are receiving this because you modified the open/close state.Message ID: @.***>