Strange String bug (around type.to_s from mod_ruby)?

(See attached files please.)

‘eruby bug.rhtml’ gives:

"Sub"
"b"
"Base"
"se"

Fine. Now, from the browser (thru mod_ruby):

"#::Sub"
"Module 0lx4048974c>::Sub"
"Base"
"se"

If in bug.rhtml you don't require bug.rb but paste it in (see 
comments in the code), then both printouts will break:

"#::Sub"
"Module 0lx4048974c>::Sub"
"#::Base"
"Module 0lx4048974c>::Base"

Also, if you play with the changes commented in bug.rb, you
can trigger/mask the error at will.

Furthermore, in the slightly different live code, even when the 
output looks good (OK, I'm not familiar with mod_ruby so I have 
no idea what that '#::' is supposed represents in the "Sub" class 
name, that alone is, well, sort of strange, but well...), so even 
when there is no "Module ..." in the output, e.g. File.mkpath(y)
(where y is the broken string) would create directory path, which 
DOES have that ghost "Module ..." thing in there!...

Kind of scary...

Seems like either I do something miserable, or there may be
a buffer overrun (if I had to place my bet... ;) ) somewhere.
(Posslibly a mod_ruby problem, so I sent this to the mod-ruby 
people already.)

Cheers,
Sab

(Apache/1.3.26 (Unix) Debian GNU/Linux mod_ruby/1.0.0 Ruby/1.6.7 
-- and I _did_ restart it a few times...)

[bug.rb|attachment](upload://yuqWZTNwPy9t5LCBVVd84iuK1gv.rb) (248 Bytes)



[bug.rhtml|attachment](upload://isdR6L0PdvbL4FLJEtY9eaMV88D.rhtml) (270 Bytes)

Fine. Now, from the browser (thru mod_ruby):

mod_ruby run a script in an anonymous module, this is what you are seeing

"#::Sub"
"Module 0lx4048974c>::Sub"

The anonymous module is "Module 0lx4048974c"

"Base"
"se"

a "require" run at top level and in your case create the class Base

If in bug.rhtml you don't require bug.rb but paste it in (see
comments in the code), then both printouts will break:

"#::Sub"
"Module 0lx4048974c>::Sub"
"#::Base"
"Module 0lx4048974c>::Base"

You have cut/paste the code and now the class Base is created in the
anonymous module.

Guy Decoux

Thanks, but how does this explain the magic in bug.rb:
replacing type.to_s with its exact literal value does
affect the output, as does trigger/stop the problem the
subtle change from [2…-1] to [1…-1].

Sab

···

----- Original Message -----
From: “ts” decoux@moulon.inra.fr
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Cc: ruby-talk@ruby-lang.org
Sent: Sunday, October 20, 2002 4:05 PM
Subject: Re: Strange String bug (around type.to_s from mod_ruby)?

Fine. Now, from the browser (thru mod_ruby):

mod_ruby run a script in an anonymous module, this is what you are seeing

#::Sub
“Module 0lx4048974c>::Sub”

The anonymous module is “Module 0lx4048974c”

“Base”
“se”

a “require” run at top level and in your case create the class Base

If in bug.rhtml you don’t require bug.rb but paste it in (see
comments in the code), then both printouts will break:

#::Sub
“Module 0lx4048974c>::Sub”
#::Base
“Module 0lx4048974c>::Base”

You have cut/paste the code and now the class Base is created in the
anonymous module.

Guy Decoux

Thanks, but how does this explain the magic in bug.rb:
replacing type.to_s with its exact literal value _does_
affect the output, as does trigger/stop the problem the
subtle change from [2..-1] to [1..-1].

Well, look at the source of the document, this is probably your browser
which interpret <Module:0x5555555> as an HTML tag and don't display it.

When it find 'Module:0x5555555>' it just display it.

Guy Decoux