[Fwd: Re: [Guitarix-developer] jack session crash]

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

[Fwd: Re: [Guitarix-developer] jack session crash]

Hermann Meyer
Hi

We have a wired problem with jack_session_manager diffs in
jack1 <-> jack2
for functions:

A)  jack_client_get_uuid
B)  jack_get_uuid_for_client_name

Therefore I forward our results to you. (attached)

Is that a known issue ?

regards
hermann

> Could nail it on

> string GxJack::get_uuid_insert()
>
> replacing
> char* uuid = jack_client_get_uuid(client_insert);
> with
> const char* uuid = jack_get_uuid_for_client_name(client_insert,
> client_insert_name.c_str());
>
> works here.
> I'm on jackd2, but as rosea already reported a crash with jackd1 and the
> old version, there seems to be a incompatibility in both versions of
> jack-session manager (jack1 <->jack2). That's more then strange. . .  .
yes, we have incompatibilities in all directions, that's really bad. I tested
with ubuntu jackd1 (1:0.121.0+svn4) and jackd2 (1.9.7~dfsg-1ubuntu2)

functions:

A)  jack_client_get_uuid
B)  jack_get_uuid_for_client_name

Both functions are defined with weak linkage in the header files of both
packages. But jackd1 has only A in its shared library, while jackd2 has
only B.

To make the mess complete, the weak linking doesn't work as
advertised by the jackd developers. At least my understanding and
that of the ubuntu / debian packagers seems to be:

 1) you can compile and link with either package (works)
 2) when the function is not in the shared library used at
     runtime, the function address will be 0. Does NOT work.

2) only works when the shared lib used at runtime is the same as
the one used when linking. The compiler / linker will set the address
of a weak function that it does not find in the libraries supplied to
constant 0. Even when the funktion is in the library which is used at
runtime, there will be no runtime linking.

Even worse, when the funktion is found while building the
executable, there will be an entry in the ELF PLT (Procedure Linkage
Table). The address of the function in the program will be that of
the PLT entry. So the function address is != 0 even when the
runtime linker can't resolve the function and produces a jump
to address 0 when calling the funktion.

To solve the problem for guitarix, I had to make some ugly
constructions:

 - the functions must never be used directly (or you will get
   a PLT entry so that dlsym() will only reflect the state while
   building the executable)

 - define typedefs for the function pointers that must be kept
   in sync with the definitions of the functions in the jack header

 - define global variables that are initialized with the function
   addresses via dlsym().

Example:

typedef char *(*jack_client_get_uuid_type)(jack_client_t *);

jack_client_get_uuid_type jack_client_get_uuid_fp =
    reinterpret_cast<jack_client_get_uuid_type>(
        dlsym(RTLD_DEFAULT, "jack_client_get_uuid"));

Test program to verify the described behaviour:

----------------------------------------------------------------
#include <stdio.h>
#include <jack/session.h>

int main() {
    printf("jack_client_get_uuid = %p, jack_get_uuid_for_client_name = %p\n",
           jack_client_get_uuid, jack_get_uuid_for_client_name);
    return 0;
}
----------------------------------------------------------------

test run (the ## lines represent deinstallation of jackd
and installation of the displayed jackd version):

----------------------------------------------------------------
## libjack0            1:0.121.0+svn4
$ gcc t.c -ljack
$ ./a.out
jack_client_get_uuid = 0x8048430, jack_get_uuid_for_client_name = (nil)

## libjack-jackd2-dev  1.9.7~dfsg-1ubuntu2
$ ./a.out
jack_client_get_uuid = 0x8048430, jack_get_uuid_for_client_name = (nil)
$ gcc t.c -ljack
$ ./a.out
jack_client_get_uuid = (nil), jack_get_uuid_for_client_name = 0x8048420

## libjack0            1:0.121.0+svn4
$ ./a.out
jack_client_get_uuid = (nil), jack_get_uuid_for_client_name = 0x8048420
----------------------------------------------------------------

ciao
Andreas

_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Paul Davis
On Wed, Nov 2, 2011 at 3:14 PM, hermann <[hidden email]> wrote:

> To make the mess complete, the weak linking doesn't work as
> advertised by the jackd developers. At least my understanding and
> that of the ubuntu / debian packagers seems to be:
>
>  1) you can compile and link with either package (works)
>  2) when the function is not in the shared library used at
>     runtime, the function address will be 0. Does NOT work.
>
> 2) only works when the shared lib used at runtime is the same as
> the one used when linking. The compiler / linker will set the address
> of a weak function that it does not find in the libraries supplied to
> constant 0. Even when the funktion is in the library which is used at
> runtime, there will be no runtime linking.

I have no idea what you are trying to say here.

If the function prototype was declared with weak linkage, and the
symbol is not found at runtime, then this condition:

     if (function_name)

will evaluate to false.

ardour is doing this all the time.

its fairly clear from your test program that you have not include
weakjack.h which is required to get weak linkage declarations.

--p
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Paul Davis
On Wed, Nov 2, 2011 at 3:33 PM, Paul Davis <[hidden email]> wrote:

> its fairly clear from your test program that you have not include
> weakjack.h which is required to get weak linkage declarations.

this ought to be in the reference manual, but alas, it is not. the
documentation on using weak linkage is written but doxygen has not
been told to include it. will fix.
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Hermann Meyer
In reply to this post by Paul Davis
Am Mittwoch, den 02.11.2011, 15:33 -0400 schrieb Paul Davis:
> if (function_name)
>
> will evaluate to false.
>
> ardour is doing this all the time.

Well, we come to a something similar solution,
so, this problem is already known.

thanks
hermann



_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Stéphane Letz
In reply to this post by Paul Davis

Le 2 nov. 2011 à 20:33, Paul Davis a écrit :

> On Wed, Nov 2, 2011 at 3:14 PM, hermann <[hidden email]> wrote:
>
>> To make the mess complete, the weak linking doesn't work as
>> advertised by the jackd developers. At least my understanding and
>> that of the ubuntu / debian packagers seems to be:
>>
>>  1) you can compile and link with either package (works)
>>  2) when the function is not in the shared library used at
>>     runtime, the function address will be 0. Does NOT work.
>>
>> 2) only works when the shared lib used at runtime is the same as
>> the one used when linking. The compiler / linker will set the address
>> of a weak function that it does not find in the libraries supplied to
>> constant 0. Even when the funktion is in the library which is used at
>> runtime, there will be no runtime linking.
>
> I have no idea what you are trying to say here.
>
> If the function prototype was declared with weak linkage, and the
> symbol is not found at runtime, then this condition:
>
>     if (function_name)
>
> will evaluate to false.
>
> ardour is doing this all the time.
>
> its fairly clear from your test program that you have not include
> weakjack.h which is required to get weak linkage declarations.
>
> --p

/**
 * get the assigned uuid for client.
 * safe to call from callback and all other threads.
 * memory needs to be freed.
 */

char *jack_client_get_uuid (jack_client_t *client) JACK_WEAK_EXPORT;


Freed by jak_free API yes ? ==> should be added in the doc

/**
 * Get the session ID for a client name.
 * The session manager needs this to reassociate a client name to the session_id.
 */
char *jack_get_uuid_for_client_name (jack_client_t *client,
                                     const char    *client_name) JACK_WEAK_EXPORT;


Freed by jak_free API yes ? ==> should be added in the doc

/**
 * Get the client name for a session_id.
 *
 * In order to snapshot the graph connections, the session manager needs to map
 * session_ids to client names.
 */
char *jack_get_client_name_by_uuid (jack_client_t *client,
                                    const char    *client_uuid ) JACK_WEAK_EXPORT;

Freed by jak_free API yes ? ==> should be added in the doc



jack_client_get_uuid missing in JACK2:

code from JACK1:

char *
jack_client_get_uuid( jack_client_t *client )
{
        char retval[16];

        snprintf( retval, sizeof(retval), "%d", client->control->uid );

        return strdup(retval);
}

==> Torben, I guess JACK1  client->control->uid correspond to JACK2  fSessionID field in JackClientControl yes?

Thanks.

