kriti-sc opened a new issue, #2770:
URL: https://github.com/apache/iggy/issues/2770

   ### Bug description
   
   ### Problem
   
   The sink_connector! and source_connector! macros in iggy_connector_sdk 
export FFI functions with generic names like open, close, consume, handle, and 
version using #[unsafe(no_mangle)]. When a connector plugin (compiled as a 
cdylib) internally calls POSIX open() — e.g., via std::fs::File::open or 
object_store::local::LocalFileSystem, the dynamic linker resolves it to the 
plugin's own open FFI function instead of libc's open().
   
   This causes a segfault because the POSIX open(path, flags, mode) arguments 
get misinterpreted as the plugin's open(id, config_ptr, config_len, 
log_callback) parameters, leading to garbage pointer dereference in 
std::str::from_utf8.
   
   ### Found while
   Writing the delta sink connector and writing delta lake on file system, 
which calls POSIX open().
   
   See below lldb backtrace:
   
   ```
   * thread #20, name = 'tokio-runtime-worker', stop reason = EXC_BAD_ACCESS 
(code=1, address=0x1000000)
     * frame #0: 0x0000000103bc8498 
libiggy_connector_delta_sink.dylib`core::str::converts::from_utf8 + 52
       frame #1: 0x0000000102c870bc 
libiggy_connector_delta_sink.dylib`iggy_connector_sdk::sink::SinkContainer<T>::open
 + 4924
       frame #2: 0x0000000102caa80c libiggy_connector_delta_sink.dylib`open + 80
       frame #3: 0x0000000103b8dfb8 
libiggy_connector_delta_sink.dylib`std::sys::fs::unix::File::open_c + 260
       frame #4: 0x0000000103b8a5a4 
libiggy_connector_delta_sink.dylib`std::fs::OpenOptions::_open + 144
       frame #5: 0x00000001037eafc4 
libiggy_connector_delta_sink.dylib`object_store::local::open_file + 84
       frame #6: 0x000000010385ecdc 
libiggy_connector_delta_sink.dylib`<object_store::local::LocalFileSystem as 
object_store::ObjectStore>::get_opts + 52
       frame #7: 0x0000000103838210 
libiggy_connector_delta_sink.dylib`tokio::runtime::task::raw::poll + 256
   Key frames: File::open_c (frame #3) calls POSIX open(), which resolves to 
the plugin's FFI open (frame #2), which calls SinkContainer::open (frame #1), 
which tries to parse file descriptor arguments as a UTF-8 config string (frame 
#0) — segfault.
   ```
   
   ### Fix
   Rename the exported FFI symbols to avoid collision with libc/POSIX names.
   
   ### Deployment
   
   None
   
   ### Versions
   
   _No response_
   
   ### Hardware / environment
   
   _No response_
   
   ### Sample code
   
   _No response_
   
   ### Logs
   
   _No response_
   
   ### Iggy server config
   
   _No response_
   
   ### Reproduction
   
   _No response_


-- 
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