mthom / scryer-prolog

A modern Prolog implementation written mostly in Rust.
BSD 3-Clause "New" or "Revised" License
2k stars 117 forks source link

Rebis: Ctrl-c sometimes yields segmentation fault #823

Closed triska closed 3 years ago

triska commented 3 years ago

Thanks to support of the discontiguous/1 directive, the simple timetabling engine Simsttab now runs nicely with the rebis-dev branch.

To reproduce this issue, please clone the git repository, and try it for example with:

$ scryer-prolog simsttab.pl reqs.pl

and posting the query:

?- requirements_variables(Rs, Vs), labeling([ff], Vs), print_classes(Rs).

yielding, after a few minutes:

Class: 1a

  Mon     Tue     Wed     Thu     Fri   
========================================
          mat     mat     mat     mat   
          ume     ume     nej     nej   
  mat     anj     anj     rai     rai   
  anj     atvz    geo     zgo     zgo   
  atvz    bio     kem     atvz    geo   
  sjk     sjk     sjk     bio     kem   
  nej     fiz     sjk     fiz           

Class: 1b

  Mon     Tue     Wed     Thu     Fri   
========================================
  mat     mat     mat     mat     mat   
  anj     nej     nej     geo     nej   
  ume     fiz     zgo     zgo     atvz  
  ...

However, I noticed that pressing Ctrl-c at inopportune times while the files are being loaded sometimes (in fact, quite rarely) yields a crash or error. I noticed this first in cases when a non-existent file is specified on the command line, for example in:

$ scryer-prolog simsttab.pl reqs_example.
^Cthread 'main' panicked at 'internal error: entered unreachable code', src/machine/code_repo.rs:27:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Note that reqs_example. does not exist in the directory, though I do not know whether that is relevant to reproduce this issue.

I also got:

$ scryer-prolog simsttab.pl reqs_example.
^CSegmentation fault: 11

To reproduce this, please run Scryer Prolog with:

$ scryer-prolog simsttab.pl reqs_example.

and then press Ctrl-c at various points before the toplevel prompt appears. It would of course be great to have a more reproducible test case, and I would greatly appreciate all input.

The expected result, and in fact the one I most often (but not always) get, is:

$ scryer-prolog simsttab.pl reqs_example.
^C
caught: error('$interrupt_thrown',repl)

caught: error(existence_error(source_sink,'reqs_example..pl'),open/4)
triska commented 3 years ago

Perfect, thank you a lot!