Stéphane
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Paul Davis
In reply to this post by Hermann Meyer
On Wed, Nov 2, 2011 at 3:47 PM, hermann <[hidden email]> wrote:
> Am Mittwoch, den 02.11.2011, 15:33 -0400 schrieb Paul Davis:
>> if (function_name)
>>
>> will evaluate to false.
>>
>> ardour is doing this all the time.
>
> Well, we come to a something similar solution,

hopefully just involving:


    #include <jack/weakjack.h>

?

>
>
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Hermann Meyer
Am Mittwoch, den 02.11.2011, 15:53 -0400 schrieb Paul Davis:
> hopefully just involving:
>
>
>     #include <jack/weakjack.h>
>
> ?

No, right now we use dlfcn.h to solve it.

I will have a look at weakjack.h,



_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Hermann Meyer
In reply to this post by Stéphane Letz
Am Mittwoch, den 02.11.2011, 20:48 +0100 schrieb Stéphane Letz:

> Le 2 nov. 2011 à 20:33, Paul Davis a écrit :
>
> > On Wed, Nov 2, 2011 at 3:14 PM, hermann <[hidden email]> wrote:
> >
> >> To make the mess complete, the weak linking doesn't work as
> >> advertised by the jackd developers. At least my understanding and
> >> that of the ubuntu / debian packagers seems to be:
> >>
> >>  1) you can compile and link with either package (works)
> >>  2) when the function is not in the shared library used at
> >>     runtime, the function address will be 0. Does NOT work.
> >>
> >> 2) only works when the shared lib used at runtime is the same as
> >> the one used when linking. The compiler / linker will set the address
> >> of a weak function that it does not find in the libraries supplied to
> >> constant 0. Even when the funktion is in the library which is used at
> >> runtime, there will be no runtime linking.
> >
> > I have no idea what you are trying to say here.
> >
> > If the function prototype was declared with weak linkage, and the
> > symbol is not found at runtime, then this condition:
> >
> >     if (function_name)
> >
> > will evaluate to false.
> >
> > ardour is doing this all the time.
> >
> > its fairly clear from your test program that you have not include
> > weakjack.h which is required to get weak linkage declarations.
> >
> > --p
>
> /**
>  * get the assigned uuid for client.
>  * safe to call from callback and all other threads.
>  * memory needs to be freed.
>  */
>
> char *jack_client_get_uuid (jack_client_t *client) JACK_WEAK_EXPORT;
>
>
> Freed by jak_free API yes ? ==> should be added in the doc
>
> /**
>  * Get the session ID for a client name.
>  * The session manager needs this to reassociate a client name to the session_id.
>  */
> char *jack_get_uuid_for_client_name (jack_client_t *client,
>                                      const char    *client_name) JACK_WEAK_EXPORT;
>
>
> Freed by jak_free API yes ? ==> should be added in the doc
>
> /**
>  * Get the client name for a session_id.
>  *
>  * In order to snapshot the graph connections, the session manager needs to map
>  * session_ids to client names.
>  */
> char *jack_get_client_name_by_uuid (jack_client_t *client,
>                                     const char    *client_uuid ) JACK_WEAK_EXPORT;
>
> Freed by jak_free API yes ? ==> should be added in the doc
>
>
>
> jack_client_get_uuid missing in JACK2:
>
> code from JACK1:
>
> char *
> jack_client_get_uuid( jack_client_t *client )
> {
> char retval[16];
>
> snprintf( retval, sizeof(retval), "%d", client->control->uid );
>
> return strdup(retval);
> }
>
> ==> Torben, I guess JACK1  client->control->uid correspond to JACK2  fSessionID field in JackClientControl yes?
>
> Thanks.
>
> Stéphane

Stéphane, is there any chance that this comes in sync for both jack
versions ?

greets
hermann

_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Andreas Degert
In reply to this post by Paul Davis
On Wed, 2 Nov 2011 15:53:07 -0400
Paul Davis <[hidden email]> wrote:

> On Wed, Nov 2, 2011 at 3:47 PM, hermann <[hidden email]> wrote:
> > Am Mittwoch, den 02.11.2011, 15:33 -0400 schrieb Paul Davis:
> >> if (function_name)
> >>
> >> will evaluate to false.
> >>
> >> ardour is doing this all the time.
> >
> > Well, we come to a something similar solution,
>
> hopefully just involving:
>
>
>     #include <jack/weakjack.h>

