Skip to content

Ruby 3.4: zmq_proxy thread never terminates, process hangs #137

@kojix2

Description

@kojix2

Hello Chuck Remes (@chuckremes),

Thank you very much for maintaining ffi-rzmq.
Since Ruby 3.4, I have observed unexpected behavior with ffi-rzmq.

When running IRuby’s test suite under Ruby 3.4, the process hangs after all tests pass and never terminates.
Dumping thread backtraces shows that the zmq_proxy call remains blocked and does not return.

Below is a minimal reproduction without using IRuby.

Steps to Reproduce

  1. Install Ruby:

    rbenv install 3.3.8
    rbenv install 3.4.5
  2. Save the following code as hang.rb:

    require "ffi-rzmq"
    
    ctx    = ZMQ::Context.new
    front  = ctx.socket(ZMQ::REP)
    back   = ctx.socket(ZMQ::REQ)
    front.bind("inproc://front")
    back.bind("inproc://back")
    
    Thread.new do
      ZMQ::Device.new(front, back)
    end
    
    sleep 1
    puts "Exiting main thread"
  3. Run:

    ruby hang.rb
  4. Compare the results:

    • Ruby 3.3.8: Process exits normally after printing Exiting main thread.
    • Ruby 3.4.5: Process does not exit and remains blocked in the zmq_proxy call.

This issue does not occur on Ruby 3.3.x.
It may be related to thread or shutdown handling changes in Ruby 3.4.
Any guidance or insights on this behavior would be greatly appreciated.

Thanks in advance for looking into this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions