Link to home
Start Free TrialLog in
Avatar of zaidmarji
zaidmarjiFlag for United States of America

asked on

Issue with Ruby script

Hi Folks,

I just inherited a ruby script that I'm trying to get to run. It goes through a couple of files and tries to match rules in one file to columns in the other file I'm coming across an issue where I get the following error

C:/Ruby187/lib/ruby/1.8/ostruct.rb:83: [BUG] object allocation during garbage collection phase
ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]

Here is the piece of code it is failing on
	for line in product_lines do
		tiebreaker_columns.current_row = line.strip.split("\t")
		tiebreaker_columns.current_line_number = line_number

		vendor = compose_tie_breaker(tiebreaker_columns)
		column = 0
		att_count = 0
		for item in tiebreaker_columns.current_row do
			t = OpenStruct.new
			t.vendor_name, t.vendor_id = vendor.name, vendor.vid
			t.field_name = product_vals[column]
			for k,v in $rules do
				if (k == t)
					found_matching_rule +=1
					x = OpenStruct.new
					x.vid = vendor.vid.to_s().strip
					x.row_id = line_number.to_s().strip
					x.attribute_type = v.our_type.to_s().strip
					x.attribute_name = v.our_field_name.to_s().gsub("'","''").strip
					$attributes[x] = item.to_s().gsub("'","''").strip
				end
				att_count+=1
			end
			column += 1
		end
		line_number += 1
	end

Open in new window


it breaks in the most inner loop. Any idea on why this might be happening?

Thanks your help is very much appreciated.

Avatar of JESii
JESii
Flag of United States of America image

This bug was heavily reported back in 2008 on ruby-forum.org and there were some indications that it might be due to problems with a gem. I see that you're running this on windows with the latest version of Ruby 1.8.7...

Couple of suggestions:
1. Do you have the latest version of the gems you are using? If not, you could try updating them.
2. Maybe you could try upgrading to the latest Ruby version - 1.9.2? It certainly is stable and is the way to go for the future. Only problem is, there were some changes in some of the language syntax, so that might not work out of the box for you.
Avatar of zaidmarji

ASKER

@ JESii

Thanks I actually upgraded to 1.9.2 to try and see if it would work. The only problem I'm facing right now is trying to connect this to a MS Sql database. With 1.8.7 I could you dbd-odbc, but I dont see they have a version for 1.9.2 that runs on Windows. Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of zaidmarji
zaidmarji
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You're welcome; I'm sorry to hear that as I'm developing a rails app to go against MS SQL Server and I'm hoping to use 1.9.2... we'll see how much "fun" I can have :=)
no solution found so changed the code in question