Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion keygeneration on ios using clang(libc++) never terminates

Received: by 10.180.84.234 with SMTP id c10mr2471437wiz.4.1351543292901;
        Mon, 29 Oct 2012 13:41:32 -0700 (PDT)
X-BeenThere: cryptopp-users@googlegroups.com
Received: by 10.180.95.40 with SMTP id dh8ls1527907wib.0.gmail; Mon, 29 Oct
 2012 13:41:14 -0700 (PDT)
Received: by 10.181.12.101 with SMTP id ep5mr2469170wid.1.1351543274237;
        Mon, 29 Oct 2012 13:41:14 -0700 (PDT)
Received: by 10.181.12.101 with SMTP id ep5mr2469169wid.1.1351543274226;
        Mon, 29 Oct 2012 13:41:14 -0700 (PDT)
Return-Path: <fraser.hutchi...@gmail.com>
Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46])
        by gmr-mx.google.com with ESMTPS id z7si420278wiw.1.2012.10.29.13.41.14
        (version=TLSv1/SSLv3 cipher=OTHER);
        Mon, 29 Oct 2012 13:41:14 -0700 (PDT)
Received-SPF: pass (google.com: domain of fraser.hutchi...@gmail.com designates 74.125.82.46 as permitted sender) client-ip=74.125.82.46;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of fraser.hutchi...@gmail.com designates 74.125.82.46 as permitted sender) smtp.mail=fraser.hutchi...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-wg0-f46.google.com with SMTP id dt12so2701865wgb.27
        for <cryptopp-users@googlegroups.com>; Mon, 29 Oct 2012 13:41:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=message-id:date:from:user-agent:mime-version:to:cc:subject
         :references:in-reply-to:content-type:content-transfer-encoding;
        bh=QlQDuxYFpyLmGNNtRJTi6h8pyD+movkgoP6T/rRh2uA=;
        b=W1RoH9nduF7nuYlp/m1umY7UFAq4pOa2YdRgEwDc1lN7j5yHGLIOfJdmYuQ/woaK7l
         iZ6aSXCIcg5Md5DVnGKwxirQTf4ZGeweoMyy37f5NY+JW+hsH4Mbt/3fZBlUITMq+RG4
         BFUkDmWn26ZMEbkV7tqmxSdCoW1QDgTxGhFYtSnq6WuYecSEPjluEGRx+vTOon34Vrxm
         8KFneLginyCPGqjvrvQdht8HYZAGDP6mwk7Pu7Fjsc8dryzSN7hms/Wz8Z/ZXZTP7h9/
         CZAOYgWPTKZnQcfsThlQuqAaj10Bm4EmyoGPh+JBql4v48AIrPcVWuTe5Wl73SqgtzBd
         9ucw==
Received: by 10.180.99.97 with SMTP id ep1mr17029322wib.9.1351543273999;
        Mon, 29 Oct 2012 13:41:13 -0700 (PDT)
Return-Path: <fraser.hutchi...@gmail.com>
Received: from [192.168.1.100] (host-92-18-202-141.as13285.net. [92.18.202.141])
        by mx.google.com with ESMTPS id ay10sm12971278wib.2.2012.10.29.13.41.12
        (version=SSLv3 cipher=OTHER);
        Mon, 29 Oct 2012 13:41:13 -0700 (PDT)
Message-ID: <508EE9E6.6080...@googlemail.com>
Date: Mon, 29 Oct 2012 20:41:10 +0000
From: Fraser Hutchison <fraser.hutchi...@gmail.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
MIME-Version: 1.0
To: Marshall Clow <mclow.li...@gmail.com>
CC: "cryptopp-users@googlegroups.com" <cryptopp-users@googlegroups.com>
Subject: Re: keygeneration on ios using clang(libc++) never terminates
References: <34614981.p...@talk.nabble.com> <C7A46DDA-27BB-4300-A9CE-F1530E544...@gmail.com>
In-Reply-To: <C7A46DDA-27BB-4300-A9CE-F1530E544...@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


On 29/10/2012 14:39, Marshall Clow wrote:
> On Oct 29, 2012, at 6:08 AM, thwang <nab...@wang-nielsen.dk> wrote:
>
>> Hi all
>>
>> I have recently change compiler, from gcc(libstdc++) to clang(libc++) on
>> iOS. After the change the generation of key, using the following snib, never
>> terminates.
>> ...
>> CryptoPP::RSAES< CryptoPP::OAEP <CryptoPP::SHA1> >::PrivateKey
>> privateSessionKey;
>> CryptoPP::AutoSeededX917RNG<CryptoPP::AES> rng;
>> privateSessionKey.GenerateRandomWithKeySize(rng, 2048);
>> ...
>>
>> I haunted it dow to be related to the use of vector<bool> in
>> nbtheory.cpp(line 310) which seems to give unexpected values when using the
>> clang(and libc++).
>> ..
>> 308 bool PrimeSieve::NextCandidate(Integer &c)
>> 309 {
>> 310      bool safe = SafeConvert(std::find(m_sieve.begin()+m_next,
>> m_sieve.end(), false) - m_sieve.begin(), m_next);
>> 311        assert(safe);
>> 312      if (m_next == m_sieve.size())
>> ..
>>
>> I isolated the issue to the following example:
>> std::vector<bool> my_vector;
>> my_vector.push_back(true);
>> my_vector.push_back(false);
>> my_vector.push_back(true);
>> my_vector.push_back(true);
>> my_vector.push_back(true);
>> my_vector.push_back(false);
>> my_vector.push_back(true);
>> long idx = std::find(my_vector.begin()+2, my_vector.end(), false) -
>> my_vector.begin();
>> std::cout << "idx:" << idx << std::endl;
>>
>> which returns
>> idx:0
>> when using clang (and libc++) and
>> idx:5
>> when using gcc (and libstdc++) as expected.
>>
>> Can anybody confirm this issue?
> Nice catch! - thanks for the simple test case.
>
> I can confirm that this issue is present in the shipping libc++ (tested with Xcode 4.5.1)
> I can also confirm that this issue has been fixed in the libc++ source repository at:
> 	https://llvm.org/svn/llvm-project/libcxx/trunk
>
> A short term fix would be to replace just the file "__bit_reference" in your Xcode installation (after backing up, of course) with the one from the libc++ source repo.
> On my system, that's in:
> 	/Applications/Xcode.app/Contents/Developer/Toolchain/XcodeDefault.xctoolchain/usr/lib/c++/v1/__bit_reference
>
> -- Marshall
>
> Marshall Clow     Idio Software   <mailto:mclow.li...@gmail.com>
>
> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
>          -- Yu Suzuki
>

Hi there,

I reported this a while back: 
http://sourceforge.net/apps/trac/cryptopp/ticket/17

It looks like there's not much activity in the bug tracker - should I 
have reported this elsewhere?

Thanks,
Fraser.