On 12/18/2012 8:01 AM, Anna Pavlova wrote:
Hello Douglas and Anthony,
sorry for late reply and cool, thanks you for helping me with gdb :-).
Thanks to you help I was able to run with my loaded library in debug mode.
Anyway, the crash (in the debug mode) looks as follows:
Program received signal SIGSEGV, Segmentation fault.
0xd810b787 in ?? ()
where 0xd810b787 is p11-C_Initialize (checked with printf(p11 = 0x%0x,
p11-C_Initialize = 0x%0x\n, p11, p11-C_Initialize);)
OK, but is 0x5810b6fa in your module?
This I am not completely sure about. But I don't really know how can I find
out if this is in my module or not.
I suspect that there is C_Initialize defined also somewhere else and the
pkcs11-tool picks it from somewhere else and not from my library.
I will ask again, does your module define the C_GetFunctionList, and does it
return a valid function list?
Yes it has - in the upper layer of the library I defined it as
CK_DEFINE_FUNCTION(CK_RV, C_GetFunctionList)
(
CK_FUNCTION_LIST_PTR_PTR ppFunctionList // receives pointer to function
list
)
{
try
{
API_ENTRY();
API_PARAM_PTR_EX(ppFunctionList, ppFunctionList);
if (ppFunctionList == NULL)
API_EXIT(CKR_ARGUMENTS_BAD);
*ppFunctionList = functionList;
API_EXIT(CKR_OK);
}
catch(...)
{
TRACE_ERROR(Catching top-level exception, );
API_EXIT(CKR_FUNCTION_FAILED);
}
}
And it should return a valid function list. In fact I have my own small test
tool that uses dlopen(libname, RTLD_NOW) to open the library and GetFuncList
= (C_GetFunctionListPtr)dlsym(lib,
C_GetFunctionList) to get the correct address of the functions.
The OpenSC ./common/libscdl.c uses dlopen(filename, RTLD_LAZY)
and dlsym(handle, symbol)
I suspect that it has something to do with how your module is linked,
and your use of RLTD_NOW vs RTLD_LAZY.
In the OpenSC ./src/pkcs11/Makefile.am has:
opensc_pkcs11_la_LDFLAGS = $(AM_LDFLAGS) \
-export-symbols $(srcdir)/opensc-pkcs11.exports \
-module -shared -avoid-version -no-undefined
Libtool uses the -module and -no-undefined to make sure that your module
will only reference symbols from itself and its dependent libraries,
and in effect does what RTLD_NOW would do, but does it when creating
the module rather then when it is being loaded.
I believe this is the same thing as done with pkcs11-tool, but somehow it
works in my small test tool, I can do C_Initialize and other pkcs11 functions
and in pkcs11-tool it crashes.
I have Ubuntu11.10, 32bit and the OpenSC version is very recent -
opensc0.12.1-1ubuntu1
I took it from here: http://apt.gooze.eu/ubuntu/dists/oneiric/
Actually that is not that new but should work.
To get the most out of gdb, you need to compile and link with the -g option
It sounds like opensc is compiled with the -g but not your module.
You may also want to try the OpenSC-0.13.0
The next release is tagged on the github OpenSC/OpenSC project,
thanks to all of you for your contributions.
Tarball and MSI installers can be found on github, sourceforge or the CI
server:
https://github.com/OpenSC/OpenSC/tags
https://sourceforge.net/projects/opensc/files/OpenSC/
https://opensc.fr/jenkins/
The packages for the other OSs will be added.
Cheers,
Anna
On Mon, Dec 17, 2012 at 8:59 PM, Douglas E. Engert deeng...@anl.gov
mailto:deeng...@anl.gov wrote:
gdb --args pkcs11-tool
--
Douglas E. Engert deeng...@anl.gov
Argonne National Laboratory
9700 South Cass Avenue
Argonne, Illinois 60439
(630) 252-5444
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel