Project

General

Profile

Bug #10223

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

The following code: 

 ~~~ruby 
 ~~~ 
 #!/usr/bin/env ruby                                                                                                                                                         
 # encoding: utf-8 

 require 'bundler/setup' 
 require 'csv' 

 CSV.open("csv_error.csv") do |input| 
   input.each do |category,*mappings| 
     # do nothing 
   end 
 end 
 ~~~ 

 with the data file attached causes the follwing error: 

 ~~~ 
 /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/csv.rb:1768: stack level too deep (SystemStackError) 
 ~~~ 

 Interestingly almost the same code: 

 ~~~ruby 
 #!/usr/bin/env ruby                                                                                                                                                         
 # encoding: utf-8 

 require 'bundler/setup' 
 require 'csv' 

 CSV.open("csv_error.csv") do |input| 
   input.each do |tuple| 
     # do nothing 
   end 
 end 
 ~~~ 

 works fine. The error appears both in Ruby 1.9.2 (ancient) and Ruby 2.1.2. So I suppose it is an error inside CSV lib. 


 This might be important for any developer parsing CSV files comming from the outside world, since it may cause DOS error.

Back