AlloyTools / org.alloytools.alloy

Alloy is a language for describing structures and a tool for exploring them. It has been used in a wide range of applications from finding holes in security mechanisms to designing telephone switching networks. This repository contains the code for the tool.
Other
695 stars 124 forks source link

Invalid paths in system path cause the application to crash on startup #180

Closed loriswit closed 1 year ago

loriswit commented 2 years ago

For some reason, I have this invalid path in my PATH environnement variable (note that DISABLED- is part of the variable value):

DISABLED-C:\Program Files\Docker\Docker\resources\bin

This causes the program to crash on startup. Here's the stack trace:

class java.nio.file.InvalidPathException: Illegal char <:> at index 10: DISABLED-C:\Program Files\Docker\Docker\resources\bin
java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
java.base/java.nio.file.Path.of(Path.java:147)
java.base/java.nio.file.Paths.get(Paths.java:69)
edu.mit.csail.sdg.alloy4whole.PreferencesDialog.staticLibrary(PreferencesDialog.java:349)
edu.mit.csail.sdg.alloy4whole.PreferencesDialog.testSolvers(PreferencesDialog.java:294)
edu.mit.csail.sdg.alloy4whole.PreferencesDialog.<init>(PreferencesDialog.java:264)
edu.mit.csail.sdg.alloy4whole.SimpleGUI.finishInit(SimpleGUI.java:2277)
edu.mit.csail.sdg.alloy4whole.SimpleGUI.<init>(SimpleGUI.java:2133)
edu.mit.csail.sdg.alloy4whole.SimpleGUI.<init>(SimpleGUI.java:201)
edu.mit.csail.sdg.alloy4whole.SimpleGUI$7.run(SimpleGUI.java:1987)
java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

The exception seems to be thrown when calling Path.get(str) in this file: https://github.com/AlloyTools/org.alloytools.alloy/blob/1fa2626e97b0d6a8b616ae207d668e9d8a28a4a3/org.alloytools.alloy.application/src/main/java/edu/mit/csail/sdg/alloy4whole/PreferencesDialog.java#L348-L356

I suppose this could be easily fixed by checking whether the path is valid before calling that function, or by catching the exception.

Alloy version: 6.1.0.202111031525 Java version: OpenJDK 18.0.1 OS: Windows 10 21H2