#786737 jackd1: crashes with -n option specified

Package:
jackd1
Source:
jack-audio-connection-kit
Description:
JACK Audio Connection Kit (server and example clients)
Submitter:
Frank Heckenbach
Date:
2015-08-25 15:48:04 UTC
Severity:
normal
#786737#5
Date:
2015-05-25 02:53:18 UTC
From:
To:
When the "-n" option is given, jackd crashes when accessing
properties (which it seems to do implicitly for any client, e.g.
jack_lsp).

To reproduce:

  jackd -nfoo -dalsa
or
  JACK_DEFAULT_SERVER=bar jackd -nfoo -dalsa

While jackd is running, repeat this:

  JACK_DEFAULT_SERVER=foo jack_lsp

After a few tries, jackd crashes:

  /dev/shm/jack-0/default/__db.001: No such file or directory
  cannot open DB environment: No such file or directory
  Segmentation fault

I found several problems in the code:

- jack_property_init():

  Returns early if db_env != NULL. However, on failure later returns
  with db_env != NULL, but db == NULL. Callers assume db != NULL
  after it returns.

  Patch below. This fixes at least the segfault, but the error
  message remains (and whatever consequences it may have, I don't
  know).

- 7 places in metadata.c:

        if (jack_property_init (NULL)) {

  If NULL is passed for server_name, of course it won't use the
  actual server name.

  How is this supposed to work at all? Was it ever tested?

  A fix should consist of passing the actual server name from the
  callers.
--- libjack/metadata.c
+++ libjack/metadata.c
@@ -45,11 +45,11 @@

         /* idempotent */

-        if (db_env) {
+        if (db) {
                 return 0;
         }

-        if ((ret = db_env_create(&db_env, 0)) != 0) {
+        if (!db_env && (ret = db_env_create(&db_env, 0)) != 0) {
                 jack_error ("cannot initialize DB environment: %s\n", db_strerror(ret));
                 return -1;
         }

#786737#10
Date:
2015-08-25 15:44:43 UTC
From:
To:
Forwarded to jack-devel@.

Thanks for both your report and the patch.


Cheers