Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#11379 closed enhancement (fixed)

Add Quantumino solver to sage/games

Reported by: slabbe Owned by: slabbe
Priority: major Milestone: sage-4.7.2
Component: misc Keywords: sd31
Cc: Merged in: sage-4.7.2.alpha2
Authors: Sébastien Labbé Reviewers: Rob Beezer
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Attachments (10)

trac_11379_quantamino-sl.patch (35.2 KB) - added by slabbe 6 years ago.
trac_11379-size-suggestion.patch (997 bytes) - added by rbeezer 6 years ago.
trac_11379-size-suggestion-updated.patch (1.0 KB) - added by slabbe 6 years ago.
Applies over the correction patch.
trac_11379_corrections-sl.patch (104.8 KB) - added by slabbe 6 years ago.
Applies over my first patch
trac_11379_color_issue-sl.patch (14.4 KB) - added by slabbe 6 years ago.
Applies over the correction patch.
trac_11379-reviewer-docs.patch (3.0 KB) - added by rbeezer 6 years ago.
trac_11379_hole_bug-sl.patch (20.1 KB) - added by slabbe 6 years ago.
Applies over the precedent patches.
trac_11379_2d_boundary-sl.patch (11.8 KB) - added by slabbe 6 years ago.
Applies over the precedent patches.
trac_11379_quantamino-total-sl.patch (87.0 KB) - added by rbeezer 6 years ago.
Standalone, comprehensive patch
trac_11379_corrections-sl-v2.patch (104.8 KB) - added by rbeezer 6 years ago.
New version with edited commit string

Download all attachments as: .zip

Change History (50)

comment:1 Changed 6 years ago by rbeezer

I saw this demo'ed at Sage Days 30. It's really nice. I'll give the patch as look once it appears.

comment:2 Changed 6 years ago by slabbe

Just added the patch.

The file takes 80 seconds to test... so I still need to add some "long" doctest warnings...

Sébastien

Changed 6 years ago by slabbe

comment:3 Changed 6 years ago by slabbe

  • Status changed from new to needs_review

comment:4 Changed 6 years ago by slabbe

Takes now 17 seconds to test on my machine (35s with long test).

Changed 6 years ago by rbeezer

comment:5 follow-up: Changed 6 years ago by rbeezer

  • Status changed from needs_review to needs_work

Hi Sebastien,

Very nice - this is a lot of fun, and a great advertisement for the power of dancing links. Lots of little comments, I hope its not too much. Nothing very serious.

  • One doctest failure. I'm on 64-bit Linux - could 32-bit/64-bit be the cause?
    sage -t  "devel/sage-main/sage/games/quantumino.py"
    **********************************************************************
    File "/sage/sage-4.7/devel/sage-main/sage/games/quantumino.py", line 193:
        sage: hash(p)
    Expected:
        2059134902
    Got:
        6915256369230374838
    **********************************************************************
    
  • Why does block number 8 (yellow) have a hole in the middle? See discussion below about size.
  • Documentation looks good. I would have liked to see a bit more detail at the module level for a quickstart - more like for the QuantuminoSolver class-level documentation. Specifically:
    • Make it clearer that you will see the puzzle pieces in 3D with the show_pentaminos() command.
    • Show how to get the list of the actual placements for a single solution. I wanted to do this once I had a solution since the _repr_ was not as informative as my curiosity.
    • Maybe a real quick overview of the classes: the pentamino and polyomino classes, the solution class, and the solver class.
  • I thought an interact would be fun. Checkboxes for the excluded piece, plus the ability to "explode" the solution via a slider. I'm not suggesting you write an interact, but a size argument as input to show3d() (for the solution) would make this possible. Patch attempts to do this, but it is not totally correct, at size below 0.50 the pieces start to fall apart into cubes. And the aside piece breaks up even earlier in my test. The hole in block number 8 behaves slightly differently. So as a suggestion: consider adding a size argument to pass from the solution show3d() down to each piece. But my patch is just a suggestion - it is not ready to use.
  • Some of the lesser methods could use some improved documentation. In many cases, at least the first summary line, and/or the type of input. For example:
    • "Return the 3D polyomino defined by a set of 3d coordinates." It is not clear what "defined by" means here, maybe the coordinates are for the "bottommost" corner of each constituent cube.
    • It is not clear what sub does without looking at the code. A one-line summary and an input list would be enough, I think.
  • I'm not sure upper-case is part of Python or Sage style for code. SPACE, COORD_TO_INT, and INT_TO_COORD look funny to my eye.
  • I set up Sudoku puzzles with a "Sudoku" class. Then s = Sudoku(.....), followed by s.solve() gave an iterator over solutions. Would it be worth trying to mimic that approach for consistency? I'm not arguing that my approach was better - just first. :-)

