Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

This login session: $13.76, but for you $11.88.


devel / comp.lang.c++ / Turn off Address Sanitiser for just one function call

SubjectAuthor
* Turn off Address Sanitiser for just one function callFrederick Virchanza Gotham
`* Re: Turn off Address Sanitiser for just one function callAndrey Tarasevich
 `- Re: Turn off Address Sanitiser for just one function callFrederick Virchanza Gotham

1
Turn off Address Sanitiser for just one function call

<8415e920-7106-4c1a-b4ad-a6b19bf77c3bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:ad4:59c7:0:b0:62d:e362:60a7 with SMTP id el7-20020ad459c7000000b0062de36260a7mr1069798qvb.10.1687041551253;
Sat, 17 Jun 2023 15:39:11 -0700 (PDT)
X-Received: by 2002:ac8:5cc8:0:b0:3f6:aee9:d91 with SMTP id
s8-20020ac85cc8000000b003f6aee90d91mr2383442qta.1.1687041551044; Sat, 17 Jun
2023 15:39:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Sat, 17 Jun 2023 15:39:10 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=92.40.202.79; posting-account=w4UqJAoAAAAYC-PItfDbDoVGcg0yISyA
NNTP-Posting-Host: 92.40.202.79
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8415e920-7106-4c1a-b4ad-a6b19bf77c3bn@googlegroups.com>
Subject: Turn off Address Sanitiser for just one function call
From: cauldwel...@gmail.com (Frederick Virchanza Gotham)
Injection-Date: Sat, 17 Jun 2023 22:39:11 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1764
 by: Frederick Virchanza - Sat, 17 Jun 2023 22:39 UTC

I'm currently writing a program that decrypts its own machine code at runtime.

The function that writes to the code memory is causing a crash because it's being flagged by Address Sanitizer.

I want to have a way to be able to call any function and to have the choice of disabling address sanitiser for that one invocation of the function (but not for other invocations).

Here's what I've written:

template<typename Lambda>
void NoSanitizeAddress(Lambda &f) __attribute__((__no_sanitize_address__));

template<typename Lambda>
void NoSanitizeAddress(Lambda &f)
{ f();
}

int main(void)
{ NoSanitizeAddress( [](){ SomeFunction(); } );
}

This works fine. I just wonder if there's a better way of doing this though.

Re: Turn off Address Sanitiser for just one function call

<u6lntd$1e63h$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c++
Subject: Re: Turn off Address Sanitiser for just one function call
Date: Sat, 17 Jun 2023 18:50:35 -0700
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <u6lntd$1e63h$1@dont-email.me>
References: <8415e920-7106-4c1a-b4ad-a6b19bf77c3bn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 18 Jun 2023 01:50:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="095c473512c6af65cf2e47bfd963f929";
logging-data="1513585"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ym2gOAQXzRt3OcGgetZTT"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.11.2
Cancel-Lock: sha1:cVGGUCZoMkz9wl65rEISYedsSrc=
In-Reply-To: <8415e920-7106-4c1a-b4ad-a6b19bf77c3bn@googlegroups.com>
Content-Language: en-US
 by: Andrey Tarasevich - Sun, 18 Jun 2023 01:50 UTC

On 06/17/23 3:39 PM, Frederick Virchanza Gotham wrote:
>
> Here's what I've written:
>
> template<typename Lambda>
> void NoSanitizeAddress(Lambda &f) __attribute__((__no_sanitize_address__));
>
> template<typename Lambda>
> void NoSanitizeAddress(Lambda &f)
> {
> f();
> }
>
> int main(void)
> {
> NoSanitizeAddress( [](){ SomeFunction(); } );
> }
>
> This works fine. I just wonder if there's a better way of doing this though.

"This works fine"? Really? Lambda expression in C++ is a prvalue. How
did you manage to pass it by an lvalue reference?

Anyhoo, what role does the lambda play here anyway? Why not just

int main(void)
{
NoSanitizeAddress(SomeFunction);
}

?

--
Best regards,
Andrey

Re: Turn off Address Sanitiser for just one function call

<fce07082-9758-4b76-a45e-702defa6dc15n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:ac8:5f8b:0:b0:3f6:b519:9487 with SMTP id j11-20020ac85f8b000000b003f6b5199487mr3160190qta.7.1687102647775;
Sun, 18 Jun 2023 08:37:27 -0700 (PDT)
X-Received: by 2002:a05:620a:1a08:b0:762:5602:29ae with SMTP id
bk8-20020a05620a1a0800b00762560229aemr538533qkb.6.1687102647549; Sun, 18 Jun
2023 08:37:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Sun, 18 Jun 2023 08:37:27 -0700 (PDT)
In-Reply-To: <u6lntd$1e63h$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=92.40.182.234; posting-account=w4UqJAoAAAAYC-PItfDbDoVGcg0yISyA
NNTP-Posting-Host: 92.40.182.234
References: <8415e920-7106-4c1a-b4ad-a6b19bf77c3bn@googlegroups.com> <u6lntd$1e63h$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fce07082-9758-4b76-a45e-702defa6dc15n@googlegroups.com>
Subject: Re: Turn off Address Sanitiser for just one function call
From: cauldwel...@gmail.com (Frederick Virchanza Gotham)
Injection-Date: Sun, 18 Jun 2023 15:37:27 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1822
 by: Frederick Virchanza - Sun, 18 Jun 2023 15:37 UTC

On Sunday, June 18, 2023 at 2:50:54 AM UTC+1, Andrey Tarasevich wrote:
>
> "This works fine"? Really? Lambda expression in C++ is a prvalue. How
> did you manage to pass it by an lvalue reference?

I had changed it to "Lambda const &f" before copy-pasting.


> Anyhoo, what role does the lambda play here anyway? Why not just
>
> int main(void)
> {
> NoSanitizeAddress(SomeFunction);
> }

Because it might be more complex:

bool retval;
NoSanitizeAddress( [&argc,argv,&retval](void) -> void { retval = SomeFunc(++argc,argv); } );


devel / comp.lang.c++ / Turn off Address Sanitiser for just one function call

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor