Opened 10 years ago

Closed 10 years ago

#3887 closed defect (worksforme)

OSCam r9849 with PCSC is restarting to infinity

Reported by: khimtiki Owned by:
Priority: critical Component: Card support
Severity: high Keywords: seca
Cc: Sensitive: yes

Description

When OSCam is compiled with PCSC smaardcard readers it's getting to restart in loop when trying read nagra card with seca 0100 tunnel.

After this log:

Trying to switch to nagra layer of this card!

restart occurs in loop.

Revert to r9848 and there is no problem.

The cardreader: PCSC Omnikey USB 3121.
Two logs included, correct card init in r9848, and with error in r9849.

Attachments (3)

r9848_log.txt (4.9 KB ) - added by khimtiki 10 years ago.
r9849_log.txt (14.8 KB ) - added by khimtiki 10 years ago.
switchtonagratryfix1.patch (1.6 KB ) - added by theparasol 10 years ago.
Does fix anything at all?

Download all attachments as: .zip

Change History (17)

by khimtiki, 10 years ago

Attachment: r9848_log.txt added

by khimtiki, 10 years ago

Attachment: r9849_log.txt added

comment:1 by ni hao, 10 years ago

Here the same, so confirmed.

comment:2 by koekjesman, 10 years ago

Reader PCSC Omnikey USB 3121 dont work 9849 ,9850

comment:3 by theparasol, 10 years ago

Interesting, a real crash.
Can someone add a crash debug log to this ticket to speed up fixing of this issue?

comment:4 by khimtiki, 10 years ago

There is some more info from debug 48:

2014/09/17 13:20:37        0 s cyfra+ [pcsc] creating thread for device 0
2014/09/17 13:20:37        0 s waiting for local card init
2014/09/17 13:20:37  1BB2F50 r cyfra+ [pcsc] IFD: Opening device 0
2014/09/17 13:20:37  1BB2F50 r cyfra+ [pcsc] IO: PCSC establish context for PCSC pcsc_reader 0
2014/09/17 13:20:37  1BB2F50 r cyfra+ [pcsc] IO: PCSC pcsc_reader 0: OMNIKEY AG CardMan 3121 00 00
2014/09/17 13:20:37  1BB2F50 r cyfra+ [pcsc] IFD: Device 0 succesfully opened
2014/09/17 13:20:37  1BB2F50 r cyfra+ [pcsc] Reader initialized (device=0, detect=cd, mhz=357, cardmhz=357)
2014/09/17 13:20:38  1BB2F50 r cyfra+ [pcsc] PCSC was opened with handle: 910396323
2014/09/17 13:20:38  1BB2F50 r cyfra+ [pcsc] card detected
2014/09/17 13:20:38  1BB2F50 r cyfra+ [pcsc] IFD: Activating card
2014/09/17 13:20:38  1BB2F50 r cyfra+ [pcsc] IO: PCSC initializing card in (OMNIKEY AG CardMan 3121 00 00)
2014/09/17 13:20:38  1BB2F50 r cyfra+ [pcsc] IO: PCSC resetting card in (OMNIKEY AG CardMan 3121 00 00) with handle 910396323
2014/09/17 13:20:38  1BB2F50 r cyfra+ [pcsc] IO: PCSC resetting done on card in (OMNIKEY AG CardMan 3121 00 00)
2014/09/17 13:20:38  1BB2F50 r cyfra+ [pcsc] IO: PCSC Protocol (T=0)
2014/09/17 13:20:38  1BB2F50 r cyfra+ [pcsc] IO: PCSC getting ATR for card in (OMNIKEY AG CardMan 3121 00 00)
2014/09/17 13:20:38  1BB2F50 r cyfra+ [pcsc] IO: PCSC Protocol (T=0)
2014/09/17 13:20:38  1BB2F50 r cyfra+ [pcsc] ATR: 3B F7 11 00 01 40 96 70 70 0A 0E 6C B6 D6 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 5 bytes to PCSC : C1 0E 00 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 10 bytes from PCSC with rv=0 : 00 23 00 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 10
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] type: SECA, caid: 0100, serial: #########, card: Mediaguard v10.0
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 5 bytes to PCSC : C1 16 00 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 8 bytes from PCSC with rv=0 : FF FF 00 07 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 8
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] Request provider 1
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 5 bytes to PCSC : C1 12 00 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 27 bytes from PCSC with rv=0 : 00 00 43 59 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 27
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] provider 1: 0000, valid: 1, name: CYFRA +, expiry date: 2014/10/29
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] SA: ########
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 8 bytes to PCSC : C1 34 00 00 03 04 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 2 bytes from PCSC with rv=0 : 90 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 2
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 5 bytes to PCSC : C1 32 00 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 15 bytes from PCSC with rv=0 : B2 00 07 99 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 15
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] PBM for provider 1: 799007c01a000
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] Request provider 2
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 5 bytes to PCSC : C1 12 01 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 27 bytes from PCSC with rv=0 : 00 68 43 59 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 27
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] provider 2: 0068, valid: 1, name: CYFRA+ 1, expiry date: 2014/10/29
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] SA: ########
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 8 bytes to PCSC : C1 34 00 00 03 00 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 2 bytes from PCSC with rv=0 : 90 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 2
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 5 bytes to PCSC : C1 32 01 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 12 bytes from PCSC with rv=0 : 83 81 00 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 12
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] PBM for provider 2: 8100000000000000
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] Request provider 3
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 5 bytes to PCSC : C1 12 02 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 27 bytes from PCSC with rv=0 : 00 65 43 59 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 27
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] provider 3: 0065, valid: 0, name: CYFRA+ 2, expiry date: 1992/01/01
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 8 bytes to PCSC : C1 34 00 00 03 00 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 2 bytes from PCSC with rv=0 : 90 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 2
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: sending 5 bytes to PCSC : C1 32 02 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: received 12 bytes from PCSC with rv=0 : 83 80 00 00 
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IO: PCSC doapi (0 ) (T=0), 12
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] PBM for provider 3: 8000000000000000
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] providers: 3 (0000,0068,0065)
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] Trying to switch to nagra layer of this card!
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IFD: Transmit size 5 bytes, expected len 5 bytes, delay 0 us, timeout=10000000 us
2014/09/17 13:20:39  1BB2F50 r cyfra+ [pcsc] IFD: Transmit:
2014/09/17 13:20:39  1BB2F50    80 CA 00 00 11 

