help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Cleanup resources on shell exit


From: Andy Chu
Subject: Re: [Help-bash] Cleanup resources on shell exit
Date: Mon, 6 May 2019 23:28:51 -0700

Unless I'm missing something, it sounds like you should just unset
LD_PRELOAD before invoking bash / shell scripts.  Presumably you want to
test some other programs for memory safety bugs with ASAN, not bash.

There are a lot of ways to do that, but one is to put tiny shell wrappers
in your $PATH that ensure the correct environment, either for bash (unset
LD_PRELOAD), or for the tools you want to test (LD_PRELOAD).

I didn't see any evidence of ASAN runs while looking at the bash build
system, so my guess is that those are legitimate errors in the bash
source.  Pretty much any large C program will have some memory errors if
nobody explicitly went and fixed them.

So you could either propose patches to fix them, or just don't run ASAN on
bash.

Andy







On Mon, May 6, 2019 at 11:18 PM Jeffrey Walton <address@hidden> wrote:

> Hi Everyone,
>
> I'm having trouble testing some libraries and programs with Address
> Sanitizer. I'm interested in findings that are part of Asan but not
> part of Valgrind.
>
> Asan needs to be loaded early but some build systems use an ordering
> that is not conducive for Asan. For example, -lasan may be one of the
> last libraries linked. A workaround is to LD_PRELOAD=<asan lib>.
>
> When I attempt to use LD_PRELOAD Bash is producing findings that are
> tainting the tests. Sometimes the tests fail to run, and other times
> the tests run but report results from Bash. For example, this should
> build and install OpenSSL and its dependencies with Asan, and then run
> the self tests:
>
>     LD_PRELOAD=/usr/lib64/libasan.so.5 INSTX_ASAN=1 \
>         INSTX_PREFIX=/var/sanitize ./build-openssl.sh
>
> Each subshell in the script generates one of these:
>
> =================================================================
> ==11296==ERROR: LeakSanitizer: detected memory leaks
>
> Direct leak of 23 byte(s) in 1 object(s) allocated from:
>     #0 0x7f93594ddc08 in __interceptor_malloc
> (/usr/lib64/libasan.so.5+0xefc08)
>     #1 0x564763da8341 in xmalloc (/usr/bin/bash+0x8a341)
>
> SUMMARY: AddressSanitizer: 23 byte(s) leaked in 1 allocation(s).
>
> The errors cause the script to d bad things, like mis-detect bitness,
> mis-detect available options, etc.
>
> My question is, how can I tell Bash to cleanup its resources? Is there
> an envar or option to get it to run more strictly or better behaved?
>
> Thanks in advance.
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]