view · edit · sidebar · attach · print · history

20120131-fix-errors-oddb_org-recycled-object-error-migel-check-grid_c

<< Masa.20120210-fix-quanty-error-pointer-url-bsv-errors-oddb_org-french-fi-ebook | Index | Masa.20120130-update_company_textinfos2-oddb_org >>


  1. Fix errors oddb.org
  2. Check grid.c

Commits
  1. Skip limitation_text method if there is no limitation_text. Fix NoMethodError undefined method [] for nil NilClass (oddb.org)
  2. Rescued NoMethodError undefined method migel_code for 1.9:String (migel)
  3. Fix ArgumentError comparison of ODDB::State::Interactions::Basket::Check with ODDB::State::Interactions::Basket::Check failed when sorting in interaction_basket event (oddb.org)
  4. Fix NoMethodError undefined method each for nil:NilClass when sorting result by price_public (oddb.org)
  5. Fix Encoding::CompatibilityError incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (oddb.org)
  6. Fix NoMethodError undefined method generic_group_comparables for nil:NilClass in ddd_chart event (oddb.org)

Fix errors oddb.org

Refer to

#!/bin/sh
exec 2>&1
ulimit -v 10240000
exec sudo -u apache envdir /home/ywesee/env /usr/local/bin/ruby /var/www/migel/bin/migeld
  • /home/ywesee/RUBY_GC_MALLOC_LIMIT
 70000000
  • Default value is 8000000
  • With the default RUBY_GC_MALLOC_LIMIT (8000000), averagely 10 times reloading causes the recycled object error

Check grid.c

Note

  • Most of the crash cases come from
    1. grid.c#grid_add_component_stype (composite.rb: 227)
    2. grid.c#grid_to_html (composite.rb 164)
  • The last executed line in the case of composite.rb 227 is (grid.c 853, in grid_add_attribute)
 if(rb_respond_to(item, set_attribute))
  • The item.class could be (the followings are from top page of ch.oddb.org)
    1. item.class = ODDB::View::TabNavigationLink
    2. item.class = ODDB::View::TabNavigation
    3. item.class = HtmlGrid::Input
    4. item.class = HtmlGrid::Span
    5. item.class = String
    6. item.class = ODDB::View::NavigationLink
    7. item.class = HtmlGrid::Link
    8. item.class = ODDB::View::CountryNavigation
    9. item.class = ODDB::View::ZoneNavigation
    10. item.class = ODDB::View::Copyright
    11. item.class = ODDB::View::Navigation
  • These instances are checked if they have 'set_attribute' method by the 'rb_respond_to' function

How to check item.class

  • /usr/local/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.4/ext/htmlgrid/grid.c#grid_field_add_component_style
...
VALUE val;
char *value;
val = rb_funcall(item, rb_intern("class"), 0);
val = rb_funcall(val, rb_intern("to_s"), 0);
value = StringValuePtr(val);
printf("item.class = %s\n", value);
                if(rb_respond_to(item, set_attribute))
...
  • sudo /usr/local/bin/ruby extconf.rb
  • sudo make clean; make

Experiment

  • /usr/local/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.4/ext/htmlgrid/grid.c#grid_field_add_component_style
 void grid_field_add_component_style(cf, style)
 ...
                //if(rb_respond_to(item, set_attribute))
                if(rb_respond_to("hogehoge", set_attribute))
                {
                        rb_funcall(item, set_attribute, 2,
                                        str_class, style);
                }

Result

Next

  • Where is the 'item' coming from?
  • Catch it on Ruby level before grid.c

Memo (useful to check class of VALUE type variable)

char *which_class(VALUE item){
        VALUE val;
        char *value;
        val = rb_funcall(item, rb_intern("class"), 0);
        val = rb_funcall(val, rb_intern("to_s"), 0);
        value = StringValuePtr(val);
        return value;
}
  • The followings is available to check data type in C level
    • CheckType()
    • TYPE()

Note

  • cf comes from cg->fields[]
  • cg is a cGrid struct data
  • cg->fields may change in grid_set_dimensions or grid_insert_row function
  • grid_insert_row may be called from Ruby level with insert_row method
view · edit · sidebar · attach · print · history
Page last modified on January 31, 2012, at 05:33 PM