and OSCam restarts again ;)

comment:5 by theparasol, 10 years ago

Tnx, but actually I was refering to a gdb debug log with exact point of crash.

by theparasol, 10 years ago

Attachment: switchtonagratryfix1.patch added

Does fix anything at all?

comment:6 by theparasol, 10 years ago

update:

got new idea, forget about switchtonagratryfix1.patch​

comment:7 by ni hao, 10 years ago

Resolution: fixed
Status: newclosed

r9852 works for me

comment:8 by khimtiki, 10 years ago

Resolution: fixed
Status: closedreopened

Just compiled r9852, but nothing changed for me. It still restarts at the same point.
For tests backed again to r9848 and card init works perfectly as I pasted log yesterday.

Tried gdb, but I don't know if I did it correctly:

# cd /var/Oscam
# gdb oscam
...
> (gdb) r -c/var/Oscam/config

and here's the output:

GNU gdb (Debian 7.7.1+dfsg-3) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from oscam...(no debugging symbols found)...done.
(gdb) (gdb) (gdb) (gdb) (gdb) (gdb) (gdb) (gdb) (gdb) (gdb) (gdb) (gdb) qwqStarting program: /var/Oscam/oscam -c/var/Oscam/config -d48
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Inferior 1 (process 15837) exited normally]
Starting program: /var/Oscam/oscam -c/var/Oscam/config
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Inferior 1 (process 15872) exited normally]

It's just exiting during reading card.
My friend reported in phoenix and internal readers there's no problem with card init.
Is it PCSC readers related problem only? Stopped OScam, restarted pcscd daemon, started OScam again, but it didn't help too.

comment:9 by ni hao, 10 years ago

Sorry I was still testing with 9848 (pff), Unfortunately 9852 does not cover the problem

comment:10 by stefansat sat, 10 years ago

I think the problem is the use off variables and or functions defined in header :
icc_async.h

which are now used in reader-seca.c

#include "csctapi/icc_async.h"

reader-seca.c is for all usable hardware card readers.

icc_async only for the serial ones. I gues ,...

But the PCSC is a full automated very very good card reader.

Which command excactly brings oscam in a crash I don't . But think You should look at the incompatible icc_async commands for that reader. Those commands are for serial based readers. Like phoenix,smargo and internal readers. Not for PCSC readers. And the reader-seca.c was made for ALL readers not only serial ones.

comment:11 by theparasol, 10 years ago

icc_async is always used, no exceptions.
Crashreport is useless, use this manual to create one:

http://www.streamboard.tv/wbb2/thread.php?threadid=30975

comment:12 by khimtiki, 10 years ago

@theparasol, thanks for link :)
Here's a most interesting debug output:

...
...
19:53:10   6B46E0 r cyfra+ [pcsc] Trying to switch to nagra layer of this card!

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffeffaa700 (LWP 7027)]
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000000409fc6 in ICC_Async_Transmit (reader=0x69f060, size=5, expectedlen=1, data=0x68ebc1 <ins80> "\200", <incomplete sequence \312>, delay=0, timeout=0) at csctapi/icc_async.c:281
#2  0x000000000042d22e in seca_card_init (reader=0x69f060, newatr=0x69f060) at reader-seca.c:249
#3  0x0000000000425f01 in reader_get_cardsystem (reader=reader@entry=0x69f060, atr=atr@entry=0x7fffeffa9de0) at reader-common.c:134
#4  0x00000000004262fb in cardreader_do_reset (reader=0x69f060) at reader-common.c:184
#5  0x000000000044d190 in work_thread (ptr=0x7fffdc000e70) at oscam-work.c:291
#6  0x00007ffff73660a4 in start_thread (arg=0x7fffeffaa700) at pthread_create.c:309
#7  0x00007ffff6e97c2d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
(gdb)

Forgot version! r9852 of course :D

Last edited 10 years ago by khimtiki (previous) (diff)

comment:13 by theparasol, 10 years ago

Yes, tnx a lot... got a fresh idea to fix it.

Something else pokes in my eye:
2014/09/17 13:20:39 1BB2F50 r cyfra+ [pcsc] IO: sending 5 bytes to PCSC : C1 12 02 00
2014/09/17 13:20:39 1BB2F50 r cyfra+ [pcsc] IO: sending 8 bytes to PCSC : C1 34 00 00 03 00 00

Hexdump always omits the last char ;)

comment:14 by khimtiki, 10 years ago

Resolution: worksforme
Status: reopenedclosed

Yes, bingo! Card init works for me in r9853 :)

Note: See TracTickets for help on using tickets.