webrick crashes processing NotModified response in lucid

Bug #540193 reported by aquavitale
66
This bug affects 11 people
Affects Status Importance Assigned to Milestone
rails (Ubuntu)
Confirmed
Undecided
Unassigned
Nominated for Lucid by André FL Ribeiro

Bug Description

Binary package hint: rails

Description: Ubuntu lucid (development branch)
Release: 10.04
Webrick raises an exception trying to generate NotModified response on static files.

Backtrace:

First request (no Etag or If Modified headers)

127.0.0.1 - - [17/Mar/2010:14:30:25 MSK] "GET /images/rails.png HTTP/1.1" 200 6646
- -> /images/rails.png

Second request (browser sends If-Modified-Since)

[2010-03-17 14:30:45] ERROR NoMethodError: private method `gsub!' called for #<Class:0x7fb7c0799ff8>
 /usr/lib/ruby/1.8/webrick/htmlutils.rb:16:in `escape'
 /usr/lib/ruby/1.8/webrick/httpresponse.rb:232:in `set_error'
 /home/viert/rails/test/vendor/rails/railties/lib/webrick_server.rb:94:in `handle_file'
 /home/viert/rails/test/vendor/rails/railties/lib/webrick_server.rb:73:in `service'
 /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
 /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
 /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
 /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
 /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
 /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
 /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
 /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
 /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
 /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
 /home/viert/rails/test/vendor/rails/railties/lib/webrick_server.rb:60:in `dispatch'
 /home/viert/rails/test/vendor/rails/railties/lib/commands/servers/webrick.rb:66
 /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
 /home/viert/rails/test/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
 /home/viert/rails/test/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
 /home/viert/rails/test/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
 /home/viert/rails/test/vendor/rails/railties/lib/commands/server.rb:49
 /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
 script/server:3
127.0.0.1 - - [17/Mar/2010:14:30:45 MSK] "GET /images/rails.png HTTP/1.1" 500 343
- -> /images/rails.png

Trying to reach out the core of the problem I found out that variable err (HTTPStatus::NotModified) has no string property "message" which required in /usr/lib/ruby/1.8/webrick/htmlutils.rb:16:in `escape' or maybe i'm wrong about it.

ProblemType: Bug
Architecture: amd64
Date: Wed Mar 17 14:25:40 2010
DistroRelease: Ubuntu 10.04
InstallationMedia: Ubuntu 10.04 "Lucid Lynx" - Alpha amd64 (20100224.1)
Package: rails 2.2.3-2
PackageArchitecture: all
ProcEnviron:
 LANG=en_US.utf8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.32-16.25-generic
SourcePackage: rails
Uname: Linux 2.6.32-16-generic x86_64

Revision history for this message
aquavitale (aquavitale) wrote :
Revision history for this message
André FL Ribeiro (andre-fl-ribeiro) wrote :

anywork solutions, or workarounds?

Changed in rails (Ubuntu):
status: New → Confirmed
Revision history for this message
Jonathan Kingston (jonathan-jooped) wrote :

Either in *project path*/vendor/rails/railties/lib/webrick_server.rb line 94, change to:
res.set_error(err.to_s)

or in /usr/lib/ruby/1.8/webrick/htmlutils.rb line 15 change to:
      str = string.to_s ? string.dup.to_s : ""

Is this something to be filed to a webbrick project or rails, seems to be the rails that is sending an invalid type.

Revision history for this message
Leberwurscht (pbmaxi) wrote :

This bug seems to be serious, it shows up on every new rails site created on an up to date Lucid Lynx:

rails test
cd test
scripts/server

Now if I open http://localhost:3000/ the first time, it works. But from then on, I only get Internal Server errors as "private method `gsub!' called for #<Class:0x7f6f1e0568d0>".

Changing res.set_error(err) to res.set_error(err.to_s) solved the problem for me.

Revision history for this message
Jonathan Kingston (jonathan-jooped) wrote :

Leberwurscht this is because it happens every time a 304 not modified header is being tried to be sent. This header is sent to the client to save the effort of sending the same content again.

Revision history for this message
Flavio (flaviosnm) wrote :

I did the same that Leberwurscht, but that problem still happens even changing the line 15 in htmlutils.rb file.
Does anyone knows another way to run ruby applications using Lucid??
Thanks

Revision history for this message
Jonathan Kingston (jonathan-jooped) wrote : Re: [Bug 540193] Re: webrick crashes processing NotModified response in lucid

You could look up using a different server not webrick. I'm surprised that
this has not been patched yet.

On 10 August 2010 13:07, Flavio <email address hidden> wrote:

> I did the same that Leberwurscht, but that problem still happens even
> changing the line 15 in htmlutils.rb file.
> Does anyone knows another way to run ruby applications using Lucid??
> Thanks
>
> --
> webrick crashes processing NotModified response in lucid
> https://bugs.launchpad.net/bugs/540193
> You received this bug notification because you are a direct subscriber
> of the bug.
>
>

Revision history for this message
Al Snow (jasnow) wrote :

Checked code and found this (based on suggested
fixes in http://www.ruby-forum.com/topic/206225)

grep -n set_error ./rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb

96: res.set_error(ex)
99: res.set_error(ex)
104: res.set_error(ex, true)

grep -n string /home/dell/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/htmlutils.rb

18: str = string ? string.dup : ""

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.