Project

General

Profile

Actions

Bug #211

closed

"wrong argument type" "expected Proc"

Added by Tobi_Reif (Tobi Reif) over 16 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
[ruby-core:17477]

Description

=begin
I have

$ ruby -v
ruby 1.8.6 (2008-06-20 patchlevel 230) [i686-linux]

When I do this

$ ./script/server

and then browse to http://localhost:3000/ I get this:

ActionView::TemplateError (wrong argument type String (expected Proc)) on line #21 of list/index.html.erb:
18:


19:

Add list


20: <%= error_messages_for :list %>
21: <% form_for :list, @list, :url => {:action => "create"} do |f| %>
22:

23: <%= label(:list, :name) %>
24: <%= f.text_field :name, :size => 22 %>
 (eval):2:in `protect_against_forgery?'
 /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_tag_helper.rb:404:in `extra_tags_for_form'
 /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_tag_helper.rb:412:in `form_tag_html'
 /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/form_tag_helper.rb:41:in `form_tag'

[...]
=end

Actions #1

Updated by drbrain (Eric Hodel) over 16 years ago

=begin
I can't find a protect_against_forgery? in ruby 1.8, and action_view is rails code. I think you meant to file this bug on dev.rubyonrails.org.
=end

Actions #2

Updated by Tobi_Reif (Tobi Reif) over 16 years ago

=begin
Hi Eric!

I don't get this error with
ruby 1.8.6 (2008-03-03 patchlevel 114) [i686-linux]
so it must be caused by
ruby 1.8.6 (2008-06-20 patchlevel 230) [i686-linux]
(By the changes since p114.)

It would be great if you could try to reproduce this error, perhaps line 21 is enough to trigger it.

=end

Actions #3

Updated by drbrain (Eric Hodel) over 16 years ago

=begin
You'll need to provide more information to reproduce this, as there is too little information and too much work required:

$ ./script/server
-bash: ./script/server: No such file or directory

So I'd need to install rails and build a rails app. Can you reduce this to a reproduction without rails?
=end

Actions #4

Updated by shyouhei (Shyouhei Urabe) over 16 years ago

=begin
Duplication of #199 I believe. Fixed in the repository.
=end

Actions #5

Updated by Tobi_Reif (Tobi Reif) over 16 years ago

=begin
I compiled the current Ruby 1.8.6:

$ svn co http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_6
[... make etc ...]
$ /home/tobi/bulk/run/ruby/ruby_1.8.6_rev_17790/bin/ruby -v
ruby 1.8.6 (2008-07-01 patchlevel 257) [i686-linux]
[... installed RubyGems, Rails, etc ...]
[In the Rails app's dir:]
$ ed script/server
97
1
#!/usr/bin/env ruby
1i
#!/home/tobi/bulk/run/ruby/ruby_1.8.6_rev_17790/bin/ruby
.
wq

Result:

$ ./script/server
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
[...]

browsed to http://localhost:3000/

-> no error.

$ ./script/server -e test -p 2000
[...]

Browsed to index.

[...]
$ # No segfault.

$ ./script/server -e production --port 4000

Browsed to index

[...]
$ # No error.

I can't talk about any related issues, but the issues I experienced
are fixed.

Thanks for the fixes!

In the future it would be great if the Ruby community would be asked
to test a release candidate before a real version of Ruby is released and
recommended as stable. (No matter if the release will be made in response
to a security issue or not.)

Thanks for Ruby!

=end

Actions #6

Updated by candlerb (Brian Candler) over 16 years ago

=begin
I got this exact error too. Reproducing it was a bit awkward, but I think I can confirm the problem and that it has been fixed.
In my case, I was finding that in my replica live environment:

  • "script/server" worked fine
  • "mongrel_rails start -P tmp/pids/mongrel.pid" usually demonstrated the bug: "wrong argument type FalseClass (expected Proc)"
  • "mongrel_rails" by itself caused a segfault:

$ mongrel_rails start
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).
** Rails signals registered. HUP => reload (without restart). It might not work well.
** Mongrel 1.1.4 available at 0.0.0.0:3000
** Use CTRL-C to stop.
Segmentation fault

