{"action":"created","issue":{"url":"https://api.github.com/repos/OpenSC/libp11/issues/215","repository_url":"https://api.github.com/repos/OpenSC/libp11","labels_url":"https://api.github.com/repos/OpenSC/libp11/issues/215/labels{/name}","comments_url":"https://api.github.com/repos/OpenSC/libp11/issues/215/comments","events_url":"https://api.github.com/repos/OpenSC/libp11/issues/215/events","html_url":"https://github.com/OpenSC/libp11/issues/215","id":311342769,"node_id":"MDU6SXNzdWUzMTEzNDI3Njk=","number":215,"title":"Current master fails tests (infinite loop)","user":{"login":"mouse07410","id":5923577,"node_id":"MDQ6VXNlcjU5MjM1Nzc=","avatar_url":"https://avatars1.githubusercontent.com/u/5923577?v=4","gravatar_id":"","url":"https://api.github.com/users/mouse07410","html_url":"https://github.com/mouse07410","followers_url":"https://api.github.com/users/mouse07410/followers","following_url":"https://api.github.com/users/mouse07410/following{/other_user}","gists_url":"https://api.github.com/users/mouse07410/gists{/gist_id}","starred_url":"https://api.github.com/users/mouse07410/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mouse07410/subscriptions","organizations_url":"https://api.github.com/users/mouse07410/orgs","repos_url":"https://api.github.com/users/mouse07410/repos","events_url":"https://api.github.com/users/mouse07410/events{/privacy}","received_events_url":"https://api.github.com/users/mouse07410/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-04-04T18:33:24Z","updated_at":"2018-06-11T15:18:36Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"After https://github.com/OpenSC/libp11/pull/214 has been merged, the current master started failing its tests. It enters a recursive loop when token initialization requires getting random bytes that in turn requires token initialization, etc. I've attached the logs [here](https://github.com/OpenSC/libp11/pull/214). Some excerpts:\r\n\r\n```\r\n. . . . .\r\n/Applications/Xcode.app/Contents/Developer/usr/bin/make  check-TESTS\r\nPASS: rsa-testpkcs11.softhsm\r\nPASS: rsa-testfork.softhsm\r\nPASS: rsa-testlistkeys.softhsm\r\nFAIL: rsa-evp-sign.softhsm\r\nPASS: ec-testfork.softhsm\r\nFAIL: fork-change-slot.softhsm\r\n============================================================================\r\nTestsuite summary for libp11 0.4.8_git\r\n============================================================================\r\n# TOTAL: 6\r\n# PASS:  4\r\n# SKIP:  0\r\n# XFAIL: 0\r\n# FAIL:  2\r\n# XPASS: 0\r\n# ERROR: 0\r\n============================================================================\r\nSee tests/test-suite.log\r\n============================================================================\r\n$ cat tests/test-suite.log\r\n============================================\r\n   libp11 0.4.8_git: tests/test-suite.log\r\n============================================\r\n\r\n# TOTAL: 6\r\n# PASS:  4\r\n# SKIP:  0\r\n# XFAIL: 0\r\n# FAIL:  2\r\n# XPASS: 0\r\n# ERROR: 0\r\n\r\n.. contents:: :depth: 2\r\n\r\nFAIL: rsa-evp-sign.softhsm\r\n==========================\r\n\r\nCurrent directory: /Users/ur20980/src/libp11/tests\r\nSource directory: .\r\nOutput directory: output.57104\r\n-n * Initializing smart card... \r\nok\r\nImporting\r\nUsing slot 0 with a present token (0x16ba6051)\r\nUsing slot 0 with a present token (0x16ba6051)\r\nUsing slot 0 with a present token (0x16ba6051)\r\nFinished\r\n***************\r\nListing objects\r\n***************\r\nUsing slot 0 with a present token (0x16ba6051)\r\nPrivate Key Object; RSA \r\n  label:      server-key\r\n  ID:         01020304\r\n  Usage:      decrypt, sign, unwrap\r\nPublic Key Object; RSA 2048 bits\r\n  label:      server-key\r\n  ID:         01020304\r\n  Usage:      encrypt, verify, wrap\r\nCertificate Object; type = X.509 cert\r\n  label:      server-key\r\n  ID:         01020304\r\nPKCS#11: Initializing the engine\r\nPKCS#11: Initializing the engine\r\n. . . [last line repeats 48000 times] . . .\r\nPKCS#11: Initializing the engine\r\nPKCS#11: Initializing the engine\r\n./rsa-evp-sign.softhsm: line 33: 57116 Segmentation fault: 11  ./evp-sign ctrl false \"${outdir}/engines.cnf\" ${PRIVATE_KEY} ${PUBLIC_KEY} ${MODULE}\r\nBasic PKCS #11 test, using ctrl failed\r\nFAIL rsa-evp-sign.softhsm (exit status: 1)\r\n\r\nFAIL: fork-change-slot.softhsm\r\n==============================\r\n\r\nCurrent directory: /Users/ur20980/src/libp11/tests\r\nSource directory: .\r\nOutput directory: output.57540\r\n-n * Initializing smart card... \r\nok\r\n-n * Initializing smart card... \r\nok\r\nKey pair generated:\r\nPrivate Key Object; RSA \r\n  label:      pkey\r\n  ID:         01020304\r\n  Usage:      decrypt, sign, unwrap\r\nPublic Key Object; RSA 1024 bits\r\n  label:      pkey\r\n  ID:         01020304\r\n  Usage:      encrypt, verify, wrap\r\nFound token (22aba925-99c8-d1ee-8db7-63862b8a7bae) with matching token label.\r\nThe token (output.57540/softhsm-testpkcs11.db/22aba925-99c8-d1ee-8db7-63862b8a7bae) has been deleted.\r\nkill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]\r\n./fork-change-slot.softhsm: line 66: 57550 Segmentation fault: 11  ./fork-change-slot \"pkcs11:token=token2;object=pkey;type=private;pin-value=$PIN\" \"${outdir}/engines.cnf\" ${MODULE}\r\nFAIL fork-change-slot.softhsm (exit status: 1)\r\n```\r\n\r\nProcess sample:\r\n```\r\nSampling process 20624 for 3 seconds with 1 millisecond of run time between samples\r\nSampling completed, processing symbols...\r\nAnalysis of sampling evp-sign (pid 20624) every 1 millisecond\r\nProcess:         evp-sign [20624]\r\nPath:            /Users/ur20980/src/libp11/tests/.libs/evp-sign\r\nLoad Address:    0x10402a000\r\nIdentifier:      evp-sign\r\nVersion:         0\r\nCode Type:       X86-64\r\nParent Process:  sh [20612]\r\n\r\nDate/Time:       2018-04-04 13:25:08.525 -0400\r\nLaunch Time:     2018-04-04 13:23:37.908 -0400\r\nOS Version:      Mac OS X 10.12.6 (16G1314)\r\nReport Version:  7\r\nAnalysis Tool:   /usr/bin/sample\r\n----\r\n\r\nCall graph:\r\n    2447 Thread_4137815   DispatchQueue_1: com.apple.main-thread  (serial)\r\n      1829 OSSLRNG::generateRandom(ByteString&, unsigned long)  (in libsofthsm2.so) + 49  [0x1043d8ca1]\r\n      + 1829 RAND_bytes  (in libcrypto.1.0.0.dylib) + 60  [0x10416183c]\r\n      +   1829 engine_table_select  (in libcrypto.1.0.0.dylib) + 267  [0x1041511ab]\r\n      +     1829 engine_unlocked_init  (in libcrypto.1.0.0.dylib) + 59  [0x1041501eb]\r\n      +       1829 ctx_init  (in libpkcs11.dylib) + 86  [0x1043647f6]\r\n      +         1829 ctx_init_libp11_unlocked  (in libpkcs11.dylib) + 96  [0x104364890]\r\n      +           1829 pkcs11_CTX_load  (in libpkcs11.dylib) + 101  [0x1043699c5]\r\n      +             1829 C_Initialize  (in libsofthsm2.so) + 25  [0x104378909]\r\n      +               1829 SoftHSM::C_Initialize(void*)  (in libsofthsm2.so) + 994  [0x1043922e2]\r\n      +                 1829 SlotManager::SlotManager(ObjectStore*)  (in libsofthsm2.so) + 506  [0x10440529a]\r\n      +                   1829 SlotManager::insertToken(ObjectStore*, unsigned long, ObjectStoreToken*)  (in libsofthsm2.so) + 56  [0x1044053f8]\r\n      +                     1829 Slot::Slot(ObjectStore*, unsigned long, ObjectStoreToken*)  (in libsofthsm2.so) + 63  [0x104405f7f]\r\n      +                       1829 Token::Token(ObjectStoreToken*)  (in libsofthsm2.so) + 136  [0x1044066e8]\r\n      +                         1829 SecureDataManager::SecureDataManager(ByteString const&, ByteString const&)  (in libsofthsm2.so) + 86  [0x1043e1a06]\r\n      +                           1829 SecureDataManager::initObject()  (in libsofthsm2.so) + 114  [0x1043e16d2]\r\n      +                             1829 OSSLRNG::generateRandom(ByteString&, unsigned long)  (in libsofthsm2.so) + 49  [0x1043d8ca1]\r\n      +                               1829 RAND_bytes  (in libcrypto.1.0.0.dylib) + 60  [0x10416183c]\r\n      +                                 1829 engine_table_select  (in libcrypto.1.0.0.dylib) + 267  [0x1041511ab]\r\n      +                                   1829 engine_unlocked_init  (in libcrypto.1.0.0.dylib) + 59  [0x1041501eb]\r\n      +                                     1829 ctx_init  (in libpkcs11.dylib) + 86  [0x1043647f6]\r\n      +                                       1829 ctx_init_libp11_unlocked  (in libpkcs11.dylib) + 96  [0x104364890]\r\n      +                                         1829 pkcs11_CTX_load  (in libpkcs11.dylib) + 101  [0x1043699c5]\r\n      +                                           1829 C_Initialize  (in libsofthsm2.so) + 25  [0x104378909]\r\n      +                                             1829 SoftHSM::C_Initialize(void*)  (in libsofthsm2.so) + 994  [0x1043922e2]\r\n      +                                               1829 SlotManager::SlotManager(ObjectStore*)  (in libsofthsm2.so) + 506  [0x10440529a]\r\n. . . . .\r\nTotal number in stack (recursive counted multiple, when >=5):\r\n        510       C_Initialize  (in libsofthsm2.so) + 25  [0x104378909]\r\n        509       Slot::Slot(ObjectStore*, unsigned long, ObjectStoreToken*)  (in libsofthsm2.so) + 63  [0x104405f7f]\r\n        509       pkcs11_CTX_load  (in libpkcs11.dylib) + 101  [0x1043699c5]\r\n        508       SlotManager::insertToken(ObjectStore*, unsigned long, ObjectStoreToken*)  (in libsofthsm2.so) + 56  [0x1044053f8]\r\n        508       ctx_init_libp11_unlocked  (in libpkcs11.dylib) + 96  [0x104364890]\r\n        507       SlotManager::SlotManager(ObjectStore*)  (in libsofthsm2.so) + 506  [0x10440529a]\r\n        507       SoftHSM::C_Initialize(void*)  (in libsofthsm2.so) + 994  [0x1043922e2]\r\n        507       ctx_init  (in libpkcs11.dylib) + 86  [0x1043647f6]\r\n        506       engine_unlocked_init  (in libcrypto.1.0.0.dylib) + 59  [0x1041501eb]\r\n        505       RAND_bytes  (in libcrypto.1.0.0.dylib) + 60  [0x10416183c]\r\n        505       engine_table_select  (in libcrypto.1.0.0.dylib) + 267  [0x1041511ab]\r\n        504       OSSLRNG::generateRandom(ByteString&, unsigned long)  (in libsofthsm2.so) + 49  [0x1043d8ca1]\r\n        503       SecureDataManager::initObject()  (in libsofthsm2.so) + 114  [0x1043e16d2]\r\n        502       SecureDataManager::SecureDataManager(ByteString const&, ByteString const&)  (in libsofthsm2.so) + 86  [0x1043e1a06]\r\n        501       Token::Token(ObjectStoreToken*)  (in libsofthsm2.so) + 136  [0x1044066e8]\r\n        48       malloc  (in libsystem_malloc.dylib) + 24  [0x7fffa8b69200]\r\n        46       operator new(unsigned long)  (in libc++abi.dylib) + 30  [0x7fffa75f2e0e]\r\n        44       malloc_zone_malloc  (in libsystem_malloc.dylib) + 107  [0x7fffa8b6a282]\r\n        31       File::readULong(unsigned long&)  (in libsofthsm2.so) + 50  [0x1043e8bd2]\r\n        25       std::__1::vector<unsigned char, SecureAllocator<unsigned char> >::__append(unsigned long)  (in libsofthsm2.so) + 273  [0x1043e10c1]\r\n        24       ObjectFile::isValid()  (in libsofthsm2.so) + 16  [0x1043f30b0]\r\n        21       File::readULong(unsigned long&)  (in libsofthsm2.so) + 83  [0x1043e8bf3]\r\n        21       szone_malloc_should_clear  (in libsystem_malloc.dylib) + 400  [0x7fffa8b6a472]\r\n        20       File::readULong(unsigned long&)  (in libsofthsm2.so) + 179  [0x1043e8c53]\r\n        20       OSToken::index(bool)  (in libsofthsm2.so) + 65  [0x1043ebea1]\r\n        20       ObjectFile::refresh(bool)  (in libsofthsm2.so) + 106  [0x1043f066a]\r\n        20       szone_malloc_should_clear  (in libsystem_malloc.dylib) + 0  [0x7fffa8b6a2e2]\r\n        19       ImageLoader::recursiveUpdateDepth(unsigned int)  (in dyld) + 111  [0x108a92797]\r\n        18       fread  (in libsystem_c.dylib) + 48  [0x7fffa8a5c380]\r\n        17       ObjectFile::ObjectFile(OSToken*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_strin\r\ng<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool)  (in libsofthsm2.so) + 344  [0x1043f0598]\r\n        15       SecureMemoryRegistry::add(void*, unsigned long)  (in libsofthsm2.so) + 0  [0x1043e4b40]\r\n        14       _platform_memmove$VARIANT$Haswell  (in libsystem_platform.dylib) + 0  [0x7fffa8bfaea0]\r\n        14       pthread_mutex_lock  (in libsystem_pthread.dylib) + 0  [0x7fffa8bff38c]\r\n. . . . .\r\nSort by top of stack, same collapsed (when >= 5):\r\n        __open  (in libsystem_kernel.dylib)        1766\r\n        mach_msg_trap  (in dyld)        64\r\n        __close_nocancel  (in libsystem_kernel.dylib)        61\r\n        lstat$INODE64  (in libsystem_kernel.dylib)        60\r\n        __getdirentries64  (in libsystem_kernel.dylib)        46\r\n        SecureMemoryRegistry::add(void*, unsigned long)  (in libsofthsm2.so)        35\r\n        SecureMemoryRegistry::remove(void*)  (in libsofthsm2.so)        30\r\n        __fcntl  (in libsystem_kernel.dylib)        29\r\n        szone_malloc_should_clear  (in libsystem_malloc.dylib)        25\r\n        __open_nocancel  (in libsystem_kernel.dylib)        23\r\n        fstat$INODE64  (in libsystem_kernel.dylib)        22\r\n        pthread_mutex_lock  (in libsystem_pthread.dylib)        18\r\n        free_tiny  (in libsystem_malloc.dylib)        16\r\n        _platform_memmove$VARIANT$Haswell  (in libsystem_platform.dylib)        15\r\n        tiny_malloc_from_free_list  (in libsystem_malloc.dylib)        15\r\n        __read_nocancel  (in libsystem_kernel.dylib)        14\r\n        _pthread_mutex_unlock_slow  (in libsystem_pthread.dylib)        9\r\n        pthread_mutex_unlock  (in libsystem_pthread.dylib)        9\r\n        szone_size  (in libsystem_malloc.dylib)        9\r\n        free  (in libsystem_malloc.dylib)        8\r\n        __fcntl_nocancel  (in libsystem_kernel.dylib)        6\r\n        set_tiny_meta_header_in_use  (in libsystem_malloc.dylib)        6\r\n        tiny_free_no_lock  (in libsystem_malloc.dylib)        6\r\n        File::File(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool, bool, bool, bool)  (in libsofthsm2.so)        5\r\n        ObjectFile::refresh(bool)  (in libsofthsm2.so)        5\r\n        default_zone_free_definite_size  (in libsystem_malloc.dylib)        5\r\n        malloc  (in libsystem_malloc.dylib)        5\r\n. . . . .\r\n```\r\nAnd the complete trace: \r\n[Sample of evp-sign.txt](https://github.com/OpenSC/libp11/files/1877094/Sample.of.evp-sign.txt)\r\n\r\n\r\nP.S. Might I suggest that it may not be a good idea merging something that fails Travis CI? *Yes I know - it failed because SoftHSMv2 was looking for EDDSA that the available OpenSSL did not provide/support. Still, if the tester fixed it and went past that issue - I'm sure he'd hit the failure I experienced.*\r\n"},"comment":{"url":"https://api.github.com/repos/OpenSC/libp11/issues/comments/396281038","html_url":"https://github.com/OpenSC/libp11/issues/215#issuecomment-396281038","issue_url":"https://api.github.com/repos/OpenSC/libp11/issues/215","id":396281038,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NjI4MTAzOA==","user":{"login":"williamcroberts","id":17750791,"node_id":"MDQ6VXNlcjE3NzUwNzkx","avatar_url":"https://avatars0.githubusercontent.com/u/17750791?v=4","gravatar_id":"","url":"https://api.github.com/users/williamcroberts","html_url":"https://github.com/williamcroberts","followers_url":"https://api.github.com/users/williamcroberts/followers","following_url":"https://api.github.com/users/williamcroberts/following{/other_user}","gists_url":"https://api.github.com/users/williamcroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/williamcroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williamcroberts/subscriptions","organizations_url":"https://api.github.com/users/williamcroberts/orgs","repos_url":"https://api.github.com/users/williamcroberts/repos","events_url":"https://api.github.com/users/williamcroberts/events{/privacy}","received_events_url":"https://api.github.com/users/williamcroberts/received_events","type":"User","site_admin":false},"created_at":"2018-06-11T15:18:36Z","updated_at":"2018-06-11T15:18:36Z","author_association":"CONTRIBUTOR","body":"@mouse07410 if the change [here](https://github.com/OpenSC/libp11/pull/224/files#diff-9b905ce79ee26163834b3e2a1832cb86L209) fixes the issue, then i'm dropping this.\r\n\r\nhttps://github.com/OpenSC/libp11/blob/master/src/eng_front.c#L244 is still setting the rand method for the pkcs11 engine wrapper, so it should still get the random data."}}
{"actor":{"display_login":"williamcroberts"}}