restart not working in new version of wsl (Ubuntu 16.04 on windows 10)

331 views
Skip to first unread message

KSchwede

unread,
May 29, 2017, 2:33:01 PM5/29/17
to Macaulay2
Hi all,

I haven't tried to fix this myself, or even recompile it myself, but anyway, here's a bug report.

In the new version of the WSL (Windows Subsystem for Linux) which installs Ubuntu 16.04 (you can install it if you upgrade to the new Windows 10 Creator Edition), many things work basically out of the box.  

You can install VcXsrv and essentially run X windows programs (like emacs) without any hassle (make sure to add export DISPLAY=:0.0 to your .bashrc file).  Macaulay2 seems to run fine too (as it did in the older WSL systems) if you simply follow the install instructions from 


(for Ubuntu 16.04).

However, I found a somewhat weird bug.  

Running 

restart

from within Macaulay2 (either from the command line or from emacs) causes the following error.

stdio:1:1:(3): error: after eval: exec failed

I've verified this on two different clean installs of the WSL on two different systems (using the latest version of Windows 10). 

If I get a chance tonight, I'll try to recompile bleeding edget Macaulay2 from source on these systems to see if that fixes it.  On the other hand, this is probably the simplest way I've seen to get M2 up and running on Windows, even easier than a VM.

KSchwede

unread,
May 29, 2017, 8:10:23 PM5/29/17
to Macaulay2
Some additional information.  The same behavior also occurs when compiling the bleeding edge version from scratch.

corey harris

unread,
May 31, 2017, 5:26:09 AM5/31/17
to Macaulay2
I also have this problem.  The exec command seems not to be working at all...

i1 : exec("ls")
stdio:1:1:(3): error: exec failed

Brian Pike

unread,
May 31, 2017, 10:02:54 PM5/31/17
to maca...@googlegroups.com
Does it work if you use a full path name in M2's exec?:
  exec("/bin/ls")

Does it work if you do this in M2?:
  exec("M2-binary")