Minor editing

  • "needs to creates" should be "create"
  • "where each pieces is used exactly once" should be "piece"
  • # Class QuantuminoSolultion (misspelled in comment)
  • I think even with the utf-8 header the consensus (rule?) has been straight ASCII in source files? Which I know even impacts your name. I wish it wasn't this way (maybe I'm wrong?). The trademark symmbol and bracketing on "think inside the box" for the game description would need adjustments.
  • #bug trac #11272 - can this go away?
  • #return G (twice) - can these go away?

As I said, lots of little stuff, which I hope does not look like too long a list. I've tried to keep it to suggestions so you have the latitude to approach it as you see fit. I'll be happy to stick with this review as you make revisions.

Rob

comment:6 Changed 6 years ago by rbeezer

One more comment I forgot:

ss=quantumino_solver.get_solution(7, box=(3,3,9))

seems to totally hang on my system - not even a Ctrl-C gets it back. Do I need to use a box of exactly volume 80? Was it unreasonable to expect a different result?

comment:7 in reply to: ↑ 5 ; follow-up: Changed 6 years ago by slabbe

Hi Rob,

Thanks a lot for your good review. I almost done making the corrections. I also added a class Tiling Solver which replaces the puzzle solver function. This allows for more introspection (for instance looking at the rows passed to the DLX solver) and also comptute the number of solutions more efficiently. I have one question about your suggestion :

  • I thought an interact would be fun. Checkboxes for the excluded piece, plus the ability to "explode" the solution via a slider. I'm not suggesting you write an interact, but a size argument as input to show3d() (for the solution) would make this possible. Patch attempts to do this, but it is not totally correct, at size below 0.50 the pieces start to fall apart into cubes. And the aside piece breaks up even earlier in my test. The hole in block number 8 behaves slightly differently. So as a suggestion: consider adding a size argument to pass from the solution show3d() down to each piece. But my patch is just a suggestion - it is not ready to use.

I don't understand what is meant by ""explode" the solution". Is this a slider which would bring the size of the cube from 0 to 1 ? It doesn't not seem that nice to me. I would rather suggest a slider which would go from one solution to the other, where we would see the pieces that are removed and added, etc. Or maybe even an animation of it. I am almost done doing it: I have the iterator of partial solutions. I only need to know how to make a Jmol animation of 3D Graphics object or maybe an animation of Tachyon images.

Sébastien

comment:8 Changed 6 years ago by slabbe

  • Description modified (diff)

comment:9 in reply to: ↑ 7 Changed 6 years ago by slabbe

  • Status changed from needs_work to needs_review

I don't understand what is meant by ""explode" the solution".

Ok, now I understand. I needed to try it ! It is true that it helps to change the size of the small cubes. Because of conflicts, I had to reload your patch (but could not erase yours) so I renamed it. Hence, your patch apply over my second patch.

I think I was able to answer all of your comments. Needs review!

Sébastien

Changed 6 years ago by slabbe

Applies over the correction patch.

comment:10 follow-up: Changed 6 years ago by rbeezer

I had a bit of time to look through the patch. Looks great! I still need to do a thorough test of the new features and all, so will try to get to that soon.

Would Franco let you bring the real physical puzzle to Seattle for SD 31?

Rob

comment:11 in reply to: ↑ 10 Changed 6 years ago by slabbe

Would Franco let you bring the real physical puzzle to Seattle for SD 31?

Sure! I'll ask. And will try not to forget it!

Sébastien

comment:12 Changed 6 years ago by mariah

  • Component changed from PLEASE CHANGE to misc

comment:13 follow-up: Changed 6 years ago by slabbe

  • Status changed from needs_review to needs_work

I have been working on it again yesterday. I will update the patches again quite soon. Do not review until then.

Sebastien

comment:14 in reply to: ↑ 13 Changed 6 years ago by rbeezer

  • Description modified (diff)
  • Keywords sd31 added
  • Reviewers set to Rob Beezer

Replying to slabbe:

I have been working on it again yesterday. I will update the patches again quite soon. Do not review until then.

Thanks - ready whenever you are (I think!).

comment:15 Changed 6 years ago by slabbe

Great. So I will upload the patches later tonight! I still have some cleaning to make.

Changed 6 years ago by slabbe

Applies over my first patch

comment:16 Changed 6 years ago by slabbe

  • Description modified (diff)
  • Status changed from needs_work to needs_review
  • Summary changed from Add Quantamino solver to sage/games to Add Quantumino solver to sage/games

Ok, so I just re-uploaded the correction patch. The size suggestion patch as been folded into that correction patch. So only two patches are needed to be applied (the one that has already been reviewed and the correction patch).

So, compared to what has already been reviewed, I did a bunch of improvements: I created a new file sage/combinat/tiling.py and moved the polyomino class into it. Also, I created a new class called TilingSolver which solves the general problem of Tiling a box by polyomino. This class replaces the old function general_puzzle_solver which I might misspell. The TilingSolver class allows to do more introspection like getting the rows passed to the DLX solver and count them. One can also get the DLX Solver. I managed to write the Polyomino and TilingSolver abstract enough so that they can be defined in any dimension. Ploting works when the dimension is 2 or 3. I also added parameters to allow (or not) reflections and rotations and whether the pieces can be reused or not.

There is still one issue mentionned in the review that I did not fixed. The holes in the polyomino. Maybe tomorrow we can think about a efficient way to fix this?

Question: Should I use Pentomino like Donald Knuth does or Pentamino like the game Quantumino calls the pieces? Which is best?

Good night!

comment:17 Changed 6 years ago by slabbe

  • Description modified (diff)

comment:18 Changed 6 years ago by slabbe

  • Description modified (diff)

In a new patch I just uploaded which applies on top of two others, I fixed a color issue for when pieces are reusable. Sorry, I had the idea for the fix when I woke up. Now, I stop working on it!

Changed 6 years ago by slabbe

Applies over the correction patch.

comment:19 Changed 6 years ago by slabbe

Ok, so I can't stop working on it apparently. I added the possibility of making an animation. I also fixed the problem that showed up during my quick demo.

Needs review!

Changed 6 years ago by rbeezer

comment:20 follow-ups: Changed 6 years ago by rbeezer

  • Description modified (diff)

Sebastien,

Sorry to be so tardy on this one. Really just one "issue" that I think needs attention.

Made a reviewer patch: Changed some module and class links in documentation to be active, fixed a couple minor English language things. Do not list me as an author for these.

The animations are great. Can you do something to mark the end (like a few blank frames, for maybe a half-second)? It goes so fast, it is hard to tell where the start is and where the end is.

Related Questions:

  1. Pentamino 8 (a yellow one) still has a hole in it. Not a big deal, but perhaps a symptom of something that should be done more carefully?
  2. I feel bad to bring this up, since I suggested it. The "size" parameter works fine for 0.5 < size < 1.0. Proably size > 1.0 should raise an error. Below size=0.5 the puzzle pieces seem to break into lots of individual cubes. Also the hole in piece 8 seems to change according to size. So I wonder if these first two items are related.
  3. In the 3D puzzle in the tiling module documentation, there are again holes in the pieces.
  4. Maybe each cube of a piece needs to be shrunk and translated, relative to some anchor point (the "corner" closest to the origin?). I have not looked carefully enough to know if this what needs to be done.

Rob

comment:21 in reply to: ↑ 20 ; follow-up: Changed 6 years ago by slabbe

  • Status changed from needs_review to needs_work

Hi Rob,

Sorry to be so tardy on this one. Really just one "issue" that I think needs attention.

No problem!

Made a reviewer patch: Changed some module and class links in documentation to be active, fixed a couple minor English language things. Do not list me as an author for these.

Good, thanks for those fixes! Is there a problem with one of the fixes ? Because there is a symbol tilde ~ that appears in front of one of the class path.

:class:`~sage.combinat.tiling.TilingSolver`

The animations are great. Can you do something to mark the end (like a few blank frames, for maybe a half-second)? It goes so fast, it is hard to tell where the start is and where the end is.

The delay between frames and the number of iterations are arguments of the method show (see animate??). I would keep the animation function as is, but add an exemple in the doctest of how to change those parameters and add blank frames at the end. What do you think?

  1. Pentamino 8 (a yellow one) still has a hole in it. Not a big deal, but perhaps a symptom of something that should be done more carefully?

