Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

You can't evaluate a man by logic alone. -- McCoy, "I, Mudd", stardate 4513.3


devel / comp.lang.c++ / Iterator-debugging even works across thread-boundaries

SubjectAuthor
o Iterator-debugging even works across thread-boundariesBonita Montero

1
Iterator-debugging even works across thread-boundaries

<ubq9m5$pi5k$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1086&group=comp.lang.c%2B%2B#1086

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Iterator-debugging even works across thread-boundaries
Date: Sat, 19 Aug 2023 13:39:50 +0200
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <ubq9m5$pi5k$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 19 Aug 2023 11:39:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b4c32673d42c2dc7a23d473dc32a06f5";
logging-data="837812"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/42GqHc2Pfo9q7Re0sr2AwQVtd7kYtl20="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:35Be39hMZjBUZIY4UuZZXzBadss=
Content-Language: de-DE
 by: Bonita Montero - Sat, 19 Aug 2023 11:39 UTC

I just tested if iterator debugging is thrread-safe.

#include <thread>
#include <string>
#include <semaphore>

using namespace std;

int main()
{ constexpr size_t N = 1ull << 20;
binary_semaphore semZero( false );
jthread thread;
{
binary_semaphore semHalf( 0 );
string str( N, '*' );
thread = jthread( [&]( string &str )
{
char sum = 0;
for( string::iterator it = str.begin(), brk = it + N / 2, end =
str.end(); it != end; *it++ = '+' )
if( it == brk )
semHalf.release( 1 ),
semZero.acquire();
}, ref( str ) );
semHalf.acquire();
}
semZero.release( 1 );
}

So with iterator debugging you can have use after free protection at
least with MSVC. I tried that with g++'s libstdc++ (-D_GLIBCXX_DEBUG)
and libc++ (-D_LIBCPP_DEBUG=1) and I get a normal crash instead of
debugging information.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor