2011/6/21 Douglas E. Engert <deeng...@anl.gov>:
>
>
> On 6/21/2011 9:56 AM, Ludovic Rousseau wrote:
>> 2011/6/21 Ludovic Rousseau<ludovic.rouss...@gmail.com>:
>>> Hello,
>>>
>>> I try to debug a PKCS#11 program using pkcs11-spy.
>>> The problem is that for an unknown reason the C_Initialize() from the
>>> spy is calling istelf instead of the C_Initialize from OpenSC.
>>>
>>> After some 261418 calls the program crashes because of a stack
>>> exhaustion of something similar.
>>>
>>> With another program the pkcs11-spy works great. So the problem is not
>>> general :-(
>>>
>>>
>>> It looks like the C_Initialize symbol used by C_GetFunctionList() from
>>> OpenSC is resolved using the C_Initialize from the spy and not the
>>> C_Initialize from OpenSC.
>>>
>>> If I rename the function C_Initialize into C_InitializeX in
>>> src/pkcs11/pkcs11-global.c and use C_InitializeX to initialize
>>> pkcs11_function_list it works but I get the problem on the next
>>> PKCS#11 call, C_GetSlotList in my case.
>>>
>>> The program exposing the problem is a C++ one. But maybe that is not 
>>> related.
>>> Anyone having the same problem?
>>>
>>> Any idea how to solve this?
>>
>> Using LD_DEBUG=all I get some debug info.
>>
>> With the working program I have:
>>        2035: symbol=C_Initialize;  lookup in 
>> file=/home/lroussea/sc/TU/tellme [0]
>>        2035: symbol=C_Initialize;  lookup in file=/lib/libdl.so.2 [0]
>>        2035: symbol=C_Initialize;  lookup in file=/lib/libpthread.so.0 [0]
>>        2035: symbol=C_Initialize;  lookup in file=/usr/lib/libstdc++.so.6 [0]
>>        2035: symbol=C_Initialize;  lookup in file=/lib/libm.so.6 [0]
>>        2035: symbol=C_Initialize;  lookup in file=/lib/libgcc_s.so.1 [0]
>>        2035: symbol=C_Initialize;  lookup in file=/lib/libc.so.6 [0]
>>        2035: symbol=C_Initialize;  lookup in 
>> file=/lib64/ld-linux-x86-64.so.2 [0]
>>        2035: symbol=C_Initialize;  lookup in
>> file=/usr/lib/pkcs11/opensc-pkcs11.so [0]
>>        2035: binding file /usr/lib/pkcs11/opensc-pkcs11.so [0] to
>> /usr/lib/pkcs11/opensc-pkcs11.so [0]: normal symbol `C_Initialize'
>>
>> With the problematic program I have:
>>        4621: symbol=C_Initialize;  lookup in file=../src/TestSuiteP11 [0]
>>        4621: symbol=C_Initialize;  lookup in
>> file=/usr/lib/libcppunit-1.12.so.1 [0]
>>        4621: symbol=C_Initialize;  lookup in file=/lib/libdl.so.2 [0]
>>        4621: symbol=C_Initialize;  lookup in file=/usr/lib/libssl.so.0.9.8 
>> [0]
>>        4621: symbol=C_Initialize;  lookup in 
>> file=/usr/lib/libcrypto.so.0.9.8 [0]
>>        4621: symbol=C_Initialize;  lookup in file=/lib/libpthread.so.0 [0]
>>        4621: symbol=C_Initialize;  lookup in file=/usr/lib/libstdc++.so.6 [0]
>>        4621: symbol=C_Initialize;  lookup in file=/lib/libm.so.6 [0]
>>        4621: symbol=C_Initialize;  lookup in file=/lib/libgcc_s.so.1 [0]
>>        4621: symbol=C_Initialize;  lookup in file=/lib/libc.so.6 [0]
>>        4621: symbol=C_Initialize;  lookup in 
>> file=/lib64/ld-linux-x86-64.so.2 [0]
>>        4621: symbol=C_Initialize;  lookup in file=/usr/lib/libz.so.1 [0]
>>        4621: symbol=C_Initialize;  lookup in
>> file=/usr/lib/pkcs11/pkcs11-spy.so [0]
>>        4621:
>>        4621: file=/usr/lib/pkcs11/pkcs11-spy.so [0];  needed by
>> /usr/lib/pkcs11/opensc-pkcs11.so [0] (relocation dependency)
>>        4621:
>>        4621: binding file /usr/lib/pkcs11/opensc-pkcs11.so [0] to
>> /usr/lib/pkcs11/pkcs11-spy.so [0]: normal symbol `C_Initialize'
>>
>> Note the "relocation dependency".
>> opensc-pkcs11.so is using a symbol from pkcs11-spy.so. This is the problem.
>
> That should not happen.

:-)

> Is it possible that the test program is causing opensc-pkcs11 to be loaded
> because it was linked in, rather then being dynamically loaded based
> on something like a --module option?

No.

> Can you identify the routine?

Which routine?
The problem is with the C_Initialize symbol. I think that is the
routine you mention.

> Is opensc-pkcs11 missing a routine, and only spy has the routine?

No.

> Could this have something to do C++ loading libs differently?

That is also my suspect.

One option is to configure pkcs11-spy to NOT export symbols except
C_GetFunctionList. It will try and let you know.

Bye

-- 
 Dr. Ludovic Rousseau
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to