javax.smartcardio problem/OSX LION

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

javax.smartcardio problem/OSX LION

Wolfgang Korn
Hi all,

Currently I'm making myself familiar with NFC. For that reason I
started with a simple program which simply reads a tag's serial number
(see code below). The program is working fine in a Windows
environment. However, running the same program under OSX Lion does not
work. To be more specific: The program causes a segmentation fault in
libj2pcsc.dylib which I assume is javax.smartcard's JNI wrapper to
PC/SC. The behavior suggests that there might be some kind of race
condition. Moving code from inside a loop to the outside changes the
behavior (regarding the seg fault) and also simply introducing delays
sometimes changes it. I also tried sample code provided by Springcard
and got the same results. I do not thing that this problem is related
to the Springcard terminal. Doing the same with a smartcard terminal
and a smartcard causes the same problem.

I have a Springcard NFC'Roll and a Reiner-SCT cyberjack ecom terminal
connected to the machine. In order to make the NFC'Roll working I
replaced the CCID driver shipped with OSX with a recompiled version
(1.4.9) in which I added the terminal's vendor and product IDs.

Here is what I tried to get rid of the problem. First of all I updated
my Java6 to the latest version assuming that a new version of the JNI
wrapper would be shipped. Now the version is 1.6.0_37. Unfortunately
that did not solve the problem. Next step was installing Java7 but
that did not eliminate the problem either. Here is the output I get:

