Skip to content

[C++][Gandiva] Cache size can be negative number #41329

@zanmato1984

Description

@zanmato1984

Describe the bug, including details regarding any error messages, version, and platform.

I think the original purpose of the following check is to set gandiva cache size to the predefined default value (5000) for invalid/zero/negative numbers:

size_t capacity = DEFAULT_CACHE_SIZE;
auto maybe_env_cache_size = ::arrow::internal::GetEnvVar("GANDIVA_CACHE_SIZE");
if (maybe_env_cache_size.ok()) {
const auto env_cache_size = *std::move(maybe_env_cache_size);
if (!env_cache_size.empty()) {
capacity = std::atol(env_cache_size.c_str());
if (capacity <= 0) {
ARROW_LOG(WARNING) << "Invalid cache size provided in GANDIVA_CACHE_SIZE. "
<< "Using default cache size: " << DEFAULT_CACHE_SIZE;
capacity = DEFAULT_CACHE_SIZE;
}
}
}
return static_cast<int>(capacity);

However it will fail checking if the value is negative because it is using unsigned type size_t to do the <= 0 check.

Component(s)

C++

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions