typecheck_equals aborts the process on custom data types (unimplemented!)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start at the Custom arm of CassDataTypeInner::typecheck_equals in scylla-rust-wrapper/src/cql_types/data_type.rs (around lines 305-307), then follow the recursion through CassCqlValue::is_type_compatible in scylla-rust-wrapper/src/cql_types/value.rs to see which callers surface the result as CASS_ERROR_LIB_INVALID_VALUE_TYPE. Reproduce with the unit test sketched in the issue (list<custom> set into a tuple<list<int>>) and run it to confirm the abort before changing anything. Done means that test path returns an error instead of panicking, with the existing cql_types tests still passing.
Written by the indexing model from the issue text.
Description
What goes wrong
CassDataTypeInner::typecheck_equals ends with:
so any typecheck where the value-side type is (or contains) a Custom type panics. It runs inside extern "C" setters, so the process aborts.
A Custom data type is reachable through the public API: cass_data_type_new(CASS_VALUE_TYPE_CUSTOM) returns one, and cass_data_type_add_sub_type accepts it as a subtype:
Building a collection/tuple/UDT from such a type and then setting it into a typed tuple, UDT or collection (or binding it) goes through CassCqlValue::is_type_compatible -> typecheck_equals, which recurses into the subtypes and hits the Custom arm:
The expected outcome is CASS_ERROR_LIB_INVALID_VALUE_TYPE (or rejecting CUSTOM up front), not an abort.
Related: #158 (plan to drop custom types entirely). Until that lands, the API still hands out Custom types that later crash the process.
Reproduction
Temporary unit test in scylla-rust-wrapper/src/cql_types/data_type.rs tests:
// list<custom>
let custom = cass_data_type_new(CassValueType::CASS_VALUE_TYPE_CUSTOM);
let list_custom = cass_data_type_new(CassValueType::CASS_VALUE_TYPE_LIST);
cass_data_type_add_sub_type(list_custom.borrow(), custom.borrow().into_c_const());
// tuple<list<int>>
let int_t = cass_data_type_new(CassValueType::CASS_VALUE_TYPE_INT);
let list_int = cass_data_type_new(CassValueType::CASS_VALUE_TYPE_LIST);
cass_data_type_add_sub_type(list_int.borrow(), int_t.borrow().into_c_const());
let tup_t = cass_data_type_new(CassValueType::CASS_VALUE_TYPE_TUPLE);
cass_data_type_add_sub_type(tup_t.borrow(), list_int.borrow().into_c_const());
let coll = cass_collection_new_from_data_type(list_custom.borrow().into_c_const(), 0);
let mut tup = cass_tuple_new_from_data_type(tup_t.borrow().into_c_const());
cass_tuple_set_collection(tup.borrow_mut(), 0, coll.borrow().into_c_const());
panicked at src/cql_types/data_type.rs:306:17:
not implemented: cpp-rs-driver does not support custom types!
panicked at .../core/src/panicking.rs:225:5:
panic in a function that cannot unwind
thread caused non-unwinding panic. aborting.
Fix direction
Make the Custom arm of typecheck_equals return a result instead of panicking: either false (so the setter returns CASS_ERROR_LIB_INVALID_VALUE_TYPE), or, closer to cpp-driver, compare the custom class names when other is also Custom. Alternatively, since custom types are not supported (#158), have cass_data_type_new(CASS_VALUE_TYPE_CUSTOM) return NULL so a Custom type can never reach the typecheck.
- Dominant language
- C++
- Stars
- 27
- Forks
- 18
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from scylladb/cpp-rs-driver
-
area/Driver_-_cpp-rs-driver bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
scylladb/cpp-rs-driver#546 ·
-
area/Driver_-_cpp-rs-driver bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
scylladb/cpp-rs-driver#544 ·
-
area/Driver_-_cpp-rs-driver bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
scylladb/cpp-rs-driver#543 ·
-
area/Driver_-_cpp-rs-driver bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
scylladb/cpp-rs-driver#542 ·
-
area/Driver_-_cpp-rs-driver bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
scylladb/cpp-rs-driver#541 ·
All issues in scylladb/cpp-rs-driver
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 95/100
Tracktion/tracktion_engine#505 ·
Maintainers usually reply within 1 day
-
Merge discards entry history (and the other side’s version) when “Max. history items” is unlimitedOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
keepassxreboot/keepassxc#14157 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
tenstorrent/tt-metal#67322 ·
Maintainers usually reply within 1 day
-
`SIGFPE` reading `JSON` from a `Wide` part when `max_prefixes_deserialization_thread_pool_size` is 0Opencomp-json-datatype v25.8-affected v26.10-affected v26.11-affected v26.8-affected v26.9-affected
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ClickHouse/ClickHouse#134554 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
jesdga95/basalt#747 · 2 comments ·
Maintainers usually reply within 1 day