ruby-changes:43012
From: ngoto <ko1@a...>
Date: Fri, 20 May 2016 23:55:28 +0900 (JST)
Subject: [ruby-changes:43012] ngoto:r55086 (trunk): capa should be even number on 64-bit SPARC for 8-byte word alignment
ngoto 2016-05-20 23:55:23 +0900 (Fri, 20 May 2016) New Revision: 55086 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55086 Log: capa should be even number on 64-bit SPARC for 8-byte word alignment * id_table.c (list_id_table_init): When unaligned word access is prohibited and sizeof(VALUE) is 8 (64-bit machines), capa should always be even number for 8-byte word alignment of the values of a table. This code assumes that sizeof(ID) is 4, sizeof(VALUE) is 8, and xmalloc() returns 8-byte aligned memory. This fixes bus error on 64-bit SPARC Solaris 10. [Bug #12406][ruby-dev:49631] Modified files: trunk/ChangeLog trunk/id_table.c Index: ChangeLog =================================================================== --- ChangeLog (revision 55085) +++ ChangeLog (revision 55086) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri May 20 23:45:53 2016 Naohisa Goto <ngotogenome@g...> + + * id_table.c (list_id_table_init): When unaligned word access is + prohibited and sizeof(VALUE) is 8 (64-bit machines), + capa should always be even number for 8-byte word alignment + of the values of a table. This code assumes that sizeof(ID) is 4, + sizeof(VALUE) is 8, and xmalloc() returns 8-byte aligned memory. + This fixes bus error on 64-bit SPARC Solaris 10. + [Bug #12406][ruby-dev:49631] + Fri May 20 22:30:09 2016 Naohisa Goto <ngotogenome@g...> * symbol.h (rb_id2sym): Use HAVE_BUILTIN___BUILTIN_CONSTANT_P Index: id_table.c =================================================================== --- id_table.c (revision 55085) +++ id_table.c (revision 55086) @@ -379,6 +379,14 @@ static struct list_id_table * https://github.com/ruby/ruby/blob/trunk/id_table.c#L379 list_id_table_init(struct list_id_table *tbl, size_t capa) { if (capa > 0) { +#if ID_TABLE_USE_CALC_VALUES && \ + (UNALIGNED_WORD_ACCESS == 0) && (SIZEOF_VALUE == 8) + /* Workaround for 8-byte word alignment on 64-bit SPARC. + * This code assumes that sizeof(ID) == 4, sizeof(VALUE) == 8, and + * xmalloc() returns 8-byte aligned memory block. + */ + if (capa & (size_t)1) capa += 1; +#endif tbl->capa = (int)capa; #if ID_TABLE_USE_CALC_VALUES tbl->keys = (id_key_t *)xmalloc(sizeof(id_key_t) * capa + sizeof(VALUE) * capa); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/