Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parquet_field_list read_func lambda capture invalid this pointer #16440

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions cpp/src/io/parquet/compact_protocol_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ class parquet_field_bool : public parquet_field {
struct parquet_field_bool_list : public parquet_field_list<bool, FieldType::BOOLEAN_TRUE> {
parquet_field_bool_list(int f, std::vector<bool>& v) : parquet_field_list(f, v)
{
auto const read_value = [this](uint32_t i, CompactProtocolReader* cpr) {
auto const read_value = [&val = v](uint32_t i, CompactProtocolReader* cpr) {
auto const current_byte = cpr->getb();
assert_bool_field_type(current_byte);
this->val[i] = current_byte == static_cast<int>(FieldType::BOOLEAN_TRUE);
val[i] = current_byte == static_cast<int>(FieldType::BOOLEAN_TRUE);
};
bind_read_func(read_value);
}
Expand Down Expand Up @@ -188,8 +188,8 @@ template <typename T, FieldType EXPECTED_TYPE>
struct parquet_field_int_list : public parquet_field_list<T, EXPECTED_TYPE> {
parquet_field_int_list(int f, std::vector<T>& v) : parquet_field_list<T, EXPECTED_TYPE>(f, v)
{
auto const read_value = [this](uint32_t i, CompactProtocolReader* cpr) {
this->val[i] = cpr->get_zigzag<T>();
auto const read_value = [&val = v](uint32_t i, CompactProtocolReader* cpr) {
val[i] = cpr->get_zigzag<T>();
};
this->bind_read_func(read_value);
}
Expand Down Expand Up @@ -229,11 +229,11 @@ class parquet_field_string : public parquet_field {
struct parquet_field_string_list : public parquet_field_list<std::string, FieldType::BINARY> {
parquet_field_string_list(int f, std::vector<std::string>& v) : parquet_field_list(f, v)
{
auto const read_value = [this](uint32_t i, CompactProtocolReader* cpr) {
auto const read_value = [&val = v](uint32_t i, CompactProtocolReader* cpr) {
auto const l = cpr->get_u32();
CUDF_EXPECTS(l < static_cast<size_t>(cpr->m_end - cpr->m_cur), "string length mismatch");

this->val[i].assign(reinterpret_cast<char const*>(cpr->m_cur), l);
val[i].assign(reinterpret_cast<char const*>(cpr->m_cur), l);
cpr->m_cur += l;
};
bind_read_func(read_value);
Expand Down Expand Up @@ -269,8 +269,8 @@ struct parquet_field_enum_list : public parquet_field_list<Enum, FieldType::I32>
parquet_field_enum_list(int f, std::vector<Enum>& v)
: parquet_field_list<Enum, FieldType::I32>(f, v)
{
auto const read_value = [this](uint32_t i, CompactProtocolReader* cpr) {
this->val[i] = static_cast<Enum>(cpr->get_i32());
auto const read_value = [&val = v](uint32_t i, CompactProtocolReader* cpr) {
val[i] = static_cast<Enum>(cpr->get_i32());
};
this->bind_read_func(read_value);
}
Expand Down Expand Up @@ -354,8 +354,8 @@ struct parquet_field_struct_list : public parquet_field_list<T, FieldType::STRUC
parquet_field_struct_list(int f, std::vector<T>& v)
: parquet_field_list<T, FieldType::STRUCT>(f, v)
{
auto const read_value = [this](uint32_t i, CompactProtocolReader* cpr) {
cpr->read(&this->val[i]);
auto const read_value = [&val = v](uint32_t i, CompactProtocolReader* cpr) {
cpr->read(&val[i]);
};
this->bind_read_func(read_value);
}
Expand Down Expand Up @@ -395,7 +395,7 @@ struct parquet_field_binary_list
: public parquet_field_list<std::vector<uint8_t>, FieldType::BINARY> {
parquet_field_binary_list(int f, std::vector<std::vector<uint8_t>>& v) : parquet_field_list(f, v)
{
auto const read_value = [this](uint32_t i, CompactProtocolReader* cpr) {
auto const read_value = [&val = v](uint32_t i, CompactProtocolReader* cpr) {
auto const l = cpr->get_u32();
CUDF_EXPECTS(l <= static_cast<size_t>(cpr->m_end - cpr->m_cur), "binary length mismatch");

Expand Down Expand Up @@ -482,9 +482,7 @@ void CompactProtocolReader::skip_struct_field(int t, int depth)
skip_struct_field(t, depth + 1);
}
break;
default:
// printf("unsupported skip for type %d\n", t);
break;
default: break;
}
}

Expand Down
Loading