Invalid memory access of location 0x0 rip=0x109e6f66e
java(621,0x1014ae000) malloc: *** mmap(size=140527034961920) failed
(error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

I also have the log files generated by the JVM.

Any suggestion what can be done to get rid of that problem. Any help
is much appreciated.

Best
Wolfgang


=======================

        try {
            while (true) {
                // show the list of available terminals
                TerminalFactory factory = TerminalFactory.getDefault();
                List<CardTerminal> terminals = factory.terminals().list();
                System.out.println("Terminals: " + terminals);

                // get the first terminal
                CardTerminal terminal = terminals.get(1);

                if (terminal.isCardPresent()) {
                    // establish a connection with the card
                    Card card = terminal.connect("*");
                    System.out.println("card: " + card);

                    // print card's ATR
                    ATR atr = card.getATR();
                    System.out.println("atr: " + atr.toString());
                    System.out.println("ATR bytes");
                    HexDump.dump(atr.getBytes(), 0, System.out, 0);
                    System.out.println("Historical bytes");
                    HexDump.dump(atr.getHistoricalBytes(), 0, System.out, 0);

                    // Retrieve serial number
                    byte[] c1 = {(byte) 0xff, (byte) 0xca, (byte) 0x00,
                        (byte) 0x00, (byte) 0x00};
                    CardChannel channel = card.getBasicChannel();
                    ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
                    System.out.println("Card S/N");
                    HexDump.dump(r.getData(), 0, System.out, 0);
                    System.out.println();

                    // disconnect
                    try {
                        Thread.sleep(2000);
                    }
                    catch (InterruptedException ie) {
                    }
                    card.disconnect(false);
                }
            }
        }
        catch (Exception exc) {
            exc.printStackTrace();
        }

_______________________________________________
Muscle mailing list
[hidden email]
http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
Reply | Threaded
Open this post in threaded view
|

Re: javax.smartcardio problem/OSX LION

Michael StJohns-2
The first thing I'd do is take a look at which versions of the ccid and pcsclite packages you have on your system.  You may need to update those substantially.  Also, take a look at the logs for the pcscd - see if you even got that far.

Mike


At 02:56 PM 1/24/2013, Wolfgang Korn wrote:

>Hi all,
>
>Currently I'm making myself familiar with NFC. For that reason I
>started with a simple program which simply reads a tag's serial number
>(see code below). The program is working fine in a Windows
>environment. However, running the same program under OSX Lion does not
>work. To be more specific: The program causes a segmentation fault in
>libj2pcsc.dylib which I assume is javax.smartcard's JNI wrapper to
>PC/SC. The behavior suggests that there might be some kind of race
>condition. Moving code from inside a loop to the outside changes the
>behavior (regarding the seg fault) and also simply introducing delays
>sometimes changes it. I also tried sample code provided by Springcard
>and got the same results. I do not thing that this problem is related
>to the Springcard terminal. Doing the same with a smartcard terminal
>and a smartcard causes the same problem.
>
>I have a Springcard NFC'Roll and a Reiner-SCT cyberjack ecom terminal
>connected to the machine. In order to make the NFC'Roll working I
>replaced the CCID driver shipped with OSX with a recompiled version
>(1.4.9) in which I added the terminal's vendor and product IDs.
>
>Here is what I tried to get rid of the problem. First of all I updated
>my Java6 to the latest version assuming that a new version of the JNI
>wrapper would be shipped. Now the version is 1.6.0_37. Unfortunately
>that did not solve the problem. Next step was installing Java7 but
>that did not eliminate the problem either. Here is the output I get:
>
>Invalid memory access of location 0x0 rip=0x109e6f66e
>java(621,0x1014ae000) malloc: *** mmap(size=140527034961920) failed
>(error code=12)
>*** error: can't allocate region
>*** set a breakpoint in malloc_error_break to debug
>
>I also have the log files generated by the JVM.
>
>Any suggestion what can be done to get rid of that problem. Any help
>is much appreciated.
>
>Best
>Wolfgang
>
>
>=======================
>
>        try {
>            while (true) {
>                // show the list of available terminals
>                TerminalFactory factory = TerminalFactory.getDefault();
>                List<CardTerminal> terminals = factory.terminals().list();
>                System.out.println("Terminals: " + terminals);
>
>                // get the first terminal
>                CardTerminal terminal = terminals.get(1);
>
>                if (terminal.isCardPresent()) {
>                    // establish a connection with the card
>                    Card card = terminal.connect("*");
>                    System.out.println("card: " + card);
>
>                    // print card's ATR
>                    ATR atr = card.getATR();
>                    System.out.println("atr: " + atr.toString());
>                    System.out.println("ATR bytes");
>                    HexDump.dump(atr.getBytes(), 0, System.out, 0);
>                    System.out.println("Historical bytes");
>                    HexDump.dump(atr.getHistoricalBytes(), 0, System.out, 0);
>
>                    // Retrieve serial number
>                    byte[] c1 = {(byte) 0xff, (byte) 0xca, (byte) 0x00,
>                        (byte) 0x00, (byte) 0x00};
>                    CardChannel channel = card.getBasicChannel();
>                    ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
>                    System.out.println("Card S/N");
>                    HexDump.dump(r.getData(), 0, System.out, 0);
>                    System.out.println();
>
>                    // disconnect
>                    try {
>                        Thread.sleep(2000);
>                    }
>                    catch (InterruptedException ie) {
>                    }
>                    card.disconnect(false);
>                }
>            }
>        }
>        catch (Exception exc) {
>            exc.printStackTrace();
>        }
>
>_______________________________________________
>Muscle mailing list
>[hidden email]
>http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com



_______________________________________________
Muscle mailing list
[hidden email]
http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
Reply | Threaded
Open this post in threaded view
|

Re: javax.smartcardio problem/OSX LION

Wolfgang Korn
In reply to this post by Wolfgang Korn
Hi Mike,

thanks for your reply. The version of the pcsclite is the one which is
shipped with OSX Lion. pcscd -v reports version 1.4.0. As written in
my original post I replaced the stock ccid driver with a pached 1.4.9
version in order to support my Springcard NFC terminal. However, the
problem also occurs working only with my Reiner-SCT terminal which
does not make use of the ccid driver but has its own driver.

I also took a detailed look into the logs written by the JVM. Below I
there is the stack trace showing where the problem occurs. The
interesting thing is that even if the stack trace shows problems while
listing the attached readers, my program always properly shows the
readers prior to terminating due to the seg fault.

Stack: [0x0000000108ea8000,0x0000000108fa8000],
sp=0x0000000108fa77e0,  free space=1021k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libj2pcsc.dylib+0x166e]  pcsc_multi2jstring+0x11
C  [libj2pcsc.dylib+0x17f9]
Java_sun_security_smartcardio_PCSC_SCardListReaders+0x72
j  sun.security.smartcardio.PCSC.SCardListReaders(J)[Ljava/lang/String;+0
j  sun.security.smartcardio.PCSCTerminals.list(Ljavax/smartcardio/CardTerminals$State;)Ljava/util/List;+15
j  javax.smartcardio.CardTerminals.list()Ljava/util/List;+4
j  de.frusty.test.smartcard.SmartcardTest.main([Ljava/lang/String;)V+8

-- Wolfgang


On Thu, Jan 24, 2013 at 10:09 PM, Michael StJohns <[hidden email]> wrote:

> The first thing I'd do is take a look at which versions of the ccid and pcsclite packages you have on your system.  You may need to update those substantially.  Also, take a look at the logs for the pcscd - see if you even got that far.
>
> Mike
>
>
> At 02:56 PM 1/24/2013, Wolfgang Korn wrote:
>>Hi all,
>>
>>Currently I'm making myself familiar with NFC. For that reason I
>>started with a simple program which simply reads a tag's serial number
>>(see code below). The program is working fine in a Windows
>>environment. However, running the same program under OSX Lion does not
>>work. To be more specific: The program causes a segmentation fault in
>>libj2pcsc.dylib which I assume is javax.smartcard's JNI wrapper to
>>PC/SC. The behavior suggests that there might be some kind of race
>>condition. Moving code from inside a loop to the outside changes the
>>behavior (regarding the seg fault) and also simply introducing delays
>>sometimes changes it. I also tried sample code provided by Springcard
>>and got the same results. I do not thing that this problem is related
>>to the Springcard terminal. Doing the same with a smartcard terminal
>>and a smartcard causes the same problem.
>>
>>I have a Springcard NFC'Roll and a Reiner-SCT cyberjack ecom terminal
>>connected to the machine. In order to make the NFC'Roll working I
>>replaced the CCID driver shipped with OSX with a recompiled version
>>(1.4.9) in which I added the terminal's vendor and product IDs.
>>
>>Here is what I tried to get rid of the problem. First of all I updated
>>my Java6 to the latest version assuming that a new version of the JNI
>>wrapper would be shipped. Now the version is 1.6.0_37. Unfortunately
>>that did not solve the problem. Next step was installing Java7 but
>>that did not eliminate the problem either. Here is the output I get:
>>
>>Invalid memory access of location 0x0 rip=0x109e6f66e
>>java(621,0x1014ae000) malloc: *** mmap(size=140527034961920) failed
>>(error code=12)
>>*** error: can't allocate region
>>*** set a breakpoint in malloc_error_break to debug
>>
>>I also have the log files generated by the JVM.
>>
>>Any suggestion what can be done to get rid of that problem. Any help
>>is much appreciated.
>>
>>Best
>>Wolfgang
>>
>>
>>=======================
>>
>>        try {
>>            while (true) {
>>                // show the list of available terminals
>>                TerminalFactory factory = TerminalFactory.getDefault();
>>                List<CardTerminal> terminals = factory.terminals().list();
>>                System.out.println("Terminals: " + terminals);
>>
>>                // get the first terminal
>>                CardTerminal terminal = terminals.get(1);
>>
>>                if (terminal.isCardPresent()) {
>>                    // establish a connection with the card
>>                    Card card = terminal.connect("*");
>>                    System.out.println("card: " + card);
>>
>>                    // print card's ATR
>>                    ATR atr = card.getATR();
>>                    System.out.println("atr: " + atr.toString());
>>                    System.out.println("ATR bytes");
>>                    HexDump.dump(atr.getBytes(), 0, System.out, 0);
>>                    System.out.println("Historical bytes");
>>                    HexDump.dump(atr.getHistoricalBytes(), 0, System.out, 0);
>>
>>                    // Retrieve serial number
>>                    byte[] c1 = {(byte) 0xff, (byte) 0xca, (byte) 0x00,
>>                        (byte) 0x00, (byte) 0x00};
>>                    CardChannel channel = card.getBasicChannel();
>>                    ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
>>                    System.out.println("Card S/N");
>>                    HexDump.dump(r.getData(), 0, System.out, 0);
>>                    System.out.println();
>>
>>                    // disconnect
>>                    try {
>>                        Thread.sleep(2000);
>>                    }
>>                    catch (InterruptedException ie) {
>>                    }
>>                    card.disconnect(false);
>>                }
>>            }
>>        }
>>        catch (Exception exc) {
>>            exc.printStackTrace();
>>        }
>>
>>_______________________________________________
>>Muscle mailing list
>>[hidden email]
>>http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
>
>
>
> _______________________________________________
> Muscle mailing list
> [hidden email]
> http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com

_______________________________________________
Muscle mailing list
[hidden email]
http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
Reply | Threaded
Open this post in threaded view
|

Re: javax.smartcardio problem/OSX LION

Martin Paljak-4
Hello,

This is Apple ;)

for generic Java apps that can use and understand JAVA_HOME you should:

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home

Then make sure to run Java in 32 bit mode with -d32 (Java 1.6 is
needed because Java 1.7 comes only in 64 bit mode on Apple).


For any kind of development (that does not include developing *for*
mac) I suggest to take a Debian VM inside VMWare player or Virtualbox
and use it over SSH.

Martin

On Fri, Jan 25, 2013 at 8:52 AM, Wolfgang Korn <[hidden email]> wrote:

> Hi Mike,
>
> thanks for your reply. The version of the pcsclite is the one which is
> shipped with OSX Lion. pcscd -v reports version 1.4.0. As written in
> my original post I replaced the stock ccid driver with a pached 1.4.9
> version in order to support my Springcard NFC terminal. However, the
> problem also occurs working only with my Reiner-SCT terminal which
> does not make use of the ccid driver but has its own driver.
>
> I also took a detailed look into the logs written by the JVM. Below I
> there is the stack trace showing where the problem occurs. The
> interesting thing is that even if the stack trace shows problems while
> listing the attached readers, my program always properly shows the
> readers prior to terminating due to the seg fault.
>
> Stack: [0x0000000108ea8000,0x0000000108fa8000],
> sp=0x0000000108fa77e0,  free space=1021k
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
> C  [libj2pcsc.dylib+0x166e]  pcsc_multi2jstring+0x11
> C  [libj2pcsc.dylib+0x17f9]
> Java_sun_security_smartcardio_PCSC_SCardListReaders+0x72
> j  sun.security.smartcardio.PCSC.SCardListReaders(J)[Ljava/lang/String;+0
> j  sun.security.smartcardio.PCSCTerminals.list(Ljavax/smartcardio/CardTerminals$State;)Ljava/util/List;+15
> j  javax.smartcardio.CardTerminals.list()Ljava/util/List;+4
> j  de.frusty.test.smartcard.SmartcardTest.main([Ljava/lang/String;)V+8
>
> -- Wolfgang
>
>
> On Thu, Jan 24, 2013 at 10:09 PM, Michael StJohns <[hidden email]> wrote:
>> The first thing I'd do is take a look at which versions of the ccid and pcsclite packages you have on your system.  You may need to update those substantially.  Also, take a look at the logs for the pcscd - see if you even got that far.
>>
>> Mike
>>
>>
>> At 02:56 PM 1/24/2013, Wolfgang Korn wrote:
>>>Hi all,
>>>
>>>Currently I'm making myself familiar with NFC. For that reason I
>>>started with a simple program which simply reads a tag's serial number
>>>(see code below). The program is working fine in a Windows
>>>environment. However, running the same program under OSX Lion does not
>>>work. To be more specific: The program causes a segmentation fault in
>>>libj2pcsc.dylib which I assume is javax.smartcard's JNI wrapper to
>>>PC/SC. The behavior suggests that there might be some kind of race
>>>condition. Moving code from inside a loop to the outside changes the
>>>behavior (regarding the seg fault) and also simply introducing delays
>>>sometimes changes it. I also tried sample code provided by Springcard
>>>and got the same results. I do not thing that this problem is related
>>>to the Springcard terminal. Doing the same with a smartcard terminal
>>>and a smartcard causes the same problem.
>>>
>>>I have a Springcard NFC'Roll and a Reiner-SCT cyberjack ecom terminal
>>>connected to the machine. In order to make the NFC'Roll working I
>>>replaced the CCID driver shipped with OSX with a recompiled version
>>>(1.4.9) in which I added the terminal's vendor and product IDs.
>>>
>>>Here is what I tried to get rid of the problem. First of all I updated
>>>my Java6 to the latest version assuming that a new version of the JNI
>>>wrapper would be shipped. Now the version is 1.6.0_37. Unfortunately
>>>that did not solve the problem. Next step was installing Java7 but
>>>that did not eliminate the problem either. Here is the output I get:
>>>
>>>Invalid memory access of location 0x0 rip=0x109e6f66e
>>>java(621,0x1014ae000) malloc: *** mmap(size=140527034961920) failed
>>>(error code=12)
>>>*** error: can't allocate region
>>>*** set a breakpoint in malloc_error_break to debug
>>>
>>>I also have the log files generated by the JVM.
>>>
>>>Any suggestion what can be done to get rid of that problem. Any help
>>>is much appreciated.
>>>
>>>Best
>>>Wolfgang
>>>
>>>
>>>=======================
>>>
>>>        try {
>>>            while (true) {
>>>                // show the list of available terminals
>>>                TerminalFactory factory = TerminalFactory.getDefault();
>>>                List<CardTerminal> terminals = factory.terminals().list();
>>>                System.out.println("Terminals: " + terminals);
>>>
>>>                // get the first terminal
>>>                CardTerminal terminal = terminals.get(1);
>>>
>>>                if (terminal.isCardPresent()) {
>>>                    // establish a connection with the card
>>>                    Card card = terminal.connect("*");
>>>                    System.out.println("card: " + card);
>>>
>>>                    // print card's ATR
>>>                    ATR atr = card.getATR();
>>>                    System.out.println("atr: " + atr.toString());
>>>                    System.out.println("ATR bytes");
>>>                    HexDump.dump(atr.getBytes(), 0, System.out, 0);
>>>                    System.out.println("Historical bytes");
>>>                    HexDump.dump(atr.getHistoricalBytes(), 0, System.out, 0);
>>>
>>>                    // Retrieve serial number
>>>                    byte[] c1 = {(byte) 0xff, (byte) 0xca, (byte) 0x00,
>>>                        (byte) 0x00, (byte) 0x00};
>>>                    CardChannel channel = card.getBasicChannel();
>>>                    ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
>>>                    System.out.println("Card S/N");
>>>                    HexDump.dump(r.getData(), 0, System.out, 0);
>>>                    System.out.println();
>>>
>>>                    // disconnect
>>>                    try {
>>>                        Thread.sleep(2000);
>>>                    }
>>>                    catch (InterruptedException ie) {
>>>                    }
>>>                    card.disconnect(false);
>>>                }
>>>            }
>>>        }
>>>        catch (Exception exc) {
>>>            exc.printStackTrace();
>>>        }
>>>
>>>_______________________________________________
>>>Muscle mailing list
>>>[hidden email]
>>>http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
>>
>>
>>
>> _______________________________________________
>> Muscle mailing list
>> [hidden email]
>> http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
>
> _______________________________________________
> Muscle mailing list
> [hidden email]
> http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com

_______________________________________________
Muscle mailing list
[hidden email]
http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
Reply | Threaded
Open this post in threaded view
|

Re: javax.smartcardio problem/OSX LION

Wolfgang Korn
Martin,

thanks a lot. I just gave it try and everything is working! I was not
aware that 64bit would be a problem. I assume using a 64bit VM in a
Debian environment isn't a problem, right?

Wolfgang


On Fri, Jan 25, 2013 at 9:19 AM, Martin Paljak <[hidden email]> wrote:

> Hello,
>
> This is Apple ;)
>
> for generic Java apps that can use and understand JAVA_HOME you should:
>
> export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
>
> Then make sure to run Java in 32 bit mode with -d32 (Java 1.6 is
> needed because Java 1.7 comes only in 64 bit mode on Apple).
>
>
> For any kind of development (that does not include developing *for*
> mac) I suggest to take a Debian VM inside VMWare player or Virtualbox
> and use it over SSH.
>
> Martin
>
> On Fri, Jan 25, 2013 at 8:52 AM, Wolfgang Korn <[hidden email]> wrote:
>> Hi Mike,
>>
>> thanks for your reply. The version of the pcsclite is the one which is
>> shipped with OSX Lion. pcscd -v reports version 1.4.0. As written in
>> my original post I replaced the stock ccid driver with a pached 1.4.9
>> version in order to support my Springcard NFC terminal. However, the
>> problem also occurs working only with my Reiner-SCT terminal which
>> does not make use of the ccid driver but has its own driver.
>>
>> I also took a detailed look into the logs written by the JVM. Below I
>> there is the stack trace showing where the problem occurs. The
>> interesting thing is that even if the stack trace shows problems while
>> listing the attached readers, my program always properly shows the
>> readers prior to terminating due to the seg fault.
>>
>> Stack: [0x0000000108ea8000,0x0000000108fa8000],
>> sp=0x0000000108fa77e0,  free space=1021k
>> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
>> C  [libj2pcsc.dylib+0x166e]  pcsc_multi2jstring+0x11
>> C  [libj2pcsc.dylib+0x17f9]
>> Java_sun_security_smartcardio_PCSC_SCardListReaders+0x72
>> j  sun.security.smartcardio.PCSC.SCardListReaders(J)[Ljava/lang/String;+0
>> j  sun.security.smartcardio.PCSCTerminals.list(Ljavax/smartcardio/CardTerminals$State;)Ljava/util/List;+15
>> j  javax.smartcardio.CardTerminals.list()Ljava/util/List;+4
>> j  de.frusty.test.smartcard.SmartcardTest.main([Ljava/lang/String;)V+8
>>
>> -- Wolfgang
>>
>>
>> On Thu, Jan 24, 2013 at 10:09 PM, Michael StJohns <[hidden email]> wrote:
>>> The first thing I'd do is take a look at which versions of the ccid and pcsclite packages you have on your system.  You may need to update those substantially.  Also, take a look at the logs for the pcscd - see if you even got that far.
>>>
>>> Mike
>>>
>>>
>>> At 02:56 PM 1/24/2013, Wolfgang Korn wrote:
>>>>Hi all,
>>>>
>>>>Currently I'm making myself familiar with NFC. For that reason I
>>>>started with a simple program which simply reads a tag's serial number
>>>>(see code below). The program is working fine in a Windows
>>>>environment. However, running the same program under OSX Lion does not
>>>>work. To be more specific: The program causes a segmentation fault in
>>>>libj2pcsc.dylib which I assume is javax.smartcard's JNI wrapper to
>>>>PC/SC. The behavior suggests that there might be some kind of race
>>>>condition. Moving code from inside a loop to the outside changes the
>>>>behavior (regarding the seg fault) and also simply introducing delays
>>>>sometimes changes it. I also tried sample code provided by Springcard
>>>>and got the same results. I do not thing that this problem is related
>>>>to the Springcard terminal. Doing the same with a smartcard terminal
>>>>and a smartcard causes the same problem.
>>>>
>>>>I have a Springcard NFC'Roll and a Reiner-SCT cyberjack ecom terminal
>>>>connected to the machine. In order to make the NFC'Roll working I
>>>>replaced the CCID driver shipped with OSX with a recompiled version
>>>>(1.4.9) in which I added the terminal's vendor and product IDs.
>>>>
>>>>Here is what I tried to get rid of the problem. First of all I updated
>>>>my Java6 to the latest version assuming that a new version of the JNI
>>>>wrapper would be shipped. Now the version is 1.6.0_37. Unfortunately
>>>>that did not solve the problem. Next step was installing Java7 but
>>>>that did not eliminate the problem either. Here is the output I get:
>>>>
>>>>Invalid memory access of location 0x0 rip=0x109e6f66e
>>>>java(621,0x1014ae000) malloc: *** mmap(size=140527034961920) failed
>>>>(error code=12)
>>>>*** error: can't allocate region
>>>>*** set a breakpoint in malloc_error_break to debug
>>>>
>>>>I also have the log files generated by the JVM.
>>>>
>>>>Any suggestion what can be done to get rid of that problem. Any help
>>>>is much appreciated.
>>>>
>>>>Best
>>>>Wolfgang
>>>>
>>>>
>>>>=======================
>>>>
>>>>        try {
>>>>            while (true) {
>>>>                // show the list of available terminals
>>>>                TerminalFactory factory = TerminalFactory.getDefault();
>>>>                List<CardTerminal> terminals = factory.terminals().list();
>>>>                System.out.println("Terminals: " + terminals);
>>>>
>>>>                // get the first terminal
>>>>                CardTerminal terminal = terminals.get(1);
>>>>
>>>>                if (terminal.isCardPresent()) {
>>>>                    // establish a connection with the card
>>>>                    Card card = terminal.connect("*");
>>>>                    System.out.println("card: " + card);
>>>>
>>>>                    // print card's ATR
>>>>                    ATR atr = card.getATR();
>>>>                    System.out.println("atr: " + atr.toString());
>>>>                    System.out.println("ATR bytes");
>>>>                    HexDump.dump(atr.getBytes(), 0, System.out, 0);
>>>>                    System.out.println("Historical bytes");
>>>>                    HexDump.dump(atr.getHistoricalBytes(), 0, System.out, 0);
>>>>
>>>>                    // Retrieve serial number
>>>>                    byte[] c1 = {(byte) 0xff, (byte) 0xca, (byte) 0x00,
>>>>                        (byte) 0x00, (byte) 0x00};
>>>>                    CardChannel channel = card.getBasicChannel();
>>>>                    ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
>>>>                    System.out.println("Card S/N");
>>>>                    HexDump.dump(r.getData(), 0, System.out, 0);
>>>>                    System.out.println();
>>>>
>>>>                    // disconnect
>>>>                    try {
>>>>                        Thread.sleep(2000);
>>>>                    }
>>>>                    catch (InterruptedException ie) {
>>>>                    }
>>>>                    card.disconnect(false);
>>>>                }
>>>>            }
>>>>        }
>>>>        catch (Exception exc) {
>>>>            exc.printStackTrace();
>>>>        }
>>>>
>>>>_______________________________________________
>>>>Muscle mailing list
>>>>[hidden email]
>>>>http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
>>>
>>>
>>>
>>> _______________________________________________
>>> Muscle mailing list
>>> [hidden email]
>>> http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
>>
>> _______________________________________________
>> Muscle mailing list
>> [hidden email]
>> http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
>
> _______________________________________________
> Muscle mailing list
> [hidden email]
> http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com

_______________________________________________
Muscle mailing list
[hidden email]
http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
Reply | Threaded
Open this post in threaded view
|

Re: javax.smartcardio problem/OSX LION

helpcrypto helpcrypto
It could be a problem if you were using PKCS11 class, but shouldnt be,
AFAIK, if you stay on pcsc layer.

On Fri, Jan 25, 2013 at 5:06 PM, Wolfgang Korn <[hidden email]> wrote:

> Martin,
>
> thanks a lot. I just gave it try and everything is working! I was not
> aware that 64bit would be a problem. I assume using a 64bit VM in a
> Debian environment isn't a problem, right?
>
> Wolfgang
>
>
> On Fri, Jan 25, 2013 at 9:19 AM, Martin Paljak <[hidden email]> wrote:
>> Hello,
>>
>> This is Apple ;)
>>
>> for generic Java apps that can use and understand JAVA_HOME you should:
>>
>> export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
>>
>> Then make sure to run Java in 32 bit mode with -d32 (Java 1.6 is
>> needed because Java 1.7 comes only in 64 bit mode on Apple).
>>
>>
>> For any kind of development (that does not include developing *for*
>> mac) I suggest to take a Debian VM inside VMWare player or Virtualbox
>> and use it over SSH.
>>
>> Martin
>>
>> On Fri, Jan 25, 2013 at 8:52 AM, Wolfgang Korn <[hidden email]> wrote:
>>> Hi Mike,
>>>
>>> thanks for your reply. The version of the pcsclite is the one which is
>>> shipped with OSX Lion. pcscd -v reports version 1.4.0. As written in
>>> my original post I replaced the stock ccid driver with a pached 1.4.9
>>> version in order to support my Springcard NFC terminal. However, the
>>> problem also occurs working only with my Reiner-SCT terminal which
>>> does not make use of the ccid driver but has its own driver.
>>>
>>> I also took a detailed look into the logs written by the JVM. Below I
>>> there is the stack trace showing where the problem occurs. The
>>> interesting thing is that even if the stack trace shows problems while
>>> listing the attached readers, my program always properly shows the
>>> readers prior to terminating due to the seg fault.
>>>
>>> Stack: [0x0000000108ea8000,0x0000000108fa8000],
>>> sp=0x0000000108fa77e0,  free space=1021k
>>> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
>>> C  [libj2pcsc.dylib+0x166e]  pcsc_multi2jstring+0x11
>>> C  [libj2pcsc.dylib+0x17f9]
>>> Java_sun_security_smartcardio_PCSC_SCardListReaders+0x72
>>> j  sun.security.smartcardio.PCSC.SCardListReaders(J)[Ljava/lang/String;+0
>>> j  sun.security.smartcardio.PCSCTerminals.list(Ljavax/smartcardio/CardTerminals$State;)Ljava/util/List;+15
>>> j  javax.smartcardio.CardTerminals.list()Ljava/util/List;+4
>>> j  de.frusty.test.smartcard.SmartcardTest.main([Ljava/lang/String;)V+8
>>>
>>> -- Wolfgang
>>>
>>>
>>> On Thu, Jan 24, 2013 at 10:09 PM, Michael StJohns <[hidden email]> wrote:
>>>> The first thing I'd do is take a look at which versions of the ccid and pcsclite packages you have on your system.  You may need to update those substantially.  Also, take a look at the logs for the pcscd - see if you even got that far.
>>>>
>>>> Mike
>>>>
>>>>
>>>> At 02:56 PM 1/24/2013, Wolfgang Korn wrote:
>>>>>Hi all,
>>>>>
>>>>>Currently I'm making myself familiar with NFC. For that reason I
>>>>>started with a simple program which simply reads a tag's serial number
>>>>>(see code below). The program is working fine in a Windows
>>>>>environment. However, running the same program under OSX Lion does not
>>>>>work. To be more specific: The program causes a segmentation fault in
>>>>>libj2pcsc.dylib which I assume is javax.smartcard's JNI wrapper to
>>>>>PC/SC. The behavior suggests that there might be some kind of race
>>>>>condition. Moving code from inside a loop to the outside changes the
>>>>>behavior (regarding the seg fault) and also simply introducing delays
>>>>>sometimes changes it. I also tried sample code provided by Springcard
>>>>>and got the same results. I do not thing that this problem is related
>>>>>to the Springcard terminal. Doing the same with a smartcard terminal
>>>>>and a smartcard causes the same problem.
>>>>>
>>>>>I have a Springcard NFC'Roll and a Reiner-SCT cyberjack ecom terminal
>>>>>connected to the machine. In order to make the NFC'Roll working I
>>>>>replaced the CCID driver shipped with OSX with a recompiled version
>>>>>(1.4.9) in which I added the terminal's vendor and product IDs.
>>>>>
>>>>>Here is what I tried to get rid of the problem. First of all I updated
>>>>>my Java6 to the latest version assuming that a new version of the JNI
>>>>>wrapper would be shipped. Now the version is 1.6.0_37. Unfortunately
>>>>>that did not solve the problem. Next step was installing Java7 but
>>>>>that did not eliminate the problem either. Here is the output I get:
>>>>>
>>>>>Invalid memory access of location 0x0 rip=0x109e6f66e
>>>>>java(621,0x1014ae000) malloc: *** mmap(size=140527034961920) failed
>>>>>(error code=12)
>>>>>*** error: can't allocate region
>>>>>*** set a breakpoint in malloc_error_break to debug
>>>>>
>>>>>I also have the log files generated by the JVM.
>>>>>
>>>>>Any suggestion what can be done to get rid of that problem. Any help
>>>>>is much appreciated.
>>>>>
>>>>>Best
>>>>>Wolfgang
>>>>>
>>>>>
>>>>>=======================
>>>>>
>>>>>        try {
>>>>>            while (true) {
>>>>>                // show the list of available terminals
>>>>>                TerminalFactory factory = TerminalFactory.getDefault();
>>>>>                List<CardTerminal> terminals = factory.terminals().list();
>>>>>                System.out.println("Terminals: " + terminals);
>>>>>
>>>>>                // get the first terminal
>>>>>                CardTerminal terminal = terminals.get(1);
>>>>>
>>>>>                if (terminal.isCardPresent()) {
>>>>>                    // establish a connection with the card
>>>>>                    Card card = terminal.connect("*");
>>>>>                    System.out.println("card: " + card);
>>>>>
>>>>>                    // print card's ATR
>>>>>                    ATR atr = card.getATR();
>>>>>                    System.out.println("atr: " + atr.toString());
>>>>>                    System.out.println("ATR bytes");
>>>>>                    HexDump.dump(atr.getBytes(), 0, System.out, 0);
>>>>>                    System.out.println("Historical bytes");
>>>>>                    HexDump.dump(atr.getHistoricalBytes(), 0, System.out, 0);
>>>>>
>>>>>                    // Retrieve serial number
>>>>>                    byte[] c1 = {(byte) 0xff, (byte) 0xca, (byte) 0x00,
>>>>>                        (byte) 0x00, (byte) 0x00};
>>>>>                    CardChannel channel = card.getBasicChannel();
>>>>>                    ResponseAPDU r = channel.transmit(new CommandAPDU(c1));
>>>>>                    System.out.println("Card S/N");
>>>>>                    HexDump.dump(r.getData(), 0, System.out, 0);
>>>>>                    System.out.println();
>>>>>
>>>>>                    // disconnect
>>>>>                    try {
>>>>>                        Thread.sleep(2000);
>>>>>                    }
>>>>>                    catch (InterruptedException ie) {
>>>>>                    }
>>>>>                    card.disconnect(false);
>>>>>                }
>>>>>            }
>>>>>        }
>>>>>        catch (Exception exc) {
>>>>>            exc.printStackTrace();
>>>>>        }
>>>>>
>>>>>_______________________________________________
>>>>>Muscle mailing list
>>>>>[hidden email]
>>>>>http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Muscle mailing list
>>>> [hidden email]
>>>> http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
>>>
>>> _______________________________________________
>>> Muscle mailing list
>>> [hidden email]
>>> http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
>>
>> _______________________________________________
>> Muscle mailing list
>> [hidden email]
>> http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
>
> _______________________________________________
> Muscle mailing list
> [hidden email]
> http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com

_______________________________________________
Muscle mailing list
[hidden email]
http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com