fret icon indicating copy to clipboard operation
fret copied to clipboard

Realisability Checker Uncaught Exception

Open mluckcuck opened this issue 1 year ago • 17 comments

I've just tried out the Realisbility Checker on my laptop and had an Uncaught Exception from FRET, not sure what's happened.

Image

I'm running Ubuntu 22.04.5, Node version 20.18.1, and I've got z3 and kind2 (downloaded today), and I tried pulling FRET and it's already up to date.

As you can see form the screenshot, I made a very simple requirements set to try this one, because it did the same thing on a set I already had.

Any ideas what's happened here?

Thanks, Matt

mluckcuck avatar Jan 30 '25 19:01 mluckcuck

The screenshot above was from trying in Monolithic mode, it does the same thing in Compositional mode.

Attached is the (simple) requirements and variable mappings.

fretRequirementsVariables.json

mluckcuck avatar Jan 30 '25 19:01 mluckcuck

Thanks, Matt. @andreaskatis is looking into this.

anmavrid avatar Jan 30 '25 19:01 anmavrid

Hi @mluckcuck ,

This issue is related to a bug in Kind2's v2.2.0 release. There are two alternatives to fix it:

  1. Downgrade to the previous release of Kind 2, v2.1.1: https://github.com/kind2-mc/kind2/releases/tag/v2.1.1
  2. Build Kind 2 from source using the develop branch, which contains a fix.

Please let us know if either of the above works or not.

