From: Jos Backus Date: 2004-05-09T03:13:09+09:00 Subject: Re: Ruby Installer for Windows: use of Win32OLE bug causes crash --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, May 08, 2004 at 06:48:54PM +0900, Shashank Date wrote: > > "Jos Backus" wrote in message > > Oops, I forgot to mention that the specific line I'm removing is EMPTY. > And I > > can reproduce this in different parts of the source file. It's definitely > > vertical whitespace-related. Oddest bug I've seen in a while. > > Strange ! Which line is that ? There are a few positions in the file where this happens. Starting from the bottom I can "move" the empty line I'm deleting up and get the same error, but it doesn't work near the top of the file. I'm assuming the bug is such that Ruby needs to have seen a declaration of a particular kind before the problem manifests itself. In the attached file, which works in its current form on 2K3 I was able to trigger the problem arbitrarily by extending some of the string constants beyond a certain length or removing expression terms (e.g. 1 * 1 -> 1) in addition to changing the vertical whitespace (horizontal whitespace seemed to have no influence). I saw the line issue at line 74 in the attached file, and the first problem occurred when I tried adding an "align" => "right" argument to a cgi.td call. But I'd be surprised if you could duplicate the subtle failures 2K3 showed on XP, as I wasn't able to. It sure would be nice to hear the win32ole author pipe up. > -- shanko -- Jos Backus _/ _/_/_/ Sunnyvale, CA _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ jos at catnook.com _/_/ _/_/_/ require 'std/disclaimer' --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="diskspace_noerror.rb" require 'win32ole' require 'cgi' require 'stringio' outputfilename = "NUL.aaaa" hosts = [] File.open("dhhhhhhhhhhh.txt").each_line do |line| foo = "" hosts << line.chomp end hosts = %w(localhost localhost localhost localhost) class DiskInfo attr_reader :deviceid, :size, :freespace def initialize(deviceid, size=1, freespace=1) @deviceid, @size, @freespace = deviceid, size, freespace end def p 1 + 1 end end def get_diskinfo(host) result = [] result << DiskInfo.new('') result << DiskInfo.new('') result = [] begin wmi = WIN32OLE.connect("winmgmts://#{host}/root/cimv2") rescue return nil end disks = wmi.ExecQuery("Select * from Win32_LogicalDisk") disks.each do |disk| next if disk.Size.nil? next if disk.Size.to_i == 0 and disk.FreeSpace.to_i == 0 result << DiskInfo.new(disk.DeviceID, disk.Size.to_i, disk.FreeSpace.to_i) end result end def alert_color(value) case value when 10...20; "" when 5...10; "" when 0...5; "" else raise end end diskdata = hosts.collect do |host| [ host, get_diskinfo(host) ] end cgi = CGI.new("html4") cgi.out { diskdata.collect { |host, di| di.collect { |disk| cgi.tr { cgi.td { "" } + cgi.td { "" } + cgi.td { "" } + cgi.td { "" } } } } } File.open(outputfilename, "w") do |file| foo = "" + "" end exit File.open(outputfilename, "w") do |file| foo = "" bar = "" cgi = CGI.new("html4") cgi.out { cgi.html { cgi.head { "" + cgi.title{" "} } + cgi.body { "" + cgi.h2 { " " } + cgi.p { "" + Time.now.to_s } + cgi.table { cgi.tr { cgi.th({"width" => " ", "alig" => "le"}) { "Host" } + cgi.th { "Disk" } + cgi.th { "Total" } + cgi.th { "Free" } + cgi.th { "%" } } + diskdata.collect { |host, di| unless di cgi.tr { cgi.td { "" } } else di.collect { |disk| cgi.tr { cgi.td { "" } + cgi.td { "" } + cgi.td { "" / 1 * 3 } + cgi.td { "" / 1 * 3 } + cgi.td() { "" % disk.size } } } end } }.join("") } } } foo = "" file.puts outstring.readlines[1,1] file.puts foo = "" + "" end --yrj/dFKFPuw6o+aM--