| 182 | } |
| 183 | |
| 184 | bool IsDebugEnabled() { |
| 185 | static const bool is_enabled = []() { |
| 186 | auto maybe_env_value = internal::GetEnvVar(kDebugMemoryEnvVar); |
| 187 | if (!maybe_env_value.ok()) { |
| 188 | return false; |
| 189 | } |
| 190 | auto env_value = *std::move(maybe_env_value); |
| 191 | if (env_value.empty() || env_value == "none") { |
| 192 | return false; |
| 193 | } |
| 194 | auto debug_state = DebugState::Instance(); |
| 195 | if (env_value == "abort") { |
| 196 | debug_state->SetHandler(DebugAbort); |
| 197 | return true; |
| 198 | } |
| 199 | if (env_value == "trap") { |
| 200 | debug_state->SetHandler(DebugTrap); |
| 201 | return true; |
| 202 | } |
| 203 | if (env_value == "warn") { |
| 204 | debug_state->SetHandler(DebugWarn); |
| 205 | return true; |
| 206 | } |
| 207 | ARROW_LOG(WARNING) << "Invalid value for " << kDebugMemoryEnvVar << ": '" << env_value |
| 208 | << "'. Valid values are 'abort', 'trap', 'warn', 'none'."; |
| 209 | return false; |
| 210 | }(); |
| 211 | |
| 212 | return is_enabled; |
| 213 | } |
| 214 | |
| 215 | // An allocator wrapper that adds a suffix at the end of allocation to check |
| 216 | // for writes beyond the allocated area. |
no test coverage detected