Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala compilation hangs #90

Closed
hermanzdosilovic opened this issue May 2, 2020 · 6 comments
Closed

Scala compilation hangs #90

hermanzdosilovic opened this issue May 2, 2020 · 6 comments

Comments

@hermanzdosilovic
Copy link
Contributor

Hi,

I am trying to compile a simple Scala hello, world program with isolate.

To install Scala on my Arch Linux PC I used this package. I have also installed isolate from the latest commit at the time of this writing.

Steps to reproduce:

  1. Save following source code as Main.scala:
object Main {
    def main(args: Array[String]) = {
        println("hello, world")
    }
}
  1. Initialize: isolate --cg --init
  2. Copy Main.scala to box: sudo cp Main.scala /var/local/lib/isolate/0/box/
  3. Run compilation: isolate --cg -p --run -- /usr/bin/scalac -verbose Main.scala

I have added the -verbose flag to better understand what is happening with the scalac.

Compilation and execution of the above hello, world program works as expected when I do not use isolate.

From my understanding after seeing the verbose output from scalac in both isolate and "native" compilation, they produce the same output but it seems there is some last step(s) that scalac needs to do before producing the class files but it does not finish in the case with isolate.

Please let me know if you need any more details from my side regarding this issue.

Can you please help me understand what is happening here and how can this be resolved?

Thank you in advance.

Best regards,
Herman

@gollux
Copy link
Member

gollux commented May 2, 2020

Can you strace it inside the box?

@hermanzdosilovic
Copy link
Contributor Author

I have run strace both in the box (isolate --cg -p --run -- /usr/bin/strace /usr/bin/scalac Main.scala) and outside (strace scalac Main.scala). You can find coresponding output in the attachment.

native.txt
isolate.txt

@gollux
Copy link
Member

gollux commented May 4, 2020

Could you try it with strace -f, please?

@hermanzdosilovic
Copy link
Contributor Author

Here they are, outputs with strace -f.

native.txt
isolate.txt

@gollux
Copy link
Member

gollux commented May 4, 2020

Thanks. For whatever reason, Scala compiler calls ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}, which is essentially the C function tcsetattr(). You probably left stdin/stdout connected to the parent process's terminal, so the sandboxed compiler runs essentially as a background session of that terminal, so it gets the SIGTTOU signal when it tries to adjust settings of the terminal.

I think that redirecting stdin from /dev/null and stdout to a file should fix the problem.

@hermanzdosilovic
Copy link
Contributor Author

Thank you very much @gollux!

I can now confirm that both compilation and execution works but I need to redirect stdin from /dev/null:

Compilation:

isolate --cg -p -i /dev/null --run -- /usr/bin/scalac Main.scala

Execution:

isolate --cg -p -i /dev/null --run -- /usr/bin/scala Main

Also, for others who might have the same problem, these also work:

$ echo "" | isolate --cg -p --run -- /usr/bin/scalac Main.scala
$ isolate --cg -p --run -- /usr/bin/scalac Main.scala < /dev/null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants