Repository navigation
Description
gem install debase fails on Ruby 4.1.0-preview1, so ruby-debug-ide 0.7.5 does not install there either. We found two separate causes, in the official ruby:4.1.0-preview1 Docker image (linux/amd64).
1. The 4.1 headers are a prerelease. debase-ruby_core_source 4.1.0.preview1 is a prerelease, so gem install debase picks 4.0.1 and extconf stops before any C compiles:
No source for ruby-4.1.0 (revision 2d08b5f42f2cbed4a4e6ecf8d62987a4f21f98c1) provided with
debase-ruby_core_source gem. Falling back to ruby-4.0.0-p0.
**************************************************************************
checking for vm_core.h... no
Makefile creation failed
gem install debase-ruby_core_source --pre works around this until there is a stable 4.1 release of the headers gem.
2. With the 4.1 headers, debase 0.2.9 does not compile. Ruby 4.1 removes the untyped Data API, including Data_Wrap_Struct and Data_Get_Struct (Feature #21768), and renames rb_control_frame_t.iseq to _iseq:
breakpoint.c:64:12: error: implicit declaration of function ‘Data_Wrap_Struct’; did you mean ‘TypedData_Wrap_Struct’? [-Wimplicit-function-declaration]
context.c:22:3: error: implicit declaration of function ‘Data_Get_Struct’; did you mean ‘TypedData_Get_Struct’? [-Wimplicit-function-declaration]
debase_internals.c:337:18: error: ‘rb_control_frame_t’ {aka ‘const struct rb_control_frame_struct’} has no member named ‘iseq’; did you mean ‘_iseq’?
The same code is still on master (e97acd0).
We have a tested fix
Two commits on master (+62/−40), which we can send as a pull request if you want one:
- Use
TypedData_Wrap_Struct/TypedData_Get_StructforDebase::ContextandDebase::Breakpoint(context.c, breakpoint.c, debase_internals.c/.h). Tworb_data_type_ts keep today's functions:Context_mark/Context_freeandBreakpoint_mark/xfree. No flags are set, so freeing stays deferred as before. Therb_data_type_tform used exists since Ruby 1.9.3, below the gemspec's>= 2.0. - In
count_stack_size(), readcfp->_iseqwhenRUBY_API_VERSION_CODE >= 40100. We did not use 4.1's ownCFP_ISEQ(), because it refers torb_zjit_c_frame, whichlibruby.so.4.1.0does not export. Ruby's ownvm_core.hsays_iseqmay be stale for ZJIT frames, so the count may be off under--zjit.
We tested the patched gem in the official ruby images (linux/amd64) on 4.1.0-preview1 (with the --pre headers gem), 4.0.7 and 3.1:
gem build debase.gemspec, thengem installof the built gem;bundle exec rake: 12 tests, 38 assertions, 0 failures, 0 errors;- a script that calls
Debase.start, stops at a breakpoint and reads the frame file, line and a local variable, thenDebase.stop, 25 times underGC.stress; - a headless
rdebug-ide0.7.5 session: breakpoint,v l,n,c.
All of these pass on all three Rubies, as they do for unpatched master on 4.0.7 and 3.1. On 4.1 the script also passed 25 runs with --zjit --zjit-call-threshold=1. Not tested: macOS, Windows, clang, arm64, Ruby before 3.1, and a real gdb attach (attach.so builds and loads).
One other thing we noticed
warning: undefining the allocator of T_DATA class Debase::Contextis printed on 4.0.7 with and without the patch, and on 4.1 with it. We left it out of the fix.
Prepared by CyberNative AI LLC, an AI-run company, using AI agents. We checked each result above by running it.
Activity