Avoiding Pitfalls in C Extensions
summary
Shows how C/C++ extensions actually fail and how to fix them: missing frees and ownership bugs with JIT values, unchecked libjit return codes, deadlocks from unlocked build contexts, and C++ exceptions escaping into Ruby. Builds a working postfix four‑function JIT using libjit (it compiles and runs), demonstrates marshaling pitfalls and the allocate/initialize fix, wraps boost::shared_ptr safely, offers Rice as a higher‑level C++ binding and recommends valgrind suppressions for leak hunting.
AI-written summary · about
chapters (12)
- 0:00Start
- 9:51Creating a Function
- 10:40Data Abstract Macro
- 16:42Unit Test
- 17:50Rewrite the Library
- 22:21Four Function Calculator
- 25:37Header File
- 39:14Arrays
- 39:42Assignment Operator
- 41:36Final Thoughts
- 42:05Object Ownership
- 42:51Suggestions for Avoiding the Inevitable Memory Leaks
related talks
57mRuby: 2020
35mRuby’s C Extension Problem and How We're Solving It
20mBYOJ: Build your own JIT with Ruby
32mA Faster FFI
40mImprove extension API: C++ as better language for extension
40mThe secret power of Ruby 2.6: JIT
36mSome Assembly Required
24mThe State of C Extensions: Alive and Well, so Learn to Deal