A couple more notes following from your example and setup:

  1. Both requirements are unrealizable. This is because you are trying to enforce the satisfaction of constraints over input variables. Typically, requirements that express expectations over inputs are meant to be declared as assumptions. In order to have the realizability checking analysis consider them as assumptions, you currently need to add the string assumption to the corresponding requirement ID (e.g., change REQ1 to REQ1_assumption).
  2. Your version of Node is more recent than the range of versions that we currently know that we support ( v16.16.x - v20.13.1 ). Just pointing it out in case you run into issues that may be related to it, as I do not think that we have tested v20.18.1 (I haven't).

Best Regards,

Andreas

andreaskatis avatar Jan 30 '25 20:01 andreaskatis

Thanks @andreaskatis (and @anmavrid ) for such a quick reply!

I'll try downgrading Kind2. But I've got the same version on my desktop machine (also Ubuntu 22.04.5 but, oddly, running FRET using Node version 12.22.9!) and a similar set of requirements works ok.

Perhaps it's related to your first note. I'm actually quite confused by the interaction between the realisability checker and the input/output variables in the variable mapping tab. So for the requirements set I've got here, I had just set them all to Input. The set on my desktop machine are a mix of inputs and outputs (in a way that seemed sensible to me) so maybe that is why it runs ok and doesn't cause the same exception.

I will go and try downgrading Kind2 and tweaking the variable types on my desktop and let you know.

mluckcuck avatar Jan 31 '25 11:01 mluckcuck

OK...

On my laptop, swapping to Node version 20.13.1 and then down to version 12.22.9 still cause the same error (with Kind2 unchanged). On my desktop, if I swap the four boolean variables to all be inputs (again, with the same version of Kind2) it does not throw this exception. (At least, I don't get the dialogue box warning me of the uncaught exception, and there is a nice green tick.)

Unfortunately, on my laptop after downgrading to Kind2 version 2.1.1 (and using Node 20.12.1) it still throws the exception. Again, on my desktop it's still fine.

Please let me know if you need some more information from me about these two setups.

mluckcuck avatar Jan 31 '25 11:01 mluckcuck

Hi Matt,

Thank you for all the information so far. I would suggest that we focus on issues that come up while only using v2.1.1 or the develop branch for the time being. Kind2's v2.2.0 has a couple of issues which can make things more confusing. One of these is the fact that the JSON output had a change (now reverted on develop) that can lead to wrong results being reported (the "nice green tick" in your comments suggests this, as the specific example is unrealizable). I will talk to the Kind 2 devs about this, to see if there is a more elegant solution to provide, other than asking people to use a different version of the tool.

So far, I have been unable to replicate the unhandled exception error while running 2.1.1, using Node 20.13.1. The example is declared unrealizable (which is the correct result) and the diagnosis completes successfully. This is true for both the compositional and monolithic analysis options.

When you changed versions, did you make sure that the new version is what FRET has access to? This would normally mean that you'd need to update the path to the Kind 2 binary in your PATH environment variable.

Best Regards,

Andreas

andreaskatis avatar Jan 31 '25 16:01 andreaskatis

Hi @andreaskatis

I'm trying this again on my laptop and it gives the same Javascript error as before. I've set it to use Node 20.13.1 and Kind2 2.1.1 (on Ubuntu 20.04.5).

I've tried it in dev mode (npm run dev) and the only error I get on the console is a warning about the 'ResultIcon' being 'undefined', which doesn't seem to relate to the Javascript error.

I've also tried Kind2 versions down to 1.9.0 and the new version (2.3.0) with the same result. When changing versions I've been deleting the directory that is on the path 'kind2', extracting the Kind2 version from its tar.gz file, and renaming the directory 'kind2', then checking at the terminal that running kind2 shows the version number I'm expecting.

mluckcuck avatar Mar 12 '25 12:03 mluckcuck

Hi @mluckcuck ,

I still haven't been able to replicate this. Could you please share with me the Lustre file that is generated for the analysis where this issue occurs? To do so you need to follow the steps below:

  1. Head into the Realizability tab for the project in question, then click 'Actions->Change Settings' and enable the 'Retain Analysis Files' option.
  2. Run the analysis.
  3. Share with me here the '.lus' files that you'll find under '~/Documents/fret-analysis'. If the component's name is still 'Tank', the Lustre file(s) should have a 'TankSpec' prefix in their file name.

Best,

Andreas

andreaskatis avatar Mar 12 '25 14:03 andreaskatis

Thanks for taking a look at this @andreaskatis I appreciate your effort for this weird error I'm getting.

I had to zip TankSpec.lus because GitHub would not allow a .lus file: TankSpec.zip

I used the same project as I had originally attached in my second comment.

Please let me know if you need any more details.

mluckcuck avatar Mar 12 '25 17:03 mluckcuck

Thank you, Matt.

The file is identical to the one that is generated from my attempts. Let's try to take a deeper look and see what Kind 2's output is when running it. To do so, you'd have to follow the steps below:

  1. Change directory to the location of 'TankSpec.lus'
  2. Run the following command:
    kind2 -json --enable CONTRACTCK --lus_main TankSpec TankSpec.lus > TankSpec.json
    
  3. Send me a copy of the generated TankSpec.json file from step 2.

Best,

Andreas

andreaskatis avatar Mar 12 '25 22:03 andreaskatis

hi @andreaskatis and @mluckcuck,

What is the status of this?

anmavrid avatar Apr 03 '25 03:04 anmavrid

Still waiting on Matt's input on this. An alternative now is to try FRET v3.0 and see whether any of the related changes to realizability checking might have helped with this issue. As it currently stands I've been unable to replicate it with the information I have.

andreaskatis avatar Apr 03 '25 12:04 andreaskatis

Thanks, Andreas.

@mluckcuck please let us know if the problem persists.

anmavrid avatar Apr 03 '25 18:04 anmavrid

Thank you, Matt.

The file is identical to the one that is generated from my attempts. Let's try to take a deeper look and see what Kind 2's output is when running it. To do so, you'd have to follow the steps below:

1. Change directory to the location of 'TankSpec.lus'

2. Run the following command:
   ```
   kind2 -json --enable CONTRACTCK --lus_main TankSpec TankSpec.lus > TankSpec.json
   ```

3. Send me a copy of the generated `TankSpec.json` file from step 2.

Best,

Andreas

Sorry, I forgot about this because teaching started.

The exception still happens, but only on my laptop.

I've run the command you suggested @andreaskatis and I've attached the file: TankSpec.json There is a line at the end of this file "value" : "Runtime error in contract checker: Unix.Unix_error(Unix.EACCES, 'create_process', '/home/matt/bin/z3')"

But z3 runs from the terminal:

Image

And is on the path (/home/matt/bin/z3/bin which contains the z3 executable)

And FRET doesn't complain that it can't be found (like it does if the dependencies aren't on the path):

Image

mluckcuck avatar Apr 04 '25 09:04 mluckcuck

Thanks, Matt. It's evident that Kind 2 is unable to access Z3 for some reason. The UNIX error mentioned in the .JSON file leads me to believe that this is some sort of read permissions issue, where Kind 2 is unable to read (part of) Z3's path.

If that's the case then it can be difficult to replicate this as it relates to the specific configuration of your environment. It could be as simple as /home/matt/bin/ not being given sufficient read permissions. Or it could be that the specific user matt or permissions group does not have read access. Some things to try towards figuring this out in the meantime:

  1. Ensure that z3 -h shows the same output when it is run from any directory, not just within /home/matt/bin , as in your screenshot.

  2. Try moving the Z3 binary to a different directory other than bin, and update the corresponding path in the PATH environmental variable. Ensure that z3 -h works from any random directory as it works in your second-to-last screenshot. Run the kind2 command I provided above again and see whether the output has changed and that no error is reported in the JSON file.

  3. Observe the output of running ls -l /home/matt. What does the /bin line contain? Is matt being mentioned as the owner of the folder? If not, try changing it by running

       sudo chown -R matt /home/matt/bin
    

I'll try to replicate this over the weekend to see if I can give you some more pointers, but the exact fix for your issue ultimately depends on the specific OS's configuration.

Best,

Andreas

andreaskatis avatar Apr 04 '25 14:04 andreaskatis

I seemed to have fixed this...

z3 would run from anywhere, because it was on my PATH. I was also the owner of bin and the z3 directory.

As a mad idea, I tried decompressing the z3 zip file again and not changing the name. As you can see below, both directories have the same permissions Image

When I update the PATH to point to /home/matt/bin/z3-4.13.4-x64-glibc-2.35/bin instead of /home/matt/bin/z3/bin and delete the z3 folder...it works again.

So, I suppose the lesson is: don't try to save yourself a bit of typing by renaming the z3 directory!

It might just be worth putting this into the troubleshooting page, though. Just in case it happens to anyone else (or me again, after I've forgotten the lesson). Thanks for your help in narrowing down the problem.

mluckcuck avatar Apr 04 '25 16:04 mluckcuck

Thanks, Matt. I'm glad you found a solution. It's strange that the folder name was causing this. Perhaps it's something I'll have to share with Kind 2 developers, since neither your environment nor FRET had trouble finding Z3 with your old configuration. We will add a note about this in our manual, regardless.

Closing the issue as resolved.

andreaskatis avatar Apr 04 '25 17:04 andreaskatis