Hi Paul, I'm the original author of the mail that hermann forwarded.
Which part of my mail do you not understand? I thought I explained the
problem :-)

AFAICS jackweak.h defines JACK_OPTIONAL_WEAK_EXPORT and
JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT, whereas the mentioned functions
from jack/session.h use JACK_WEAK_EXPORT, which is defined in
jack/weakmacros.h, which is included by session.h.

Anyhow, just to be sure I included weakjack.h in the test program,
but it doesn't change the behaviour.

Short summary:

If the jack function with weak attribute is in the shared lib that
is used when building the executable, an ELF PLT entry is generated.
When the executable is used with a shared lib that doesn't contain
the function, the the function address is still the PLT entry (!= 0)
but when called will indirectly jump to adress 0.

Btw. I'm using gcc 4.6.1, but I remember the same behaviour with older
gcc version.

ciao
Andreas
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Paul Davis
On Wed, Nov 2, 2011 at 4:28 PM, Andreas Degert <[hidden email]> wrote:

> Hi Paul, I'm the original author of the mail that hermann forwarded.
> Which part of my mail do you not understand? I thought I explained the
> problem :-)

> AFAICS jackweak.h defines JACK_OPTIONAL_WEAK_EXPORT and
> JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT, whereas the mentioned functions
> from jack/session.h use JACK_WEAK_EXPORT, which is defined in
> jack/weakmacros.h, which is included by session.h.

fair point, i forgot that this was a mandatorily weakly linked symbol.
this doesn't really make any difference to the point.

what does this show:

    nm YourExecutable | grep jack_
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Paul Davis
On Wed, Nov 2, 2011 at 4:49 PM, Paul Davis <[hidden email]> wrote:

> On Wed, Nov 2, 2011 at 4:28 PM, Andreas Degert <[hidden email]> wrote:
>
>> Hi Paul, I'm the original author of the mail that hermann forwarded.
>> Which part of my mail do you not understand? I thought I explained the
>> problem :-)
>
>> AFAICS jackweak.h defines JACK_OPTIONAL_WEAK_EXPORT and
>> JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT, whereas the mentioned functions
>> from jack/session.h use JACK_WEAK_EXPORT, which is defined in
>> jack/weakmacros.h, which is included by session.h.
>
> fair point, i forgot that this was a mandatorily weakly linked symbol.
> this doesn't really make any difference to the point.
>
> what does this show:
>
>    nm YourExecutable | grep jack_
>
 just for reference, this is what I get:

paul@sextet[2930]>cc -o js js.c -l jack
paul@sextet[2931]>./js
jack_client_get_uuid = 0x400510, jack_get_uuid_for_client_name = (nil)
paul@sextet[2932]>nm js | grep jack_
                 w jack_client_get_uuid
                 w jack_get_uuid_for_client_name
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Stéphane Letz
In reply to this post by Hermann Meyer

Le 2 nov. 2011 à 21:09, hermann a écrit :

