[Jack-Devel] Jack: "Too many servers already active"

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Jack-Devel] Jack: "Too many servers already active"

Malik Costet
Cheers everyone,

As part of my testing of, and indeed as (an intended) part of the
software I'm writing, I'm starting and stopping many jackd instances on
the box in question (a Pi).

Today, to my surprise, I seem to have hit upon some kind of limit, for
attempts to launch a server (via the command-line) fail with the message
"Too many servers already active". I haven't kept count, but I might
have successfully started and stopped a couple dozen instances of JACK
before that happened (only ever one at a time, though).

Now, the point is, there definitely *aren't* any jackd processes running
at the time I'm executing that command. So I'm wondering whether there's
perhaps some environment setting that JACK checks? Or something?

Note that a restart of the system fixes the issue. That wouldn't be an
acceptable long-term solution, however.

For what it's worth, I'm running JACK on a headless environment, and am
setting DISPLAY=:0 to work around the DBUS issues.

Ideas, suggestions, etc. much welcome.

M.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack: "Too many servers already active"

yuri@rawbw.com
On 08/22/17 17:21, Malik Costet wrote:
> Today, to my surprise, I seem to have hit upon some kind of limit, for
> attempts to launch a server (via the command-line) fail with the message
> "Too many servers already active". I haven't kept count, but I might
> have successfully started and stopped a couple dozen instances of JACK
> before that happened (only ever one at a time, though).


Quick search through the Jack code shows that this message results from
Jack attempting to be helpful that ends up being unhelpful:

 >         case ENOSPC:
 >                 fprintf (stderr, "too many servers already active\n");
 >                 exit (2);

...

#define    ENOSPC        28        /* No space left on device */


You have a 'disk-full' condition. This most likely has nothing to do
with having "too many servers already active".

Jack needs to use strerror() instead.


Yuri


_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack: "Too many servers already active"

Malik Costet
On 2017-08-23 02:41, Yuri wrote:

> On 08/22/17 17:21, Malik Costet wrote:
>> Today, to my surprise, I seem to have hit upon some kind of limit, for
>> attempts to launch a server (via the command-line) fail with the message
>> "Too many servers already active". I haven't kept count, but I might
>> have successfully started and stopped a couple dozen instances of JACK
>> before that happened (only ever one at a time, though).
>
>
> Quick search through the Jack code shows that this message results from
> Jack attempting to be helpful that ends up being unhelpful:
>
>>         case ENOSPC:
>>                 fprintf (stderr, "too many servers already active\n");
>>                 exit (2);
>
> ...
>
> #define    ENOSPC        28        /* No space left on device */
>
>
> You have a 'disk-full' condition. This most likely has nothing to do
> with having "too many servers already active".
>
> Jack needs to use strerror() instead.

Thanks for the quick reply, but... hmm. I'm gonna check this if and when
I reproduce the situation, but my machine would seem to have bucketloads
of space available:
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  3.8G   11G  27% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M   76K  463M   1% /dev/shm
tmpfs           463M  6.3M  457M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1   63M   21M   43M  33% /boot
tmpfs            93M     0   93M   0% /run/user/1000

Do you have any indication which filesystem/location JACK would be
looking for the condition? Could it also be a case of flag misuse?

M.

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack: "Too many servers already active"

yuri@rawbw.com
On 08/22/17 17:45, Malik Costet wrote:
> Do you have any indication which filesystem/location JACK would be
> looking for the condition? Could it also be a case of flag misuse?


Looking again, ENOSPC is returned by jack_register_server.
jack_register_server simulates the error ENOSPC when it can't find a
free slot in the shared memory table.

The table allows up to MAX_SERVERS=8 servers. It appears that shared
memory isn't deleted when the last process using it quits, and it got
polluted with bogus data.

Jack appears to use shared memory at "/jack-shm-registry".


I recently saw such situation on FreeBSD with another app,
supercollider. Creating shared memory was failing there, no apps were
using it. Not sure if this is a bug in kernel that it isn't
automatically free when users die. But Jack could at least test if pids
registered there are alive.


In short, no quick solution for you. Jack needs to be fixed. It needs to
detect that pids recorded in the table are dead and invalidate them.


