This page is no longer maintained — Please continue to the home page at www.scala-lang.org

FreeBSD problem (2.8-RC6)

7 replies
ch.epfl.listes....
Joined: 2010-06-29,
User offline. Last seen 42 years 45 weeks ago.

Hello.

For some reason, I can't execute scala scripts from the command line.

$ scala -version
Scala code runner version 2.8.0.RC6 -- Copyright 2002-2010, LAMP/EPFL
$ java -version
openjdk version "1.7.0"
OpenJDK Runtime Environment (build 1.7.0-root_2010_06_24_13_02-b00)
OpenJDK 64-Bit Server VM (build 17.0-b08, mixed mode)
$ uname -smir
FreeBSD 8.0-RELEASE-p2 amd64 GENERIC

hello.scala:

object Hello
{
def main (arguments : Array [String]) = println ("hello")
}

Hello.main (null)

$ scala hello.scala
...

Nothing happens. Checking processes with 'top' shows:

36238 cpj 18 66 0 446M 48640K ucond 4 0:01 8.50% java
93627 cpj 18 59 0 446M 48668K ucond 4 0:01 7.23% java
61540 cpj 18 56 0 446M 48664K ucond 6 0:01 6.15% java
37052 cpj 18 52 0 446M 48748K ucond 4 0:01 6.05% java
69507 cpj 18 52 0 446M 48636K ucond 4 0:01 5.52% java
6175 cpj 18 51 0 446M 48704K ucond 6 0:01 5.47% java
36433 cpj 18 50 0 446M 48676K ucond 6 0:01 5.22% java
9349 cpj 18 49 0 446M 48656K ucond 2 0:01 4.83% java
30934 cpj 18 47 0 445M 48320K ucond 4 0:01 4.35% java
73485 cpj 18 48 0 445M 48196K ucond 4 0:01 4.35% java
443 cpj 18 47 0 446M 48648K ucond 6 0:01 4.25% java
65613 cpj 18 46 0 445M 48240K ucond 6 0:01 3.86% java
97515 cpj 18 46 0 447M 48612K ucond 4 0:01 3.47% java
31745 cpj 18 46 0 446M 48680K ucond 1 0:01 3.37% java
29041 cpj 18 45 0 446M 48340K ucond 6 0:01 3.12% java
67785 cpj 18 45 0 446M 48840K ucond 1 0:01 3.12% java
97565 cpj 18 45 0 447M 48480K ucond 4 0:01 2.83% java
60440 cpj 18 45 0 446M 48704K ucond 4 0:01 2.83% java
29053 cpj 18 44 0 446M 48740K ucond 6 0:01 2.34% java

This list continues to grow indefinitely. It seems that scala is forking
endless copies of java, for some reason.

Any idea what's going on?

Daniel Degrandi
Joined: 2010-05-10,
User offline. Last seen 42 years 45 weeks ago.
Re: FreeBSD problem (2.8-RC6)

This isn't specific of FreeBSD. It's just that you are trying to start
it as a script, but it is not.
AFAIK the entry point of a script is by default not the main method, but
just the first line of your script.

So if your Hello.scala script looks like this:

println("Hello")

doing :
>scala Hello.scala

..will work.
Arguments that are passed via the shell are stored in an Array[String]
called args:

Hello.scala:

args foreach println

>scala Hello.scala Hello World

Hello
World

Cheers
Dan