> Am Mittwoch, den 02.11.2011, 20:48 +0100 schrieb Stéphane Letz:
>> Le 2 nov. 2011 à 20:33, Paul Davis a écrit :
>>
>>> On Wed, Nov 2, 2011 at 3:14 PM, hermann <[hidden email]> wrote:
>>>
>>>> To make the mess complete, the weak linking doesn't work as
>>>> advertised by the jackd developers. At least my understanding and
>>>> that of the ubuntu / debian packagers seems to be:
>>>>
>>>> 1) you can compile and link with either package (works)
>>>> 2) when the function is not in the shared library used at
>>>>    runtime, the function address will be 0. Does NOT work.
>>>>
>>>> 2) only works when the shared lib used at runtime is the same as
>>>> the one used when linking. The compiler / linker will set the address
>>>> of a weak function that it does not find in the libraries supplied to
>>>> constant 0. Even when the funktion is in the library which is used at
>>>> runtime, there will be no runtime linking.
>>>
>>> I have no idea what you are trying to say here.
>>>
>>> If the function prototype was declared with weak linkage, and the
>>> symbol is not found at runtime, then this condition:
>>>
>>>    if (function_name)
>>>
>>> will evaluate to false.
>>>
>>> ardour is doing this all the time.
>>>
>>> its fairly clear from your test program that you have not include
>>> weakjack.h which is required to get weak linkage declarations.
>>>
>>> --p
>>
>> /**
>> * get the assigned uuid for client.
>> * safe to call from callback and all other threads.
>> * memory needs to be freed.
>> */
>>
>> char *jack_client_get_uuid (jack_client_t *client) JACK_WEAK_EXPORT;
>>
>>
>> Freed by jak_free API yes ? ==> should be added in the doc
>>
>> /**
>> * Get the session ID for a client name.
>> * The session manager needs this to reassociate a client name to the session_id.
>> */
>> char *jack_get_uuid_for_client_name (jack_client_t *client,
>>                                     const char    *client_name) JACK_WEAK_EXPORT;
>>
>>
>> Freed by jak_free API yes ? ==> should be added in the doc
>>
>> /**
>> * Get the client name for a session_id.
>> *
>> * In order to snapshot the graph connections, the session manager needs to map
>> * session_ids to client names.
>> */
>> char *jack_get_client_name_by_uuid (jack_client_t *client,
>>                                    const char    *client_uuid ) JACK_WEAK_EXPORT;
>>
>> Freed by jak_free API yes ? ==> should be added in the doc
>>
>>
>>
>> jack_client_get_uuid missing in JACK2:
>>
>> code from JACK1:
>>
>> char *
>> jack_client_get_uuid( jack_client_t *client )
>> {
>> char retval[16];
>>
>> snprintf( retval, sizeof(retval), "%d", client->control->uid );
>>
>> return strdup(retval);
>> }
>>
>> ==> Torben, I guess JACK1  client->control->uid correspond to JACK2  fSessionID field in JackClientControl yes?
>>
>> Thanks.
>>
>> Stéphane
>
> Stéphane, is there any chance that this comes in sync for both jack
> versions ?
>
> greets
> hermann
>

I'm on JACK2, not JACK1... I can add jack_client_get_uuid.

Stéphane
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Hermann Meyer
Am Mittwoch, den 02.11.2011, 21:52 +0100 schrieb Stéphane Letz:

> > Stéphane, is there any chance that this comes in sync for both jack
> > versions ?
> >
> > greets
> > hermann
> >
>
> I'm on JACK2, not JACK1... I can add jack_client_get_uuid.
>
> Stéphane

that will be great, so when Torben or Paul add
jack_get_uuid_for_client_name
it is in sync, if not, we have at least one call witch will work in both
versions.

thanks
hermann

_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Andreas Degert
In reply to this post by Paul Davis
On Wed, 2 Nov 2011 16:51:02 -0400
Paul Davis <[hidden email]> wrote:

> On Wed, Nov 2, 2011 at 4:49 PM, Paul Davis
> <[hidden email]> wrote:
> > On Wed, Nov 2, 2011 at 4:28 PM, Andreas Degert <[hidden email]>
> > wrote:
> >
> >> Hi Paul, I'm the original author of the mail that hermann
> >> forwarded. Which part of my mail do you not understand? I thought
> >> I explained the problem :-)
> >
> >> AFAICS jackweak.h defines JACK_OPTIONAL_WEAK_EXPORT and
> >> JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT, whereas the mentioned
> >> functions from jack/session.h use JACK_WEAK_EXPORT, which is
> >> defined in jack/weakmacros.h, which is included by session.h.
> >
> > fair point, i forgot that this was a mandatorily weakly linked
> > symbol. this doesn't really make any difference to the point.
> >
> > what does this show:
> >
> >    nm YourExecutable | grep jack_
> >
>  just for reference, this is what I get:
>
> paul@sextet[2930]>cc -o js js.c -l jack
> paul@sextet[2931]>./js
> jack_client_get_uuid = 0x400510, jack_get_uuid_for_client_name = (nil)
> paul@sextet[2932]>nm js | grep jack_
>                  w jack_client_get_uuid
>                  w jack_get_uuid_for_client_name

My post was not about getting weak linking to work, without
weak symbols my test program would just have gotten a linker error.

It's about how weak linking works, and especially about how to test
if a symbol is in the shared library loaded into the current process.

If you test if the address of the function in your program is 0,
according to my test program you will not get that information (but
you need to execute the test program with both jackd1 and jackd2 libs
without recompiling).

Specifically to the situation we have in guitarix:

for session handling we need the uuid of the second guitarix jack
client (for the first its in the event structure). The two functions
in the test program can be used for that, but jackd1 has only the first
function, and jackd2 only the second.

So I thought the theory was to write something like

if (jack_client_get_uuid) {
    jack_client_get_uuid(...);
} else if (jack_get_uuid_for_client_name) {
    jack_get_uuid_for_client_name(...);
}

and e.g. compile it with jackd1 libs. When you start it the first
branch is taken. fine. Then uninstall jackd1, install jackd2 and
start it again. Second branch taken? no... crash...
jack_client_get_uuid is not 0, but when it's called it will crash at
address 0. Even if jack_client_get_uuid had been 0 now,
jack_get_uuid_for_client_name is set to constant 0 by the linker
building the executable because it didn't find it in any library.

When you recompile with jackd2, now you can start it (takes second
branch), but will crash with jackd1.

So we had to solve it by not referencing the functions in the program
but instead resolving them manually with dlsym().

ciao
Andreas
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Andreas Degert
In reply to this post by Paul Davis
On Wed, 2 Nov 2011 16:51:02 -0400
Paul Davis <[hidden email]> wrote:

> On Wed, Nov 2, 2011 at 4:49 PM, Paul Davis
> <[hidden email]> wrote:
> > On Wed, Nov 2, 2011 at 4:28 PM, Andreas Degert <[hidden email]>
> > wrote:
> >
> >> Hi Paul, I'm the original author of the mail that hermann
> >> forwarded. Which part of my mail do you not understand? I thought
> >> I explained the problem :-)
> >
> >> AFAICS jackweak.h defines JACK_OPTIONAL_WEAK_EXPORT and
> >> JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT, whereas the mentioned
> >> functions from jack/session.h use JACK_WEAK_EXPORT, which is
> >> defined in jack/weakmacros.h, which is included by session.h.
> >
> > fair point, i forgot that this was a mandatorily weakly linked
> > symbol. this doesn't really make any difference to the point.
> >
> > what does this show:
> >
> >    nm YourExecutable | grep jack_
> >
>  just for reference, this is what I get:
>
> paul@sextet[2930]>cc -o js js.c -l jack
> paul@sextet[2931]>./js
> jack_client_get_uuid = 0x400510, jack_get_uuid_for_client_name = (nil)
> paul@sextet[2932]>nm js | grep jack_
>                  w jack_client_get_uuid
>                  w jack_get_uuid_for_client_name

try this:

------------------------------------------------------------
$ nm -D a.out | grep jack
         w jack_client_get_uuid
$ objdump -R -d a.out
[...]
Disassembly of section .plt:

080483f0 <printf@plt-0x10>:
 80483f0:       ff 35 f8 9f 04 08       pushl  0x8049ff8
 80483f6:       ff 25 fc 9f 04 08       jmp    *0x8049ffc
 80483fc:       00 00                   add    %al,(%eax)
        ...

08048400 <printf@plt>:
 8048400:       ff 25 00 a0 04 08       jmp    *0x804a000
 8048406:       68 00 00 00 00          push   $0x0
 804840b:       e9 e0 ff ff ff          jmp    80483f0 <_init+0x3c>

08048410 <__gmon_start__@plt>:
 8048410:       ff 25 04 a0 04 08       jmp    *0x804a004
 8048416:       68 08 00 00 00          push   $0x8
 804841b:       e9 d0 ff ff ff          jmp    80483f0 <_init+0x3c>

08048420 <__libc_start_main@plt>:
 8048420:       ff 25 08 a0 04 08       jmp    *0x804a008
 8048426:       68 10 00 00 00          push   $0x10
 804842b:       e9 c0 ff ff ff          jmp    80483f0 <_init+0x3c>

08048430 <jack_client_get_uuid@plt>:
 8048430:       ff 25 0c a0 04 08       jmp    *0x804a00c
 8048436:       68 18 00 00 00          push   $0x18
 804843b:       e9 b0 ff ff ff          jmp    80483f0 <_init+0x3c>

