tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Handling __cxa_atexit(a,b,NULL)
In article <d3213281-d9a4-cf07-25bd-da552a0a4d62%gmx.com@localhost>,
Kamil Rytarowski <n54%gmx.com@localhost> wrote:
>-=-=-=-=-=-
>-=-=-=-=-=-
>
>I've narrowed down a bug in TSan/NetBSD with __cxa_atexit(a,b,NULL)
>handling. I'm not sure whether the problem is in NetBSD or TSan.
>
>extern "C" int __cxa_atexit ( void (*f)(void *), void *p, void *d );
>
>TSan intercepts all atexit() and __cxa_atexit() calls and wraps them in
>setup_at_exit_wrapper(() into a new struct that preserves the original
>arguments "a" and "b" from __cxa_atexit() / "a" from atexit(). In case
>of intercepting atexit() calls we end up with __cxa_atexit(x,y,NULL). In
>libc we handle this variation in the same way as atexit(x) and drop the
>"y" argument.
>
>static int setup_at_exit_wrapper(ThreadState *thr, uptr pc, void(*f)(),
> void *arg, void *dso) {
> AtExitCtx *ctx = (AtExitCtx*)InternalAlloc(sizeof(AtExitCtx));
> ctx->f = f;
> ctx->arg = arg;
> Release(thr, pc, (uptr)ctx);
> // Memory allocation in __cxa_atexit will race with free during exit,
> // because we do not see synchronization around atexit callback list.
> ThreadIgnoreBegin(thr, pc);
>
>
> int res = REAL(__cxa_atexit)(at_exit_wrapper, ctx, dso);
> ThreadIgnoreEnd(thr, pc);
> return res;
>}
>
The problem is with NetBSD and the patch is correct.
Please fix and ask for a -8 pullup.
christos
Home |
Main Index |
Thread Index |
Old Index