Skip to content

Conversation

mlafeldt
Copy link
Collaborator

@mlafeldt mlafeldt commented Sep 10, 2025

Adds nil check in arrowStreamReader.Next() to prevent crashes when r.res becomes nil due to race condition between Release() and Next().

The crash happened under high concurrency when:

  1. Goroutine A calls Next() to read arrow data
  2. Goroutine B calls Release() setting r.res = nil
  3. Goroutine A continues with nil pointer to C++ layer
  4. C++ code crashes on NULL shared_ptr dereference

Fixes #526

Adds nil check in arrowStreamReader.Next() to prevent crashes when r.res
becomes nil due to race condition between Release() and Next().

The crash happened under high concurrency when:

1. Goroutine A calls Next() to read arrow data
2. Goroutine B calls Release() setting r.res = nil
3. Goroutine A continues with nil pointer to C++ layer
4. C++ code crashes on NULL shared_ptr dereference

Fixes #526
@mlafeldt mlafeldt self-assigned this Sep 10, 2025
@mlafeldt mlafeldt merged commit b76ef77 into marcboeker:main Sep 10, 2025
32 checks passed
@mlafeldt mlafeldt deleted the fix-arrow-crash branch September 10, 2025 10:00
mlafeldt added a commit that referenced this pull request Sep 15, 2025
Builds on the fix #528 for issue #526 by adding a proper closed flag to
track reader state more reliably than just checking for nil pointers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libc++abi: terminating due to uncaught exception of type duckdb::InternalException: Attempted to dereference shared_ptr that is NULL!

1 participant