Skip to content

[C++][Acero] Use ASAN to replace current temp stack memory poisoning #41460

@zanmato1984

Description

@zanmato1984

Describe the enhancement requested

From the discussion at #41335 (comment), the arrow::util::TempVectorStack memory initialization (by filling 0xFFs [1]) seems not very useful in the sense that:

  1. If it is supposed to be work with the guards [2] at the edge of each stack frame, the guards are only checked in debug mode (note it is using ARROW_DCHECK) [3], making filling 0xFFs unnecessary in non-debug mode. And the debug-only guarding itself can fully leverage more decent memory poisoning strategy such as ASAN [4].
  2. If it is for non-debug mode too, then it might be unnecessary because the stack users are not assuming the stack memory to be initially filled with any particular content.

We may want to refine this by removing unnecessary memory initialization and/or using ASAN's manual memory poisoning.

[1]

std::memset(buffer->mutable_data(), 0xFF, size);

[2]
static constexpr uint64_t kGuard1 = 0x3141592653589793ULL;
static constexpr uint64_t kGuard2 = 0x0577215664901532ULL;

[3]
ARROW_DCHECK(reinterpret_cast<const uint64_t*>(buffer_->mutable_data() + top_)[-1] ==
kGuard2);
ARROW_DCHECK(top_ >= size);
top_ -= size;
ARROW_DCHECK(reinterpret_cast<const uint64_t*>(buffer_->mutable_data() + top_)[0] ==
kGuard1);

[4] https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning

Component(s)

C++

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions