On 12/17/2012 11:37 AM, Anna Pavlova wrote:
> Hello Douglas,
>
>
> > Sounds like p11 == NULL, or p11->C_Initialize is NULL or not valid.
>
> I did:
>
> printf("p11 = 0x%0x, p11->C_Initialize = 0x%0x\n", p11, p11->C_Initialize);
>
> in pkcs11-tool.c, just after C_LoadModule and before p11->C_Initialize(NULL)
>
> and got:
>
> p11 = 0xb7214060, p11->C_Initialize = 0x5810b6fa
OK, but is 0x5810b6fa in your module?
What version of OpenSC are you running?
On what OS?
>
> so it is not null.
>
>
> >Can you run this under gdb?
>
> Unfortunately I'm not very good in gdb :-(
>
> anna@anna:~/OpenSC/src/tools$ export LD_LIBRARY_PATH=`ls ../*/.libs -d | tr
> '\012' :`
> anna@anna:~/OpenSC/src/tools$ cd .libs/
> anna@anna:~/OpenSC/src/tools/.
> libs$ gdb 'pkcs11-tool --module /home/anna/PKCS11_Project/libPkcs11.so'
>
> the last command returns:
> pkcs11-tool --module /home/anna/PKCS11_Project/libPkcs11.so: No such file or
> directory.
One way is to use the --args
gdb --args pkcs11-tool --module /home/anna/PKCS11_Project/libPkcs11.so -l -O
break pkcs11-tool.c:558
run
If it crashes, It should show a back trace.
If it does not then to print out the p11 structure:
p *p11
I will ask again, does your module define the C_GetFunctionList, and does it
return a valid function list?
How did you link it?
>
> Of course, when I run only:
> anna@anna:~/OpenSC/src/tools/.libs$ gdb pkcs11-tool
>
> that one runs and I can run in debug mode, but I'm afraid that then I'm not
> loading my module.
>
> Do you know how can I run gdb and also use my own library? Sorry, I'm not
> really used to work with gdb :-(
>
>
> >Did you define a C_GetFunctionList in the module?
>
> Yes I did. In fact when I printed out in pkcs11-tool.c
>
> printf("%d \n",p11->version.major);
> printf("%d \n",p11->version.minor);
>
> it printed out the correct values. This is also the only thing that I can
> call with p11. But yes, C_GetFunctionList is defined in my library.
>
>
>
> >You must make sure the you module is linked as a module
> >and not just a shared library, so that functions returned by
> > C_GetFunctionList points at the functions in your module,
> >and not ones that may be defined by the caller.
>
> This is an interesting point, thank you. Actually no, I have built and linked
> it just like a shared library. I thought what's written as 'module' in the
> code and 'shared library' are the same things.
>
> Thanks,
> Anna
>
>
> On Mon, Dec 17, 2012 at 4:18 PM, Douglas E. Engert <[email protected]
> <mailto:[email protected]>> wrote:
>
>
>
> On 12/17/2012 7:01 AM, Anna Pavlova wrote:
> > Hello,
> >
> > I am new to OpenSC but I was looking for a 3rd party tool with which I
> could test my self-developed pkcs11 library and I came across the OpenSC
> pkcs11-tool.
> >
> > I installed OpenSC under Ubuntu11.10, following
> http://www.gooze.eu/howto/smartcard-quickstarter-guide/opensc-installation-under-gnu-linux
> > everything went fine, but when I wanted to run the pkcs11-tool:
> >
> > > pkcs11-tool --module /home/anna/PKCS11_Project/libPkcs11.so -l -O
>
>
> >
> > I got segmentation fault.
> >
> > I was able to find the place where the code crashed. In pkcs11-tool.c
> the line (558):
> >
> > rv = p11->C_Initialize(NULL);
>
> Sounds like p11 == NULL, or p11->C_Initialize is NULL or not valid.
> It should point at your C_Initialize routine.
>
> Can you run this under gdb?
>
> >
> > seem to crash. The message is just "Segmentation fault"
> >
> > The module loads apparently fine.
> > module = C_LoadModule(opt_module, &p11); //no error here
> >
> > The problem is, that in my pkcs11 library I put an error message at
> the very beginning of the C_Initialize function, but not even this is printed
> out. So I don't think the crash comes from my
> library.
> > I turned on the creation of a log file in my pkcs11 library, but not
> even my pkcs11 library log file is created.
> >
>
> Did you define a C_GetFunctionList in the module?
>
> You must make sure the you module is linked as a module
> and not just a shared library, so that functions returned by
> C_GetFunctionList points at the functions in your module,
> and not ones that may be defined by the caller.
>
> Have a look at the pkcs11-spy too which is a PKCS#11 module that loads
> a second PKCS#11 module.
>
> >
> > I tried to google this problem and found this old thread:
> >
> http://www.opensc-project.org/pipermail/opensc-devel/2003-April/000831.html
> >
> > But it didn't really help me (rebuilding openssl didn't solve the
> problem..). Could anyone help?
> >
> > Thanks for any help,
> > Anna
> >
> >
> > _______________________________________________
> > opensc-devel mailing list
> > [email protected]
> <mailto:[email protected]>
> > http://www.opensc-project.org/mailman/listinfo/opensc-devel
> >
>
> --
>
> Douglas E. Engert <[email protected] <mailto:[email protected]>>
> Argonne National Laboratory
> 9700 South Cass Avenue
> Argonne, Illinois 60439
> (630) 252-5444 <tel:%28630%29%20252-5444>
> _______________________________________________
> opensc-devel mailing list
> [email protected]
> <mailto:[email protected]>
> http://www.opensc-project.org/mailman/listinfo/opensc-devel
>
>
--
Douglas E. Engert <[email protected]>
Argonne National Laboratory
9700 South Cass Avenue
Argonne, Illinois 60439
(630) 252-5444
_______________________________________________
opensc-devel mailing list
[email protected]
http://www.opensc-project.org/mailman/listinfo/opensc-devel