Project

General

Profile

Actions

Bug #20310

closed

ASAN fake stacks need to be marked during GC for non-current execution context

Added by kjtsanaktsidis (KJ Tsanaktsidis) 4 months ago. Updated 3 months ago.


Description

When ASAN (address sanitizer) is enabled, the compiler does not necessarily store all local variables on the real machine stack; instead, locals can be stored in per-frame heap allocated memory which ASAN uses to detect things like stack-use-after-return ("fake stacks"). A pointer to the fake stack is left on the real machine stack, so it's possible to discover these fake stacks during GC and mark locals stored there as well.

At the moment, Ruby is currently marking these fake stacks for the current execution context which triggered GC, as part of mark_current_machine_context: https://github.com/ruby/ruby/blob/fe0b704df5553bdd59e90650ffbbfac785a2e48a/gc.c#L6411. However, there are other machine stacks which also need to be marked like this:

We need to make these two kinds of stacks perform the same ASAN fake stack marking as mark_current_machine_context does.

(P.S. - callcc continuations are another kind of machine stack which get marked, but ASAN is not compatible with callcc, so this doesn't really matter).

(P.S. - it appears to me that the currently-switched-to fiber will have its stack marked twice; once in rb_execution_context_mark or mark_current_machine_context, and once in cont_mark`; if this is true, I will fix this too)


Related issues 1 (1 open0 closed)

Related to Ruby master - Misc #20387: Meta-ticket for ASAN supportAssignedkjtsanaktsidis (KJ Tsanaktsidis)Actions

Updated by mame (Yusuke Endoh) 3 months ago

Discussed at the dev meeting, and @ko1 (Koichi Sasada) said the PR looks good to him.

Actions #3

Updated by kjtsanaktsidis (KJ Tsanaktsidis) 3 months ago

  • Related to Misc #20387: Meta-ticket for ASAN support added
Actions #4

Updated by Anonymous 3 months ago

  • Status changed from Assigned to Closed

Applied in changeset git|48d3bdddbaeabed5fb6a97bfbe65e250d1383a9c.


Move asan_fake_stack_handle to EC, not thread

It's really a property of the EC; each fiber (which has its own EC) also
has its own asan_fake_stack_handle.

[Bug #20310]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0