Disassembly of section .text:
[...]
------------------------------------------------------------

ciao
Andreas
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Stéphane Letz
In reply to this post by Hermann Meyer

Le 2 nov. 2011 à 21:09, hermann a écrit :

> Am Mittwoch, den 02.11.2011, 20:48 +0100 schrieb Stéphane Letz:
>> Le 2 nov. 2011 à 20:33, Paul Davis a écrit :
>>
>>> On Wed, Nov 2, 2011 at 3:14 PM, hermann <[hidden email]> wrote:
>>>
>>>> To make the mess complete, the weak linking doesn't work as
>>>> advertised by the jackd developers. At least my understanding and
>>>> that of the ubuntu / debian packagers seems to be:
>>>>
>>>> 1) you can compile and link with either package (works)
>>>> 2) when the function is not in the shared library used at
>>>>    runtime, the function address will be 0. Does NOT work.
>>>>
>>>> 2) only works when the shared lib used at runtime is the same as
>>>> the one used when linking. The compiler / linker will set the address
>>>> of a weak function that it does not find in the libraries supplied to
>>>> constant 0. Even when the funktion is in the library which is used at
>>>> runtime, there will be no runtime linking.
>>>
>>> I have no idea what you are trying to say here.
>>>
>>> If the function prototype was declared with weak linkage, and the
>>> symbol is not found at runtime, then this condition:
>>>
>>>    if (function_name)
>>>
>>> will evaluate to false.
>>>
>>> ardour is doing this all the time.
>>>
>>> its fairly clear from your test program that you have not include
>>> weakjack.h which is required to get weak linkage declarations.
>>>
>>> --p
>>
>> /**
>> * get the assigned uuid for client.
>> * safe to call from callback and all other threads.
>> * memory needs to be freed.
>> */
>>
>> char *jack_client_get_uuid (jack_client_t *client) JACK_WEAK_EXPORT;
>>
>>
>> Freed by jak_free API yes ? ==> should be added in the doc
>>
>> /**
>> * Get the session ID for a client name.
>> * The session manager needs this to reassociate a client name to the session_id.
>> */
>> char *jack_get_uuid_for_client_name (jack_client_t *client,
>>                                     const char    *client_name) JACK_WEAK_EXPORT;
>>
>>
>> Freed by jak_free API yes ? ==> should be added in the doc
>>
>> /**
>> * Get the client name for a session_id.
>> *
>> * In order to snapshot the graph connections, the session manager needs to map
>> * session_ids to client names.
>> */
>> char *jack_get_client_name_by_uuid (jack_client_t *client,
>>                                    const char    *client_uuid ) JACK_WEAK_EXPORT;
>>
>> Freed by jak_free API yes ? ==> should be added in the doc
>>
>>
>>
>> jack_client_get_uuid missing in JACK2:
>>
>> code from JACK1:
>>
>> char *
>> jack_client_get_uuid( jack_client_t *client )
>> {
>> char retval[16];
>>
>> snprintf( retval, sizeof(retval), "%d", client->control->uid );
>>
>> return strdup(retval);
>> }
>>
>> ==> Torben, I guess JACK1  client->control->uid correspond to JACK2  fSessionID field in JackClientControl yes?
>>
>> Thanks.
>>
>> Stéphane
>
> Stéphane, is there any chance that this comes in sync for both jack
> versions ?
>
> greets
> hermann
>

jack_client_get_uuid added in JACK2 SVN : http://trac.jackaudio.org/changeset/4558

Please test and report.

Stéphane
_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Hermann Meyer
Am Donnerstag, den 03.11.2011, 11:25 +0100 schrieb Stéphane Letz:
> jack_client_get_uuid added in JACK2 SVN :
> http://trac.jackaudio.org/changeset/4558
>
> Please test and report.
>
> Stéphane

Many Thanks Stéphane :-)

Well, it works like suspected.
Session get saved and load fine.

[11:56:30]  session save  ***  use jack_client_get_uuid

But independent from that, one point I found enjoying is, that it looks
like that the session manager always try to make connections twice. Is
that the expected behaviour ?  
It's not a big deal, but it makes me wonder why.

