Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I'm having some unexpected errors with YASWI http://search.cpan.org/~salva/Language-Prolog-Yaswi-0.18/Yaswi.pm. When I call YASWI with a Perl Module, exit that module, and then navigate into another module, I get:

[PROLOG SYSTEM ERROR: Thread 1 Recursively received fatal signal 11 PROLOG STACK: ] [pid=2788] Action? a

On Googling this error there are a number of sites which recommend including the line:

swi_init('-nosignals');

So I include this, or even the more comprehensive:

swi_init("pl", "-g", "true", "-nosignals");

And to both, I get:

Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 5.6.64) Copyright (c) 1990-2008 University of Amsterdam. SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details. For help, use ?- help(Topic). or ?- apropos(Word). % /home/steve/Documents/i_prolog.pl compiled 0.00 sec, 30,056 bytes SWI-Prolog engine already initialised at /usr/local/lib/perl/5.10.0/La +nguage/Prolog/Yaswi/Low.pm line 63.

My calling code looks like this:

#!/usr/bin/perl -w use strict; package i_observation; use Wx 0.15 qw[:allclasses]; use strict; use warnings; use Wx qw[:everything]; use Wx::Event qw( EVT_MENU ); use base qw(Wx::Frame); use Carp qw(croak); use threads (); # Used for mult +i-tasking ffmpeg use Threads; # Used in Timer to + determine state of tasks use base qw(Wx::Panel Class::Accessor::Fast); use base qw(Wx::PlComboPopup); __PACKAGE__->mk_ro_accessors( qw(html_help chm_help comboctrl) ); use Wx::Locale( gettext => 't'); use Language::Prolog::Yaswi qw(:load :run :query); use Language::Prolog::Types::overload; use Language::Prolog::Sugar functors => {location_organ => 'location_organ', location_segment => 'location_segment', listsegments => 'listsegments', listwalls => 'listwalls', diagnosis => 'diagnosis' }, chains => { orn => ';', andn => ',', add => '+' }, vars => [qw (X Y Z)]; . . . # other routines in the package . . . sub set_location_list{ . . . . my @files = (t("/home/steve/Documents/i_prolog.pl")); swi_init("pl", "-g", "true", "-nosignals"); # Or swi_init("-nosign +als"); swi_consult @files; . . . }

I've also tried

swi_cleanup();

After every Prolog call. In the hope that it would close down the prolog engine and therefore remove the problem. To no avail, in fact it gives me another error.

Use of uninitialized value in subroutine entry at i_observation.pm line 511.

While not resolving the initial problem.

Any insight would be invaluable.

Regards

Steve

Replies are listed 'Best First'.
Re: YASWI "Prolog System Error: Thread 1"
by salva (Canon) on Jan 19, 2010 at 14:10 UTC
    sub set_location_list{ ... my @files = (t("/home/steve/Documents/i_prolog.pl")); swi_init("pl", "-g", "true", "-nosignals"); # Or swi_init("-nosign +als"); swi_consult @files; ... }
    Try moving swi_init(...) outside of the sub in order to get it executed just once.

    I've also tried swi_cleanup() after every Prolog call.

    swi_cleanup() is not fully implemented by the SWI-Prolog engine (though the error you are getting probably indicates a bug in L::P::Yaswi) so its usage should be avoided.

    File a bug report on the CPAN RT site including a minimal script that triggers it (both perl and prolog code), your OS, Perl and Prolog versions and compilation options and any other pertinent details about your environment (for instance, if you are running it under mod_perl).

    I would try to reproduce and solve any error.

      Hi Salva

      Thanks for this, I'll try it out. Do you prefer:

      swi_init("pl", "-g", "true", "-nosignals");

      or

      swi_init("-nosignals");

      regards

      Steve

        IIRC, the right combination is...
        swi_init(qw(-nosignals -g true))
        The -g true part serves to silence the welcome banner generated by default by the Prolog engine.

      Hi Salva

      Well after a few version control problems of my own making, we're back to a stable system.

      I've implemented the line you suggest at the beginning of the module (.pm file). However, I'm not sure that it's the optimum way. This is what it looks like now:

      updated

      #!/usr/bin/perl -w use strict; package i_observation; ######################delete block ########################## use Wx 0.15 qw[:allclasses]; use strict; use warnings; use Wx qw[:everything]; use Wx::Event qw( EVT_MENU ); use base qw(Wx::Frame); use threads (); # Used for mult +i-tasking ffmpeg use Threads; # Used in Timer to + determine state of tasks use base qw(Wx::Panel Class::Accessor::Fast); __PACKAGE__->mk_ro_accessors( qw(html_help chm_help comboctrl) ); use Language::Prolog::Yaswi qw(:load :run :query); use Language::Prolog::Types::overload; use Language::Prolog::Sugar functors => {location_organ => 'location_organ', location_segment => 'location_segment', listsegments => 'listsegments', listwalls => 'listwalls', diagnosis => 'diagnosis' }, chains => { orn => ';', andn => ',', add => '+' }, vars => [qw (X Y Z)]; swi_init(qw(-nosignals -g true)); sub new{ . . . # other routines in the package . . . sub set_location_list{ . . . . my @files = (t("/home/steve/Documents/i_prolog.pl")); swi_consult @files; . . . }

      So, it's not clear to me when the code before any routines gets executed. The error now is:

      % /home/steve/Documents/i_prolog.pl compiled 0.00 sec, 32,784 bytes % /home/steve/Documents/i_prolog.pl compiled 0.00 sec, 0 bytes % /home/steve/Documents/i_prolog.pl compiled 0.00 sec, -232 bytes

      So it looks as though it is called three times. UPDATE: Actually these messages come way before the crash now. There is no crash message at all, so I need to step through the code and find the crash. It may not be Prolog related. Sorry for the confusion.

      Regards

      Steve

        So, it's not clear to me when the code before any routines gets executed. The error now is:
        % /home/steve/Documents/i_prolog.pl compiled 0.00 sec, 32,784 bytes

        This is not an error, just a message telling you the Prolog module i_prolog.pl has been loaded. If you get it several times it is probably because you are calling set_location_list() repeatedly.

        Without seeing the full source code of your application I can only guess, and maybe there are some real bugs on the module annoying you, but it seems to me that the actual problem is that you don't got it yet. You should become more familiar with the module and Prolog and how they work together before trying to use them inside a complex application.