ch.epfl.listes.scala-user@coreland.ath.cx schrieb:
> Hello.
>
> For some reason, I can't execute scala scripts from the command line.
>
> $ scala -version
> Scala code runner version 2.8.0.RC6 -- Copyright 2002-2010, LAMP/EPFL
> $ java -version
> openjdk version "1.7.0"
> OpenJDK Runtime Environment (build 1.7.0-root_2010_06_24_13_02-b00)
> OpenJDK 64-Bit Server VM (build 17.0-b08, mixed mode)
> $ uname -smir
> FreeBSD 8.0-RELEASE-p2 amd64 GENERIC
>
> hello.scala:
>
> object Hello
> {
> def main (arguments : Array [String]) = println ("hello")
> }
>
> Hello.main (null)
>
> $ scala hello.scala
> ...
>
> Nothing happens. Checking processes with 'top' shows:
>
> 36238 cpj 18 66 0 446M 48640K ucond 4 0:01 8.50% java
> 93627 cpj 18 59 0 446M 48668K ucond 4 0:01 7.23% java
> 61540 cpj 18 56 0 446M 48664K ucond 6 0:01 6.15% java
> 37052 cpj 18 52 0 446M 48748K ucond 4 0:01 6.05% java
> 69507 cpj 18 52 0 446M 48636K ucond 4 0:01 5.52% java
> 6175 cpj 18 51 0 446M 48704K ucond 6 0:01 5.47% java
> 36433 cpj 18 50 0 446M 48676K ucond 6 0:01 5.22% java
> 9349 cpj 18 49 0 446M 48656K ucond 2 0:01 4.83% java
> 30934 cpj 18 47 0 445M 48320K ucond 4 0:01 4.35% java
> 73485 cpj 18 48 0 445M 48196K ucond 4 0:01 4.35% java
> 443 cpj 18 47 0 446M 48648K ucond 6 0:01 4.25% java
> 65613 cpj 18 46 0 445M 48240K ucond 6 0:01 3.86% java
> 97515 cpj 18 46 0 447M 48612K ucond 4 0:01 3.47% java
> 31745 cpj 18 46 0 446M 48680K ucond 1 0:01 3.37% java
> 29041 cpj 18 45 0 446M 48340K ucond 6 0:01 3.12% java
> 67785 cpj 18 45 0 446M 48840K ucond 1 0:01 3.12% java
> 97565 cpj 18 45 0 447M 48480K ucond 4 0:01 2.83% java
> 60440 cpj 18 45 0 446M 48704K ucond 4 0:01 2.83% java
> 29053 cpj 18 44 0 446M 48740K ucond 6 0:01 2.34% java
>
> This list continues to grow indefinitely. It seems that scala is forking
> endless copies of java, for some reason.
>
> Any idea what's going on?
>
>

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: FreeBSD problem (2.8-RC6)

On Wed, Jun 30, 2010 at 02:58:22PM +0200, Daniel Degrandi wrote:
> This isn't specific of FreeBSD. It's just that you are trying to start
> it as a script, but it is not.

There's no reason the script he gave shouldn't work as it is. He called
the main method. I don't know what the problem is, but see if it runs
without using using jdk7. If it does, then that's the problem.

ch.epfl.listes....
Joined: 2010-06-29,
User offline. Last seen 42 years 45 weeks ago.
Re: FreeBSD problem (2.8-RC6)

On 2010-06-30 14:58:22, Daniel Degrandi wrote:
> This isn't specific of FreeBSD. It's just that you are trying to start
> it as a script, but it is not.
> AFAIK the entry point of a script is by default not the main method, but
> just the first line of your script.

Hi.

Unfortunately, this doesn't work either:

$ cat hello.scala
object Hello
{
def main (arguments : Array [String])
{
println ("hello")
}
}

$ scalac hello.scala
$ cat run-hello.scala
Hello.main (null)

$ scala -howtorun:script run-hello.scala
...
^C

$ scala -howtorun:script run-hello.scala
...
^C

On the other hand:

$ java -classpath scala-library.jar:. Hello
hello

ch.epfl.listes....
Joined: 2010-06-29,
User offline. Last seen 42 years 45 weeks ago.
Re: FreeBSD problem (2.8-RC6)

On 2010-06-30 06:39:10, Paul Phillips wrote:
> There's no reason the script he gave shouldn't work as it is. He called
> the main method. I don't know what the problem is, but see if it runs
> without using using jdk7. If it does, then that's the problem.

I'm currently building jdk6 to see if that makes any difference.

ch.epfl.listes....
Joined: 2010-06-29,
User offline. Last seen 42 years 45 weeks ago.
Re: FreeBSD problem (2.8-RC6)

On 2010-06-30 14:08:51, ch.epfl.listes.scala-user@coreland.ath.cx wrote:
> On 2010-06-30 06:39:10, Paul Phillips wrote:
> > There's no reason the script he gave shouldn't work as it is. He called
> > the main method. I don't know what the problem is, but see if it runs
> > without using using jdk7. If it does, then that's the problem.
>
> I'm currently building jdk6 to see if that makes any difference.

I've just tested it... No change.

$ java -version
openjdk version "1.6.0"
OpenJDK Runtime Environment (build 1.6.0-b17)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: FreeBSD problem (2.8-RC6)

On Wed, Jun 30, 2010 at 03:47:24PM +0000, ch.epfl.listes.scala-user@coreland.ath.cx wrote:
> I've just tested it... No change.

Things to do:

Try passing -nocompdaemon to scala.

Use more ps options: what exact command line do all those java processes
show?

Try setting the classpath explicitly and minimally.

ch.epfl.listes....
Joined: 2010-06-29,
User offline. Last seen 42 years 45 weeks ago.
Re: FreeBSD problem (2.8-RC6) (solved)

On 2010-06-30 08:53:50, Paul Phillips wrote:
> On Wed, Jun 30, 2010 at 03:47:24PM +0000, ch.epfl.listes.scala-user@coreland.ath.cx wrote:
> > I've just tested it... No change.
>
> Things to do:

Interesting!

> Try passing -nocompdaemon to scala.

This fixed it.

