default out-marshaller for ForeignPtr adds finalizer for null ptr
- Dominant language
- Haskell
- Stars
- 211
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes C functions return null pointers. The default marshaller for ForeignPtr's in c2hs still adds a finalizer for null pointers, which causes the application to crash when the memory is freed. I suggest the default marshaller should check if the ptr equals `nullPtr` and, if so, use `newForeignPtr_` instead.
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate c2hs's default out-marshaller for ForeignPtr and review how it handles a null pointer returned by a C function. Reproduce the null-pointer case and verify that the marshaller avoids installing a finalizer for nullPtr while retaining normal finalizer behavior for non-null pointers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, haskell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100