mthom / scryer-prolog

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

Scryer silently exits #2248

Open dougransom opened 6 months ago

dougransom commented 6 months ago

Scryer 0.93 windows exists after a second consult:

PS C:\Users\doug\code\life> scryer-prolog.exe 
?- consult(life).
   error(permission_error(modify,static_procedure,bagof/3),load/1).
?- consult(life).
PS C:\Users\doug\code\life> 

See attached.

life.pl.txt

flexoron commented 6 months ago
Here:
offset_coords(Coords) :  bagof(X-Y,offset_coord(X-Y),Coords).
Should be:
offset_coords(Coords) :-  bagof(X-Y,offset_coord(X-Y),Coords).
dougransom commented 6 months ago

Thanks! Probably obvious to most. Still Scryer probably shouldn't just exit, maybe a more verbose error could be displayed?

bakaq commented 6 months ago

~I can reproduce this in the latest master in Linux.~ The "silent exit" is actually a segmentation fault. In Linux your shell actually reports this, so it's not really "silent", it's just the program crashing. But yeah, Scryer shouldn't segfault because of this. Good catch, even though it was found by a typo.

flexoron commented 6 months ago
Well, I can't reproduce this in Linux:

$ scryer-prolog/target/release/scryer-prolog -v
v0.9.3-119-g42d67495-modified

?- consult(life).
   error(permission_error(modify,static_procedure,(',')/2),load/1).
?- consult(life).
   error(permission_error(modify,static_procedure,(',')/2),load/1).
?- consult(life).
   error(permission_error(modify,static_procedure,(',')/2),load/1).
?- halt.
bakaq commented 6 months ago

@flexoron, I think you are using the file from the other issue.

flexoron commented 6 months ago
Nope...tested with both:
#offset_coords :  bagof(X-Y,offset_coord(X-Y),Bag),Bag.
offset_coords(Coords) :  bagof(X-Y,offset_coord(X-Y),Coords).
dougransom commented 6 months ago

I didn't realize windows would swallow the error (or powershell anyway). Nothing is written to stderr, or windows is hiding stderr?

PS C:\Users\doug\code\life> Get-Error

Exception             :
    Type                 : System.Management.Automation.ItemNotFoundException
    ErrorRecord          :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Cannot find path 'C:\Users\doug\life' because it does not exist.
            HResult : -2146233087
        TargetObject          : C:\Users\doug\life
        CategoryInfo          : ObjectNotFound: (C:\Users\doug\life:String) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : PathNotFound
    ItemName             : C:\Users\doug\life
    SessionStateCategory : Drive
    TargetSite           :
        Name          : ExpandMshGlobPath
        DeclaringType : System.Management.Automation.LocationGlobber, System.Management.Automation,
Version=7.3.10.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message              : Cannot find path 'C:\Users\doug\life' because it does not exist.
    Source               : System.Management.Automation
    HResult              : -2146233087
    StackTrace           :
   at System.Management.Automation.LocationGlobber.ExpandMshGlobPath(String path, Boolean allowNonexistingPaths,
PSDriveInfo drive, ContainerCmdletProvider provider, CmdletProviderContext context)
   at System.Management.Automation.LocationGlobber.ResolveDriveQualifiedPath(String path, CmdletProviderContext
context, Boolean allowNonexistingPaths, CmdletProvider& providerInstance)
   at System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String path, Boolean
allowNonexistingPaths, CmdletProviderContext context, CmdletProvider& providerInstance)
   at System.Management.Automation.SessionStateInternal.SetLocation(String path, CmdletProviderContext context,
Boolean literalPath)
   at Microsoft.PowerShell.Commands.SetLocationCommand.ProcessRecord()
TargetObject          : C:\Users\doug\life
CategoryInfo          : ObjectNotFound: (C:\Users\doug\life:String) [Set-Location], ItemNotFoundException
FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
InvocationInfo        :
    MyCommand        : Set-Location
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 6
    Line             : cd life
    PositionMessage  : At line:1 char:1
                       + cd life
                       + ~~~~~~~
    InvocationName   : cd
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

