String.new() with parameters crashes on Ruby <2.3
Recent frozen string literal commit (https://github.com/phusion/passenger/commit/e13cab69dd96c196100cd6a25a5774032cbec697) broke some really old Ruby versions.
Basically calling String.new() with parameters in
https://github.com/phusion/passenger/blob/76d454044748fa89ea34c3ae07ee1476617bcd3c/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb#L104-L104
results in exception
```log
App 1610913 output: [ 2025-12-27 00:00:43.0106 1610913/0x005608b841c280(Worker 1) utils.rb ]: *** Exception TypeError (can't convert Hash into String) (process 1610913, thread 0x005608b841c280(Worker 1)):
App 1610913 output: from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:104:in `initialize'
App 1610913 output: from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:104:in `new'
App 1610913 output: from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:104:in `main_loop'
App 1610913 output: from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:419:in `block (3 levels) in start_threads'
App 1610913 output: from /usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:111:in `block in create_thread_and_abort_on_exception'
[ W 2025-12-27 00:00:45.0159 1610612/T4 age/Cor/App/Poo/AnalyticsCollection.cpp:104 ]: Process (pid=1610913, group=/u/apps/xxx/current (production)) no longer exists! Detaching it from the pool.
[ N 2025-12-27 00:00:45.0160 1610612/T4 age/Cor/CoreMain.cpp:1093 ]: Checking whether to disconnect long-running connections for process 1610913, application /u/apps/xxx/current (production)
```
The application in my case is running on Ruby 1.9.3-p551. Testing with irb:
```irb
irb(main):002:0> String.new(encoding: Encoding::BINARY)
TypeError: can't convert Hash into String
from (irb):3:in `initialize'
from (irb):3:in `new'
from (irb):3
from /home/xxx/.rvm/rubies/ruby-1.9.3-p551/bin/irb:12:in `<main>'
```
Encoding parameter to String.new() seems to be added in Ruby 2.3.0
I'm using Debian 12 with libapache2-mod-passenger 1:6.1.1-1~bookworm1 and have `PassengerRuby /home/xxx/.rvm/gems/ruby-1.9.3-p551/wrappers/ruby` in VirtualHost
1 条评论