Out of curiousity, I tried fsc and sure enough...

term1$ fsc -help

term2$ ps auxww | grep java
cpj 13292 8.7 0.4 456252 48932 0 S+ 4:02pm 0:00.98 [java]
cpj 22327 8.4 0.4 456252 48832 0 S+ 4:02pm 0:00.88 [java]
cpj 54743 7.1 0.4 456252 48964 0 S+ 4:02pm 0:00.91 [java]
cpj 49976 6.1 0.4 456252 48668 0 S+ 4:02pm 0:00.88 [java]
cpj 93798 5.7 0.4 456252 48636 0 S+ 4:02pm 0:00.88 [java]
cpj 61127 4.8 0.4 455228 48412 0 S+ 4:02pm 0:00.88 [java]
cpj 25966 4.6 0.4 456252 49036 0 S+ 4:02pm 0:00.88 [java]
cpj 94696 4.5 0.4 456252 48696 0 S+ 4:02pm 0:00.88 [java]
cpj 49335 4.2 0.4 456252 48844 0 S+ 4:02pm 0:00.88 [java]
cpj 87332 4.0 0.4 456252 48840 0 S+ 4:02pm 0:00.88 [java]
cpj 38384 3.7 0.4 456252 48828 0 S+ 4:02pm 0:00.88 [java]
cpj 9637 3.4 0.4 456252 48632 0 S+ 4:02pm 0:00.88 [java]
cpj 86407 3.2 0.4 455228 48032 0 S+ 4:02pm 0:00.88 [java]
cpj 52730 2.7 0.4 456252 48688 0 S+ 4:02pm 0:00.88 [java]
cpj 12126 0.0 0.3 461432 42060 0 S+ 4:02pm 0:00.56 [java]
cpj 16692 0.0 0.2 449828 31180 0 S+ 4:02pm 0:00.19 [java]
cpj 24935 0.0 0.4 456252 48780 0 S 3:59pm 0:00.95 [java]

Turns out that those java "processes" are actually kernel threads (so there're
no command line options to retrieve).

Prodding the system further:

$ fsc -verbose
[Server arguments: -d /storage/home/cpj/doc/dev/2010/06/scala-hello/. -verbose]
[VM arguments: ]
[Temp directory: /var/tmp/scala-devel/cpj]
[Executed command: List(/storage/home/cpj/src/scala-2.8.0.RC6/bin/scala, scala.tools.nsc.CompileServer)]
[Port number: 34832]
java.net.SocketException: Invalid argument
[Connecting to compilation daemon at port 34832 failed; re-trying...]
[Executed command: List(/storage/home/cpj/src/scala-2.8.0.RC6/bin/scala, scala.tools.nsc.CompileServer)]
[Port number: 11285]
java.net.SocketException: Invalid argument
[Connecting to compilation daemon at port 11285 failed; re-trying...]
[Port number: 11285]
java.net.SocketException: Invalid argument
[Connecting to compilation daemon at port 11285 failed; re-trying...]
[Executed command: List(/storage/home/cpj/src/scala-2.8.0.RC6/bin/scala, scala.tools.nsc.CompileServer)]
[Port number: 38171]
java.net.SocketException: Invalid argument
[Connecting to compilation daemon at port 38171 failed; re-trying...]
[Port number: 38171]
java.net.SocketException: Invalid argument
[Connecting to compilation daemon at port 38171 failed; re-trying...]
[Executed command: List(/storage/home/cpj/src/scala-2.8.0.RC6/bin/scala, scala.tools.nsc.CompileServer)]
[Port number: 59834]
java.net.SocketException: Invalid argument
[Connecting to compilation daemon at port 59834 failed; re-trying...]
[Port number: 59834]
java.net.SocketException: Invalid argument
[Connecting to compilation daemon at port 59834 failed; re-trying...]
[Executed command: List(/storage/home/cpj/src/scala-2.8.0.RC6/bin/scala, scala.tools.nsc.CompileServer)]
[Port number: 63422]

And so on and so on. The 'Invalid argument' error threw me, so I
traced the process with ktrace and saw:

22896 java CALL connect(0x13,0x7fffffbfde80,0x1c)
22896 java STRU struct sockaddr { AF_INET6, [::ffff:10.1.3.1]:46542 }
22896 java RET connect -1 errno 22 Invalid argument

Now, I don't use ipv6 and had a vague memory of having a similar
network problem on Linux before. I tried the same workaround:

$ JAVA_OPTS='-Djava.net.preferIPv4Stack=true' fsc -verbose -server
[Server arguments: -d /storage/home/cpj/doc/dev/2010/06/scala-hello/. -verbose ]
[VM arguments: ]
[Temp directory: /var/tmp/scala-devel/cpj]

Problem solved!

Thanks for the orientation.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland