Skip to content

Commit

Permalink
When calling the worker, we must ensure the native code is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
pkriens committed Mar 19, 2024
1 parent 0056bf6 commit bff6ace
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ public void _commands(CommandsOptions options) throws Exception {
String filename = options._arguments().remove(0);
Map<String, String> cache = new HashMap<>();
CompModule world = CompUtil.parseEverything_fromFile(rep, cache, filename);
int n = 0;
for (Command c : world.getAllCommands()) {
stdout.println(c);
stdout.printf("%-2d. %s%n",n++,c);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.alloytools.alloy.core.AlloyCore;
import org.alloytools.alloy.core.infra.Alloy;

import kodkod.engine.satlab.SATFactory;
import kodkod.solvers.api.NativeCode;

/**
Expand Down Expand Up @@ -262,6 +263,7 @@ public static void runLocally(final WorkerTask task, final WorkerCallback callba
* to it
*/
public static void run(final WorkerTask task, int newmem, int newstack, String classPath, final WorkerCallback callback) throws IOException {
SATFactory.getSolvers(); // init native code
String java = "java";
String javahome = System.getProperty("java.home");
if (javahome == null)
Expand Down Expand Up @@ -304,9 +306,12 @@ public static void run(final WorkerTask task, int newmem, int newstack, String c
String debug = AlloyCore.isDebug() ? "yes" : "no";
String main = Alloy.class.getName();

sub = Runtime.getRuntime().exec(new String[] {
java, "-Xmx" + newmem + "m", "-Xss" + newstack + "k", "-Djava.library.path=" + NativeCode.getLibraryPath(), "-Ddebug=" + debug, "-cp", classPath, WorkerEngine.class.getName(), Version.buildDate(), "" + Version.buildNumber()
});
String[] cmdline = new String[] {
java,
// "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5006",
"-Xmx" + newmem + "m", "-Xss" + newstack + "k", "-Djava.library.path=" + NativeCode.getLibraryPath(), "-Ddebug=" + debug, "-cp", classPath, WorkerEngine.class.getName(), Version.buildDate(), "" + Version.buildNumber()
};
sub = Runtime.getRuntime().exec(cmdline);
latest_sub = sub;
} else {
sub = latest_sub;
Expand Down Expand Up @@ -403,20 +408,7 @@ public void uncaughtException(Thread t, Throwable e) {
System.setErr(new PrintStream(wrap((OutputStream) null)));
final FileInputStream in = new FileInputStream(FileDescriptor.in);
final FileOutputStream out = new FileOutputStream(FileDescriptor.out);
// Preload these 3 libraries; on MS Windows with JDK 1.6 this seems to
// prevent freezes
try {
System.loadLibrary("minisat");
} catch (Throwable ex) {
}
try {
System.loadLibrary("minisatprover");
} catch (Throwable ex) {
}
try {
System.loadLibrary("zchaff");
} catch (Throwable ex) {
}

// Now we repeat the following read-then-execute loop
Thread t = null;
while (true) {
Expand Down
Loading

0 comments on commit bff6ace

Please sign in to comment.