PS C:\Users\doug\code\life>

bakaq commented 6 months ago

or windows is hiding stderr?

Segmentation faults aren't written to stderr as far as I know, it's just the shell that notices that a program has crashed and reports it for you. Also, I think segmentation faults are a Linux/Unix only thing. Maybe there is an equivalent in Windows, but maybe it doesn't have the same name.

bakaq commented 6 months ago

I actually can't reproduce this either in the actual current master. (Note to self: Test things in the actual master instead of 3 commits back)

It seems that commit 42d674950197882817e38d610de59f9d0cffa390 also solved this for some reason, at least on Linux. I think you can close this @dougransom, but it would be better if you could check if this still happens on Windows, although this would mean you would need to compile Scryer from source.

dougransom commented 6 months ago

or windows is hiding stderr?

Segmentation faults aren't written to stderr as far as I know, it's just the shell that notices that a program has crashed and reports it for you. Also, I think segmentation faults are a Linux/Unix only thing. Maybe there is an equivalent in Windows, but maybe it doesn't have the same name.

There is the windows event log:

Log Name:      Application
Source:        Application Error
Date:          2023-12-26 6:06:15 PM
Event ID:      1000
Task Category: Application Crashing Events
Level:         Error
Keywords:      
User:          SHETLAND\doug
Computer:      shetland
Description:
Faulting application name: scryer-prolog.exe, version: 0.0.0.0, time stamp: 0x654431ca
Faulting module name: scryer-prolog.exe, version: 0.0.0.0, time stamp: 0x654431ca
Exception code: 0xc0000005
Fault offset: 0x00000000002b33bf
Faulting process id: 0x0x9B34
Faulting application start time: 0x0x1DA3860A8E3417E
Faulting application path: C:\Users\doug\bin\scryer-prolog.exe
Faulting module path: C:\Users\doug\bin\scryer-prolog.exe
Report Id: 276ade5a-a8b6-4243-a27d-ae7cc05e8fb7
Faulting package full name: 
Faulting package-relative application ID: 
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Application Error" Guid="{a0e9b465-b939-57d7-b27d-95d8e925ff57}" />
    <EventID>1000</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>100</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8000000000000000</Keywords>
    <TimeCreated SystemTime="2023-12-27T02:06:15.0221158Z" />
    <EventRecordID>199761</EventRecordID>
    <Correlation />
    <Execution ProcessID="10896" ThreadID="29712" />
    <Channel>Application</Channel>
    <Computer>shetland</Computer>
    <Security UserID="S-1-5-21-1416036011-906162167-2199275194-1001" />
  </System>
  <EventData>
    <Data Name="AppName">scryer-prolog.exe</Data>
    <Data Name="AppVersion">0.0.0.0</Data>
    <Data Name="AppTimeStamp">654431ca</Data>
    <Data Name="ModuleName">scryer-prolog.exe</Data>
    <Data Name="ModuleVersion">0.0.0.0</Data>
    <Data Name="ModuleTimeStamp">654431ca</Data>
    <Data Name="ExceptionCode">c0000005</Data>
    <Data Name="FaultingOffset">00000000002b33bf</Data>
    <Data Name="ProcessId">0x9b34</Data>
    <Data Name="ProcessCreationTime">0x1da3860a8e3417e</Data>
    <Data Name="AppPath">C:\Users\doug\bin\scryer-prolog.exe</Data>
    <Data Name="ModulePath">C:\Users\doug\bin\scryer-prolog.exe</Data>
    <Data Name="IntegratorReportId">276ade5a-a8b6-4243-a27d-ae7cc05e8fb7</Data>
    <Data Name="PackageFullName">
    </Data>
    <Data Name="PackageRelativeAppId">
    </Data>
  </EventData>
</Event>
bakaq commented 6 months ago

Yeah, I don't know much about Windows, but there are lots of "Fault" in this event log you shared. Scryer is clearly crashing.