I propose the following fix.

The line:

 > if (jack_shm_header->server[i].pid == 0) {

changes to

 > if (jack_shm_header->server[i].pid == 0 ||
kill(jack_shm_header->server[i].pid, 0) != 0) {


Yuri

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack: "Too many servers already active"

yuri@rawbw.com
On 08/22/17 18:17, Yuri wrote:

> I propose the following fix.
>
> The line:
>
> > if (jack_shm_header->server[i].pid == 0) {
>
> changes to
>
> > if (jack_shm_header->server[i].pid == 0 ||
> kill(jack_shm_header->server[i].pid, 0) != 0) {


This patch should help: https://github.com/jackaudio/jack1/pull/74


Yuri


_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack: "Too many servers already active"

yuri@rawbw.com
On 08/22/17 18:39, Yuri wrote:
>
> This patch should help: https://github.com/jackaudio/jack1/pull/74


I take it back.


Jack has 8 slots for servers in the shared memory segment. On one hand,
you are saying that no jackd is running when the problem occurs. On the
other hand, jack already checks for dead pids and discards them. But, in
the end, it fails to find even one available entry in this 8-element
table. Something funny is going on. You need to print what pids are in
this table when it fails. Need step-by-step log in jack_register_server .

You are using Pi? Maybe nobody ever ran jack on Pi?


Yuri
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack: "Too many servers already active"

Malik Costet
On 2017-08-23 03:54, Yuri wrote:

> On 08/22/17 18:39, Yuri wrote:
>>
>> This patch should help: https://github.com/jackaudio/jack1/pull/74
>
>
> I take it back.
>
>
> Jack has 8 slots for servers in the shared memory segment. On one hand,
> you are saying that no jackd is running when the problem occurs. On the
> other hand, jack already checks for dead pids and discards them. But, in
> the end, it fails to find even one available entry in this 8-element
> table. Something funny is going on. You need to print what pids are in
> this table when it fails. Need step-by-step log in jack_register_server .
>
> You are using Pi? Maybe nobody ever ran jack on Pi?

Yuri, this is highly interesting.

I can think of something that happened during testing which might
correspond to what you found, although it still leaves some questions open.

First a quick overview of my setup. My main process is a Java
application. That application creates jackd instances via a fork (i.e.,
spawns a new process). It also creates jack_clients via native calls
(using Neil C. Smith's jna-jack lib [1]) to connect to those newly
created servers.

Now, one of the problems I encountered today was that something went
south when I tried to deactivate() those clients. Namely that I got a
message on stderr that the JVM couldn't detach the native thread, upon
which the entire JVM froze on me, with me having to SIGKILL it to get
rid of it. Note that I also had manually to kill the jackd process, but
that was achieved with a simple SIGTERM.

This did indeed happened about 8 times (I have since circumvented the
problem by calling close() instead of deactivate() on the client; not
happy because I don't understand what the problem was, but at least it
doesn't happen any more).

There's still two problems however:
 - I can guarantee that none of my Java process nor any jackd instances
were running what the problem happened -- or least none that showed up
in ps.
 - I /think/ that I started the server successfully, after having had
those had freezes, but before I had the "Too many servers active" error.

Discarding the second problem for the time being, as I am not sure of
it, the first one still remains. If, as you say, jack checks for dead
PIDs, how can it not find free slots if no processes are running? Or
does it perhaps not check the OS, but some internal register? In which
case the freeze and kill would prevent that register from being cleared?
This still doesn't make perfect sense, however, since, as mentioned
above, I SIGTERM'd jackd, which can hardly count as a hard exit.
The one thing that was broken was the jack_client in my JVM. So could
that be it? Could it be that because of its freeze, even after having
been killed, the JVM somehow retained resources associated with the
client, and that *that* prevented jack from cleaning up its dead instances?

Questions, questions.

In case I get that issue again, would you mind telling in more detail
what I need to do to get the information you mentioned, or really any
pertinent information?

Oh, and lastly and for reference, I'm running Jack 1.9.10.

Regards,
 M.

[1] <https://github.com/jaudiolibs/jnajack>
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org