Ok. I will think about it. Let me find a solution which will be better than the "cube in the middle" I am using up to now. Maybe using Simplicial Complexes of cubes, I could get the exact boundary of the piece? I take a look at it and comes back with a fix soon.

Sébastien

comment:22 in reply to: ↑ 21 Changed 6 years ago by rbeezer

Replying to slabbe:

No problem!

Good. We just need to finish this before you become a father. ;-)

:class:`~sage.combinat.tiling.TilingSolver`

The tilde should suppress the sage.combinat.tiling prefix in the output. Don't remember just why I did it that way there (I'm sure I had a reason at the time!) - but you should feel free to adjust it if you would rather have the fully-qualified name.

The delay between frames and the number of iterations are arguments of the method show (see animate??). I would keep the animation function as is, but add an exemple in the doctest of how to change those parameters and add blank frames at the end. What do you think?

Perfect.

Ok. I will think about it. Let me find a solution which will be better than the "cube in the middle" I am using up to now. Maybe using Simplicial Complexes of cubes, I could get the exact boundary of the piece? I take a look at it and comes back with a fix soon.

Maybe if each piece had a center, or maybe a center of a bounding box, or something like that. Then you could shrink into the center. Seems like you work off a corner right now, but again, I have not studied it very carefully. If the size parameter becomes too much trouble, feel free to drop it, but I think fixing this will fix a variety of other things, like the hole in piece 8.

Changed 6 years ago by slabbe

Applies over the precedent patches.

comment:23 in reply to: ↑ 20 ; follow-up: Changed 6 years ago by slabbe

  • Authors set to Sébastien Labbé
  • Status changed from needs_work to needs_review

I just uploaded a new patch which applies over the precedent ones.

The animations are great. Can you do something to mark the end (like a few blank frames, for maybe a half-second)? It goes so fast, it is hard to tell where the start is and where the end is.

I added a paragraph saying (copied from the animate doc string) :

    The ``show`` function takes arguments to specify the delay between        
    frames (measured in hundredths of a second, default value 20) and         
    the number of iterations (default value 0, which means to iterate         
    forever). To iterate 4 times with half a second between each frame::      
                                                                              
        sage: a.show(delay=50, iterations=4) # optional                       

I also fixed the methods dlx_common_prefix_solutions and dlx_incremental_solutions which were broken. That was maybe the reason why the animations were going so fast... So now, the following animation looks better and not too fast even with default parameters of the method show :

sage: from sage.combinat.tiling import Polyomino, TilingSolver         
sage: y = Polyomino([(0,0),(1,0),(2,0),(3,0),(2,1)], color='cyan')     
sage: T = TilingSolver([y], box=(5,10), reusable=True, reflection=True)
sage: a = T.animate('incremental')
sage: a
Animation with 123 frames                 
sage: a.show()
  1. Maybe each cube of a piece needs to be shrunk and translated, relative to some anchor point (the "corner" closest to the origin?).

Ok. So I implemented this solution (translation to origin, shrinked, translated back) and changed show2d and show3d methods accordingly. For the Quantumino, it looks great. The yellow pentamino number 8 do not have a hole anymore :

sage: from sage.games.quantumino import show_pentaminos
sage: show_pentaminos()                                

Also, using size<0.5 does not create disconnected cubes :

sage: from sage.games.quantumino import QuantuminoSolver            
sage: s = QuantuminoSolver(0).solve().next()
sage: s.show3d(size=0.3)

Although, I can not say that the proposed solution is perfect and always better than the precedent one. In the example below, there are no holes anymore which is good. But, the space between each piece is not uniform and it is even hard to find a size which will avoid the pieces to touch each other without being to far from each other:

sage: from sage.combinat.tiling import Polyomino, TilingSolver              
sage: L = []                                                                
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,2),(1,3)]))
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,2)]))      
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,3)]))      
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,3)]))            
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1)]))            
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,1),(1,2)]))            
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,1),(1,3)]))            
sage: L.append(Polyomino([(0,1),(0,2),(0,3),(1,0),(1,1),(1,3)]))            
sage: L.append(Polyomino([(0,1),(0,2),(0,3),(1,0),(1,1),(1,2)]))            
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)]))            
sage: T = TilingSolver(L, (8,8), reflection=True)                          
sage: solution = T.solve().next()                                          
sage: G = sum([piece.show2d(size=0.85) for piece in solution], Graphics()) 
sage: G.show(aspect_ratio=1)                                               

What do you think?

Sébastien

comment:24 Changed 6 years ago by slabbe

  • Description modified (diff)

comment:25 Changed 6 years ago by slabbe

  • Description modified (diff)

I don't know how to speak to the buildbot. Maybe the commas between patches name are needed? I am trying.

More info is here : http://wiki.sagemath.org/buildbot

comment:26 Changed 6 years ago by slabbe

Or maybe the information must be put in a comment instead of above in the description :

For the patchbot:

Apply trac_11379_quantamino-sl.patch, trac_11379_corrections-sl.patch, trac_11379_color_issue-sl.patch, trac_11379-reviewer-docs.patch, trac_11379_hole_bug-sl.patch

Changed 6 years ago by slabbe

Applies over the precedent patches.

comment:27 Changed 6 years ago by slabbe

  • Description modified (diff)

For the patchbot:

Apply trac_11379_quantamino-sl.patch, trac_11379_corrections-sl.patch, trac_11379_color_issue-sl.patch, trac_11379-reviewer-docs.patch, trac_11379_hole_bug-sl.patch, trac_11379_2d_boundary-sl.patch

comment:28 in reply to: ↑ 23 Changed 6 years ago by slabbe

Replying to slabbe:

Although, I can not say that the proposed solution is perfect and always better than the precedent one.

I change the way to show 2d polyomino. First, I reverted its drawing as it was before. Second, I added a boundary line. Thirdly, I made the edge between adjacent points smaller than before. This way, holes are more esthetic and natural : we accept them more easily.

You can see the result with this example :

sage: from sage.combinat.tiling import Polyomino, TilingSolver                         
sage: L = []                                                                           
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,2),(1,3)], 'yellow')) 
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,2)], "black"))        
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,3)], "gray"))         
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,3)],"cyan"))                
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,0),(1,1)],"red"))                 
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,1),(1,2)],"blue"))                
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(0,3),(1,1),(1,3)],"green"))               
sage: L.append(Polyomino([(0,1),(0,2),(0,3),(1,0),(1,1),(1,3)],"magenta"))             
sage: L.append(Polyomino([(0,1),(0,2),(0,3),(1,0),(1,1),(1,2)],"orange"))              
sage: L.append(Polyomino([(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)],"pink"))                
sage: T = TilingSolver(L, (8,8), reflection=True)                          
sage: solution = T.solve().next()                                          
sage: G = sum([piece.show2d() for piece in solution], Graphics()) 
sage: G.show(aspect_ratio=1, axes=False)                                               

Or this animation :

sage: a = T.animate()      #45 seconds     
sage: a                   
Animation with 328 frames 
sage: a.show()      # take some time like 2 minutes

Now, I am happy with the patch. Needs review!

Sébastien

comment:29 Changed 6 years ago by slabbe

The above 328 frames animation is here  :

http://thales.math.uqam.ca/~labbes/Experimentations/florent.gif

done with the following parameters

sage: a.show(delay=50, iterations=1)

Changed 6 years ago by rbeezer

Standalone, comprehensive patch

comment:30 Changed 6 years ago by rbeezer

  • Status changed from needs_review to positive_review

I like all the changes (no holes!). And the 2-D pieces look real nice. I think this is ready to go - builds, passes long tests, nice documentation on 4.7.1.alpha4. So positive review.

One patch needed a commit message, and since it was easy, I just rolled everything into one big "total" patch. Still has Sebastian's name on it.

Nice work on a big project - this will be a great way to demonstrate backtracking (and dancing links).

Rob

comment:31 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-4.7.1 to sage-4.7.2

comment:32 Changed 6 years ago by jdemeyer

  • Status changed from positive_review to needs_work

The commit message of trac_11379_corrections-sl.patch should be changed since it contains a reference to a mercurial queue.

Changed 6 years ago by rbeezer

New version with edited commit string

comment:33 follow-up: Changed 6 years ago by rbeezer

  • Description modified (diff)
  • Status changed from needs_work to positive_review

I consolidated the commit strings ont eh one patch, and had to use a new name for the file, since I do not have the privileges to replace it.

Rob

comment:34 Changed 6 years ago by jdemeyer

  • Merged in set to sage-4.7.2.alpha2
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:35 in reply to: ↑ 33 ; follow-up: Changed 6 years ago by slabbe

Replying to rbeezer:

I consolidated the commit strings ont eh one patch, and had to use a new name for the file, since I do not have the privileges to replace it.