And I've also seen:

$ mongrel_rails start -P tmp/pids/mongrel.pid
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).
** Rails signals registered. HUP => reload (without restart). It might not work well.
** Mongrel 1.1.4 available at 0.0.0.0:3000
** Use CTRL-C to stop.
*** glibc detected *** corrupted double-linked list: 0x00715858 ***
Aborted

This is RHEL4 with p230 built from the Fedora package "ruby-1.8.6.230-2.fc10.src.rpm", which includes a few patches of its own, including "ruby-1.8.6.230-string-str_buf_cat.patch"

So to replicate this, on a test box (Ubuntu 6.06.1) I made two completely fresh vanilla installations compiled from svn, tags v1_8_6_230 and v1_8_6_264

---------------- how ruby was installed ------------
svn co http://svn.ruby-lang.org/repos/ruby/tags/v1_8_6_230 tags/v1_8_6_230
cd tags/v1_8_6_230
autoconf
./configure --prefix=/usr/local/ruby-1.8.6p230
make
sudo make install
wget 'http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz'
rm -rf rubygems-1.2.0
tar -xvzf rubygems-1.2.0.tgz
cd rubygems-1.2.0
sudo /usr/local/ruby-1.8.6p230/bin/ruby setup.rb
sudo /usr/local/ruby-1.8.6p230/bin/gem install rails --version "2.0.2" --no-rdoc --no-ri

Rails requires a database layer (is there a way to disable models?)

sudo /usr/local/ruby-1.8.6p230/bin/gem install sqlite3-ruby --no-rdoc --no-ri

(repeat for p264)

---------------- sample rails app ----------------
rails foo
cd foo
script/generate controller bar
cat <app/views/bar/index.html.erb
<% form_tag(:action=>:index) do %>
<% end %>
EOF
/usr/local/ruby-1.8.6p230/bin/ruby script/server

In another console window

lynx http://localhost:3000/bar/

I had to hit the server several times, but after 4 or 5 tries under p230 this caused a crash:

$ /usr/local/ruby-1.8.6p230/bin/ruby script/server
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2008-07-02 13:22:39] INFO WEBrick 1.3.1
[2008-07-02 13:22:39] INFO ruby 1.8.6 (2008-06-20) [i686-linux]
[2008-07-02 13:22:39] INFO WEBrick::HTTPServer#start: pid=2634 port=3000
127.0.0.1 - - [02/Jul/2008:13:22:41 BST] "GET /bar HTTP/1.1" 200 179 - -> /bar
127.0.0.1 - - [02/Jul/2008:13:22:43 BST] "GET /bar HTTP/1.1" 200 179 - -> /bar
127.0.0.1 - - [02/Jul/2008:13:22:43 BST] "GET /bar HTTP/1.1" 200 179 - -> /bar
127.0.0.1 - - [02/Jul/2008:13:22:44 BST] "GET /bar HTTP/1.1" 200 179 - -> /bar
*** glibc detected *** corrupted double-linked list: 0xb7f5b358 ***
Aborted

With p264, I could not crash it (tried 30 hits)

Trying again with mongrel instead of webrick:

sudo /usr/local/ruby-1.8.6p230/bin/gem install mongrel --no-rdoc --no-ri
/usr/local/ruby-1.8.6p230/bin/ruby script/server # option 1
/usr/local/ruby-1.8.6p230/bin/mongrel_rails start # option 2

After 4 or 5 hits, mongrel (1.1.5) under p230 crashed (run either as option 1 or option 2). But p264 didn't crash even after 40 hits.

In conclusion: whilst I haven't been able to replicate exactly the problem "wrong argument type String (expected Proc)" using a clean build, I could replicate crashes reliably, and these have gone away in the recent 1.8.6 tree.

Aside: in order to make a new RPM package for my live environment, it would be helpful if there could be a new 1.8.6 tarball release...

=end

Actions #7

Updated by nobu (Nobuyoshi Nakada) over 16 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Merged to 1.8.6 branch in the repository, at r17630.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0