qjackctlSession::update() jack_connect: "system:midi_capture_2" =>
"connie:midi_in" (0)

qjackctlSession::update() jack_connect: "connie:left" =>
"system:playback_1" (0)

qjackctlSession::update() jack_connect: "connie:right" =>
"system:playback_2" (0)

JackGraphManager::Connect already connected port_src = 28 port_dst = 17

qjackctlSession::update() jack_connect: "connie:left" =>
"system:playback_1" (17)

JackGraphManager::Connect already connected port_src = 29 port_dst = 18

qjackctlSession::update() jack_connect: "connie:right" =>
"system:playback_2" (17)

JackGraphManager::Connect already connected port_src = 21 port_dst = 27

qjackctlSession::update() jack_connect: "system:midi_capture_2" =>
"connie:midi_in" (17)


again thanks for your work Stéphane
hermann

_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Stéphane Letz

Le 3 nov. 2011 à 12:25, hermann a écrit :

> Am Donnerstag, den 03.11.2011, 11:25 +0100 schrieb Stéphane Letz:
>> jack_client_get_uuid added in JACK2 SVN :
>> http://trac.jackaudio.org/changeset/4558
>>
>> Please test and report.
>>
>> Stéphane
>
> Many Thanks Stéphane :-)
>
> Well, it works like suspected.
> Session get saved and load fine.
>
> [11:56:30]  session save  ***  use jack_client_get_uuid
>
> But independent from that, one point I found enjoying is, that it looks
> like that the session manager always try to make connections twice.

Which connection manager?

Stéphane

_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Hermann Meyer
Am Donnerstag, den 03.11.2011, 12:30 +0100 schrieb Stéphane Letz:

> Le 3 nov. 2011 à 12:25, hermann a écrit :
>
> > Am Donnerstag, den 03.11.2011, 11:25 +0100 schrieb Stéphane Letz:
> >> jack_client_get_uuid added in JACK2 SVN :
> >> http://trac.jackaudio.org/changeset/4558
> >>
> >> Please test and report.
> >>
> >> Stéphane
> >
> > Many Thanks Stéphane :-)
> >
> > Well, it works like suspected.
> > Session get saved and load fine.
> >
> > [11:56:30]  session save  ***  use jack_client_get_uuid
> >
> > But independent from that, one point I found enjoying is, that it looks
> > like that the session manager always try to make connections twice.
>
> Which connection manager?
>
> Stéphane
>

Its Qjackctl
Version: 0.3.8
Build: Jul 9 2011 09:53:57

greets
hermann

_______________________________________________
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: [Fwd: Re: [Guitarix-developer] jack session crash]

Nedko Arnaudov
In reply to this post by Hermann Meyer
> Test program to verify the described behaviour:

>
> ----------------------------------------------------------------
> #include <stdio.h>
> #include <jack/session.h>
>
> int main() {
>     printf("jack_client_get_uuid = %p, jack_get_uuid_for_client_name = %p\n",
>   jack_client_get_uuid, jack_get_uuid_for_client_name);
>     return 0;
> }
> ----------------------------------------------------------------
>
> test run (the ## lines represent deinstallation of jackd
> and installation of the displayed jackd version):
>
> ----------------------------------------------------------------
> ## libjack0            1:0.121.0+svn4
> $ gcc t.c -ljack
> $ ./a.out
> jack_client_get_uuid = 0x8048430, jack_get_uuid_for_client_name = (nil)
>
> ## libjack-jackd2-dev  1.9.7~dfsg-1ubuntu2
> $ ./a.out
> jack_client_get_uuid = 0x8048430, jack_get_uuid_for_client_name = (nil)
> $ gcc t.c -ljack
> $ ./a.out
> jack_client_get_uuid = (nil), jack_get_uuid_for_client_name = 0x8048420
>
> ## libjack0            1:0.121.0+svn4
> $ ./a.out
> jack_client_get_uuid = (nil), jack_get_uuid_for_client_name = 0x8048420
> ----------------------------------------------------------------
Build the test program with -fPIC

--
Nedko Arnaudov <GnuPG KeyID: 5D1B58ED>

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org

attachment0 (499 bytes) Download Attachment
12