dalingmeng commented on code in PR #315:
URL: https://github.com/apache/paimon-cpp/pull/315#discussion_r4003864336


##########
crates/lance_ffi/Cargo.toml:
##########
@@ -0,0 +1,50 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+name = "paimon_lance_ffi"
+version = "0.1.0"
+edition = "2021"
+description = "C FFI layer for the Paimon C++ Lance file format"
+license = "Apache-2.0"
+publish = false
+
+[lib]
+name = "paimon_lance_ffi"
+crate-type = ["staticlib", "rlib"]
+
+[dependencies]
+arrow = { version = "56.1", features = ["ffi"] }
+futures = "0.3"
+lance-core = "=0.39.0"
+lance-encoding = "=0.39.0"
+lance-file = "=0.39.0"
+lance-io = "=0.39.0"
+object_store = "0.12.3"
+tokio = { version = "1.23", features = ["rt-multi-thread", "macros", "fs", 
"sync"] }
+
+[build-dependencies]
+cbindgen = "0.29"
+
+[profile.release]
+opt-level = 3
+lto = "thin"
+codegen-units = 1
+panic = "abort"
+
+[profile.dev]
+panic = "abort"

Review Comment:
   [Robustness] FFI boundary lacks panic guards; a corrupt file aborts the 
whole processAll 12 extern "C" functions in crates/lance_ffi lack catch_unwind, 
and Cargo.toml sets panic = "abort" (release/dev, L47/L50). As a result, any 
panic inside Lance (e.g. a decode assertion triggered by a corrupt/truncated 
file) aborts the entire process instead of returning an error code that C++ can 
turn into a Status. For a storage engine, "read a bad file → process crash" is 
a serious robustness defect.Evidence: in crates/lance_ffi/src/runtime.rs, 
block_on's .join().map_err(|_| "Lance runtime worker panicked") can never fire 
under panic = "abort" (the process is already aborted) — it is dead code, and 
shows the config contradicts the intent to catch panics.For reference, the 
Mosaic FFI in this same repo uses catch_unwind in 9 places to convert panics 
into error codes.Suggested fix:
   Set panic = "unwind" in Cargo.toml;
   Wrap each extern "C" body in catch_unwind(AssertUnwindSafe(|| { ... })), 
calling set_error(...) and returning non-zero on panic;
   Add a negative test: reading a corrupt Lance file returns an error instead 
of crashing.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to