Thanks Rob for taking care of this. Thanks again for the whole review. I am happy to see this is now merged!

Sébastien

comment:36 in reply to: ↑ 35 Changed 6 years ago by rbeezer

Replying to slabbe:

Replying to rbeezer: Thanks Rob for taking care of this.

No problem. I knew Jeroen was busy merging patches, and I was busy rebasing some of my linear algebra stuff, so I wanted to "strike while the iron was hot."

Thanks again for the whole review. I am happy to see this is now merged!

My pleasure - it is a nice piece of work. Feel free to cc me on other combinatorial goodness.

Best of luck with the upcoming addition to the family!

Rob

comment:37 follow-up: Changed 6 years ago by fbissey

Just a note from my testing of 4.7.2.alpha2. I have no problem on a vanilla sage even with python 2.7 installed. However in sage-on-gentoo one test is failing

        .. NOTE::

            The DLX solver throws a Segmentation Fault when the
            number of rows is zero::
                
                sage: from sage.combinat.matrices.dancing_links import dlx_solver
                sage: rows = []
                sage: x = dlx_solver(rows)
                sage: x.search()        # not tested
                BOOM !!!

sage-on-gentoo goes BOOM at

sage: x = dlx_solver(rows)

With a SIGABRT

sage:  x = dlx_solver(rows)
python2.7: sage/combinat/matrices/dancing_links_c.h:217: void dancing_links::setup_columns(): Assertion `nr_columns > 0' failed.
/usr/lib64/libcsage.so(print_backtrace+0x24)[0x7fea73a945f7]
/usr/lib64/libcsage.so(sigdie+0x1d)[0x7fea73a94687]
/usr/lib64/libcsage.so(sage_signal_handler+0x157)[0x7fea73a94822]
/lib64/libpthread.so.0(+0xfee0)[0x7fea79206ee0]
/lib64/libc.so.6(gsignal+0x35)[0x7fea78ea5ee5]
/lib64/libc.so.6(abort+0x186)[0x7fea78ea7896]
/lib64/libc.so.6(__assert_fail+0xf5)[0x7fea78e9e7a5]
/usr/lib64/python2.7/site-packages/sage/combinat/matrices/dancing_links.so(+0x855d)[0x7fea4e73255d]

while normal sage goes BOOM in the next not tested bit with a SIGSEGV

sage: x = dlx_solver(rows)
sage: x.search()
/home/work/fbissey/sandbox/sage-4.7.2.alpha2/local/lib/libcsage.so(print_backtrace+0x31)[0x7fe2bbd11e65]
/home/work/fbissey/sandbox/sage-4.7.2.alpha2/local/lib/libcsage.so(sigdie+0x14)[0x7fe2bbd11e97]
/home/work/fbissey/sandbox/sage-4.7.2.alpha2/local/lib/libcsage.so(sage_signal_handler+0x20e)[0x7fe2bbd11ae4]
/lib64/libpthread.so.0(+0xfee0)[0x7fe2c0fc5ee0]
/home/work/fbissey/sandbox/sage-4.7.2.alpha2/local/lib/python2.7/site-packages/sage/combinat/matrices/dancing_links.so(+0x847d)[0x7fe29b0c547d]

We go BOOM in sage-on-gentoo for the reason stated in the notes (0 rows).

comment:38 in reply to: ↑ 37 Changed 6 years ago by slabbe

sage-on-gentoo goes BOOM at

sage: x = dlx_solver(rows)

Would adding # not tested at the end of that line would be an acceptable fix ?

Should we open a ticket for it?

Sébastien

comment:39 Changed 6 years ago by fbissey

I am doing that right now in sage-on-gentoo. I suspect that in a vanilla sage install

 sage: x = dlx_solver(rows)

is left unevaluated and you only get a segfault when accessing x. The only thing that tells me that something else may happen is that I get a SIGABRT instead of a SIGSEGV. I don't think we need to open a new ticket or change this one for that matter. sage-on-gentoo doesn't have official status. I wanted to make a comment in case it prompted in insight. I suspect it may surface in vanilla sage sooner or later but it is difficult to know what is the trigger since I am applying a few tickets on top of 4.7.2.alpha2 plus a few custom hacks here and there.

comment:40 Changed 6 years ago by jdemeyer

Any Segmentation Fault, documented or not, is a bug. So I think this really points to a problem with the original patch. See #11814 for a follow-up.

Note: See TracTickets for help on using tickets.