(On Linux, 'M2' is a shell script that sets an environment variable and then executes M2-binary.  Maybe it's having trouble executing a shell script?)

At a bash prompt, the following might be useful.  Set the environment variable LD_LIBRARY_PATH so it includes the directory containing the libpari-gmp.* library, something like this, but specific to your system:
  export LD_LIBRARY_PATH=/usr/lib/Macaulay2/x86_64-Linux-Debian-8.5/lib:$LD_LIBRARY_PATH
(It may be helpful to look at the script 'M2' here; it finds the type of the system and on Linux falls back to the default case.)  Then run something like:
  strace -f /usr/bin/M2-binary -e 'exec("/bin/ls")' 2>&1 |grep exec
This will at least show us the exact system call that's being made to WSL  You could also try
  strace -f /usr/bin/M2-binary -e 'restart()' 2>&1 |grep exec

Thanks,
Brian

--
You received this message because you are subscribed to the Google Groups "Macaulay2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to macaulay2+unsubscribe@googlegroups.com.
To post to this group, send email to maca...@googlegroups.com.
Visit this group at https://groups.google.com/group/macaulay2.
For more options, visit https://groups.google.com/d/optout.

KSchwede

unread,
Jun 1, 2017, 9:26:42 PM6/1/17
to Macaulay2
Full path (   exec("/bin/ls") and exec("M2-binary")   ) do not work either, they return:

stdio:1:1:(3): error: exec failed

From bash prompt I ran:

export LD_LIBRARY_PATH=/usr/lib/Macaulay2/x86_64-Linux-Ubuntu-16.04/lib/:$LD_LIBRARY_PATH

that didn't help with M2.  When I ran

 strace -f /usr/bin/M2-binary -e 'exec("/bin/ls")' 2>&1 |grep exec

I got:  

execve("/usr/bin/M2-binary", ["/usr/bin/M2-binary", "-e", "exec(\"/bin/ls\")"], [/* 20 vars */]) = 0
[pid   195] execve("/usr/bin/M2-binary", ["/usr/bin/M2-binary", "-e", "exec(\"/bin/ls\")"], [/* 20 vars */] <unfinished ...>
<... execve resumed> )                  = 0
[pid   202] execve("/bin/ls", ["/bin/ls"], [/* 20 vars */]) = -1 ENOMEM (Cannot allocate memory)
[pid   202] write(2, "currentString:1:1:(3):[3]: error"..., 46currentString:1:1:(3):[3]: error: exec failed
exec("/bin/ls")

Likewise

 strace -f /usr/bin/M2-binary -e 'restart()' 2>&1 |grep exec

produces

execve("/usr/bin/M2-binary", ["/usr/bin/M2-binary", "-e", "restart()"], [/* 19 vars */]) = 0
[pid    58] execve("/usr/bin/M2-binary", ["/usr/bin/M2-binary", "-e", "restart()"], [/* 19 vars */] <unfinished ...>
<... execve resumed> )                  = 0
[pid    65] execve("/usr/bin/M2-binary", ["/usr/bin/M2-binary", "--restarted", "-e", "restart()"], [/* 19 vars */]) = -1 ENOMEM (Cannot allocate memory)
[pid    65] write(2, "/usr/share/Macaulay2/Core/system"..., 70/usr/share/Macaulay2/Core/system.m2:14:11:(1):[5]: error: exec failed
          exec if member("--restarted",commandLine) then commandLine else join({commandLine#0,"--restarted"},drop(commandLine,1))

Thanks for the help!

Best wishes,

Karl
To unsubscribe from this group and stop receiving emails from it, send an email to macaulay2+...@googlegroups.com.

Brian Pike

unread,
Jun 2, 2017, 9:17:46 PM6/2/17
to maca...@googlegroups.com
The "ENOMEM" error you're getting indicates that WSL thinks it doesn't have enough memory to start the program (either 'ls' or 'M2-binary').  That sounds like a WSL bug, and it looks like similar issues have been reported:
    https://github.com/Microsoft/BashOnWindows/issues/1734
    https://github.com/Microsoft/BashOnWindows/issues/1286
and fixed:
    https://github.com/Microsoft/BashOnWindows/issues/851#issuecomment-264314420
in some newer versions of WSL (look for "GH #1286"):
    https://msdn.microsoft.com/en-us/commandline/wsl/release_notes#build-15002

A workaround seems to be to reduce memory usage elsewhere, and/or make your page file excessively large, like 16 gigabytes.  I'd be very interested to hear if that fixes the problem.

Thanks,
Brian

To unsubscribe from this group and stop receiving emails from it, send an email to macaulay2+unsubscribe@googlegroups.com.

KSchwede

unread,
Jun 5, 2017, 12:55:54 AM6/5/17
to Macaulay2
I'm already on the creators edition, but it doesn't seem to be fixed there, and i already have a 16gb page file on at least one of the machines I'm testing it on and that doesn't seem to be enough.  Hopefully this will be fixed in the future.  

Thanks,

Karll

KSchwede

unread,
Jun 5, 2017, 1:22:08 AM6/5/17
to Macaulay2
Actually, I wonder if the new fixes in regards to memory in the creator edition broke this.  In particular, I think this didn't occur for M2 installed on the old WSL.

Karl

KSchwede

unread,
Feb 15, 2019, 11:07:14 AM2/15/19
to Macaulay2
Just another update on this.  It really looks like it can't find part of the garbage collector when calling exec.  I seem to have the file libgc.so.1 but not libgc.so.2

Currently 

strace -f /usr/bin/M2-binary -e 'exec("/bin/ls")' 2>&1 |more

yields

execve("/usr/bin/M2-binary", ["/usr/bin/M2-binary", "-e", "exec(\"/bin/ls\")"], [/* 24 vars */]) = 0
brk(NULL)                               = 0x2bfa000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/x86_64/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls/x86_64", 0x7fffc8d5cd70) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls", 0x7fffc8d5cd70)    = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64", 0x7fffc8d5cd70) = -1 ENOENT (No such file or directory)
open("/usr/lib/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=512, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=89516, ...}) = 0
mmap(NULL, 89516, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f6abb525000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/x86_64/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls/x86_64", 0x7fffc8d5cd70) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls", 0x7fffc8d5cd70) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/x86_64/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/x86_64", 0x7fffc8d5cd70) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=512, ...}) = 0
open("/usr/lib/x86_64-linux-gnu/tls/x86_64/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls/x86_64", 0x7fffc8d5cd70) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls", 0x7fffc8d5cd70) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/x86_64/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/x86_64", 0x7fffc8d5cd70) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=512, ...}) = 0
open("/lib/tls/x86_64/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls/x86_64", 0x7fffc8d5cd70) = -1 ENOENT (No such file or directory)
open("/lib/tls/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls", 0x7fffc8d5cd70)        = -1 ENOENT (No such file or directory)
open("/lib/x86_64/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64", 0x7fffc8d5cd70)     = -1 ENOENT (No such file or directory)
open("/lib/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib", {st_mode=S_IFDIR|0755, st_size=512, ...}) = 0
open("/usr/lib/libgc.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
writev(2, [{"/usr/bin/M2-binary", 18}, {": ", 2}, {"error while loading shared libra"..., 36}, {": ", 2}, {"libgc.so.2", 10}, {": ", 2}, {"cannot open shared object file", 30}, {": ", 2}, {"No such file or directory", 25}, {"\n", 1}], 10/usr/bin/M2-binary: error while loading shared libraries: libgc.so.2: cannot open shared object file: No such file or directory
) = 128
exit_group(127)                         = ?
+++ exited with 127 +++

Daniel R. Grayson

unread,
Feb 23, 2019, 2:01:55 PM2/23/19
to Macaulay2
The executable file M2-binary does indeed depend on libgc.so.2, but it's the job of the shell script M2 to
add the directory /usr/lib/Macaulay2/lib to the search path so it can find it there.  That's why you can't
run M2-binary directly.  You can fix the path yourself with this bash command:

export LD_LIBRARY_PATH=/usr/lib/Macaulay2/lib:$LD_LIBRARY_PATH

KSchwede

unread,
Sep 29, 2019, 3:34:58 PM9/29/19
to Macaulay2
Just a quick additional bit of information, on WSL2 (from windows insider), this works by default.  But on the regular WSL, you should do what's below.
Reply all
Reply to author
Forward
0 new messages