8000 Merge pull request #22 from github/dbussink-ruby-2-1-5 · github/ruby@d62e0ba · GitHub
[go: up one dir, main page]

Skip to content

Commit d62e0ba

Browse files
committed
Merge pull request #22 from github/dbussink-ruby-2-1-5
Update to upstream 2.1.5
2 parents 448f879 + 9d08974 commit d62e0ba

File tree

9 files changed

+183
-12
lines changed

9 files changed

+183
-12
lines changed

ChangeLog

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
Thu Nov 13 22:32:34 2014 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
2+
3+
* lib/rexml/document.rb: add REXML::Document#document.
4+
reported by Tomas Hoger <thoger@redhat.com> and patched by nahi.
5+
6+
Thu Nov 6 22:57:43 2014 Naohisa Goto <ngotogenome@gmail.com>
7+
8+
* bignum.c (absint_numwords_generic): set an array element after
9+
definition of a variable to fix compile error with older version
10+
of fcc (Fujitsu C Compiler) 5.6 on Solaris 10 on Sparc.
11+
[Bug #10350] [ruby-dev:48608]
12+
13+
Thu Nov 6 22:36:55 2014 Naohisa Goto <ngotogenome@gmail.com>
14+
15+
* compile.c (compile_data_alloc): add padding when strict alignment
16+
is required for memory access. Currently, the padding is enabled
17+
only when the CPU is 32-bit SPARC and the compiler is GCC.
18+
[Bug #9681] [ruby-core:61715]
19+
20+
* compile.c (STRICT_ALIGNMENT): defined if strict alignment is required
21+
22+
* compile.c (ALIGNMENT_SIZE, ALIGNMENT_SIZE_MASK, PADDING_SIZE_MAX):
23+
new macros for alignemnt word size, bit mask, max size of padding.
24+
25+
* compile.c (calc_padding): new function to calculate padding size.
26+
27+
Wed Nov 5 00:18:22 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
28+
29+
* configure.in (__builtin_setjmp): disable with gcc/clang earlier
30+
than 4.3 on Mac OS X. [ruby-core:65174] [Bug #10272]
31+
32+
Wed Nov 5 00:01:04 2014 Tanaka Akira <akr@fsij.org>
33+
34+
* bignum.c (bary_mul_balance_with_mulfunc): Fix free work area
35+
location.
36+
[ruby-dev:48723] [Bug #10464]
37+
[ruby-core:66044] [Bug #10465]
38+
Reported by Kohji Nishihama.
39+
40+
Tue Oct 28 22:30:21 2014 NARUSE, Yui <naruse@ruby-lang.org>
41+
42+
* configure.in: remove apple-gcc4.2 from CC candidates.
43+
44+
火 10 28 22:19:44 2014 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
45+
46+
* version.h (RUBY_VERSION): bump RUBY_VERSION to 2.1.5.
47+
148
Mon Oct 27 20:20:14 2014 NAKAMURA Usaku <usa@ruby-lang.org>
249

350
* lib/rexml/entity.rb: keep the entity size within the limitation.

bignum.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ bary_mul_balance_with_mulfunc(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t
16501650
}
16511651
tds = zds + n;
16521652
MEMCPY(wds, zds + n, BDIGIT, xn);
1653-
mulfunc(tds, tn, xds, xn, yds + n, r, wds-xn, wn-xn);
1653+
mulfunc(tds, tn, xds, xn, yds + n, r, wds+xn, wn-xn);
16541654
bary_add(zds + n, tn,
16551655
zds + n, tn,
16561656
wds, xn);
@@ -3294,7 +3294,7 @@ absint_numwords_generic(size_t numbytes, int nlz_bits_in_msbyte, size_t word_num
32943294
static const BDIGIT char_bit[1] = { CHAR_BIT };
32953295
BDIGIT numbytes_bary[bdigit_roomof(sizeof(numbytes))];
32963296
BDIGIT val_numbits_bary[bdigit_roomof(sizeof(numbytes) + 1)];
3297-
BDIGIT nlz_bits_in_msbyte_bary[1] = { nlz_bits_in_msbyte };
3297+
BDIGIT nlz_bits_in_msbyte_bary[1];
32983298
BDIGIT word_numbits_bary[bdigit_roomof(sizeof(word_numbits))];
32993299
BDIGIT div_bary[numberof(val_numbits_bary) + BIGDIVREM_EXTRA_WORDS];
33003300
BDIGIT mod_bary[numberof(word_numbits_bary)];
@@ -3304,6 +3304,8 @@ absint_numwords_generic(size_t numbytes, int nlz_bits_in_msbyte, size_t word_num
33043304
int sign;
33053305
size_t numwords;
33063306

3307+
nlz_bits_in_msbyte_bary[0] = nlz_bits_in_msbyte;
3308+
33073309
/*
33083310
* val_numbits = numbytes * CHAR_BIT - nlz_bits_in_msbyte
33093311
* div, mod = val_numbits.divmod(word_numbits)

compile.c

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,18 +583,72 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
583583
/* definition of data structure for compiler */
584584
/*********************************************/
585585

586+
/*
587+
* On 32-bit SPARC, GCC by default generates SPARC V7 code that may require
588+
* 8-byte word alignment. On the other hand, Oracle Solaris Studio seems to
589+
* generate SPARCV8PLUS code with unaligned memory accesss instructions.
590+
* That is why the STRICT_ALIGNMENT is defined only with GCC.
591+
*/
592+
#if defined(__sparc) && SIZEOF_VOIDP == 4 && defined(__GNUC__)
593+
#define STRICT_ALIGNMENT
594+
#endif
595+
596+
#ifdef STRICT_ALIGNMENT
597+
#if defined(HAVE_TRUE_LONG_LONG) && SIZEOF_LONG_LONG > SIZEOF_VALUE
598+
#define ALIGNMENT_SIZE SIZEOF_LONG_LONG
599+
#else
600+
#define ALIGNMENT_SIZE SIZEOF_VALUE
601+
#endif
602+
#define PADDING_SIZE_MAX ((size_t)((ALIGNMENT_SIZE) - 1))
603+
#define ALIGNMENT_SIZE_MASK PADDING_SIZE_MAX
604+
/* Note: ALIGNMENT_SIZE == (2 ** N) is expected. */
605+
#else
606+
#define PADDING_SIZE_MAX 0
607+
#endif /* STRICT_ALIGNMENT */
608+
609+
#ifdef STRICT_ALIGNMENT
610+
/* calculate padding size for aligned memory access */
611+
static size_t
612+
calc_padding(void *ptr, size_t size)
613+
{
614+
size_t mis;
615+
size_t padding = 0;
616+
617+
mis = (size_t)ptr & ALIGNMENT_SIZE_MASK;
618+
if (mis > 0) {
619+
padding = ALIGNMENT_SIZE - mis;
620+
}
621+
/*
622+
* On 32-bit sparc or equivalents, when a single VALUE is requested
623+
* and padding == sizeof(VALUE), it is clear that no padding is needed.
624+
*/
625+
#if ALIGNMENT_SIZE > SIZEOF_VALUE
626+
if (size == sizeof(VALUE) && padding == sizeof(VALUE)) {
627+
padding = 0;
628+
}
629+
#endif
630+
631+
return padding;
632+
}
633+
#endif /* STRICT_ALIGNMENT */
634+
586635
static void *
587636
compile_data_alloc(rb_iseq_t *iseq, size_t size)
588637
{
589638
void *ptr = 0;
590639
struct iseq_compile_data_storage *storage =
591640
iseq->compile_data->storage_current;
641+
#ifdef STRICT_ALIGNMENT
642+
size_t padding = calc_padding((void *)&storage->buff[storage->pos], size);
643+
#else
644+
const size_t padding = 0; /* expected to be optimized by compiler */
645+
#endif /* STRICT_ALIGNMENT */
592646

593-
if (storage->pos + size > storage->size) {
647+
if (storage->pos + size + padding > storage->size) {
594648
unsigned long alloc_size = storage->size * 2;
595649

596650
retry:
597-
if (alloc_size < size) {
651+
if (alloc_size < size + PADDING_SIZE_MAX) {
598652
alloc_size *= 2;
599653
goto retry;
600654
}
@@ -606,8 +660,15 @@ compile_data_alloc(rb_iseq_t *iseq, size_t size)
606660
storage->pos = 0;
607661
storage->size = alloc_size;
608662
storage->buff = (char *)(&storage->buff + 1);
663+
#ifdef STRICT_ALIGNMENT
664+
padding = calc_padding((void *)&storage->buff[storage->pos], size);
665+
#endif /* STRICT_ALIGNMENT */
609666
}
610667

668+
#ifdef STRICT_ALIGNMENT
669+
storage->pos += (int)padding;
670+
#endif /* STRICT_ALIGNMENT */
671+
611672
ptr = (void *)&storage->buff[storage->pos];
612673
storage->pos += size;
613674
return ptr;

configure.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ fi
423423
RUBY_NACL
424424
AS_CASE(["$host_os:$build_os"],
425425
[darwin*:darwin*], [
426-
AC_CHECK_TOOLS(CC, [gcc-4.2 clang gcc cc])
426+
AC_CHECK_TOOLS(CC, [clang gcc cc])
427427
# Following Apple deployed clang are broken
428428
# clang version 1.0 (http://llvm.org/svn/llvm-project/cfe/tags/Apple/clang-23 exported)
429429
# Apple clang version 2.0 (tags/Apple/clang-137) (based on LLVM 2.9svn)
@@ -453,7 +453,9 @@ if test "$GCC" = yes; then
453453
linker_flag=-Wl,
454454
: ${optflags=-O3}
455455
gcc_major=`echo =__GNUC__ | $CC -E -xc - | sed '/^=/!d;s///'`
456+
gcc_minor=`echo =__GNUC_MINOR__ | $CC -E -xc - | sed '/^=/!d;s///'`
456457
test -n "$gcc_major" || gcc_major=0
458+
test -n "$gcc_minor" || gcc_minor=0
457459
# RUBY_APPEND_OPTIONS(XCFLAGS, ["-include ruby/config.h" "-include ruby/missing.h"])
458460
else
459461
linker_flag=
@@ -956,6 +958,9 @@ AS_CASE(["$target_os"],
956958
ac_cv_type_getgroups=gid_t # getgroups() on Rosetta fills garbage
957959
ac_cv_lib_crypt_crypt=no
958960
ac_cv_func_fdatasync=no # Mac OS X wrongly reports it has fdatasync()
961+
if test $gcc_major -lt 4 -o \( $gcc_major -eq 4 -a $gcc_minor -lt 3 \); then
962+
ac_cv_func___builtin_setjmp=no
963+
fi
959964
AC_CACHE_CHECK(for broken crypt with 8bit chars, rb_cv_broken_crypt,
960965
[AC_TRY_RUN([
961966
#include <stdio.h>

lib/rexml/document.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ def record_entity_expansion
278278
end
279279
end
280280

281+
def document
282+
self
283+
end
284+
281285
private
282286
def build( source )
283287
Parsers::TreeParser.new( source, self ).parse

lib/rexml/entity.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def value
157157

158158
# This is a set of entity constants -- the ones defined in the XML
159159
# specification. These are +gt+, +lt+, +amp+, +quot+ and +apos+.
160+
# CAUTION: these entities does not have parent and document
160161
module EntityConst
161162
# +>+
162163
GT = Entity.new( 'gt', '>' )

test/rexml/test_document.rb

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,23 @@ def test_new
4747
</member>
4848
EOF
4949

50-
XML_WITH_NESTED_PARAMETER_ENTITY = <<EOF
50+
XML_WITH_NESTED_EMPTY_ENTITY = <<EOF
51+
<?xml version="1.0" encoding="UTF-8"?>
52+
<!DOCTYPE member [
53+
<!ENTITY a "&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;">
54+
<!ENTITY b "&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;">
55+
<!ENTITY c "&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;">
56+
<!ENTITY d "&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;">
57+
<!ENTITY e "&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;">
58+
<!ENTITY f "&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;">
59+
<!ENTITY g "">
60+
]>
61+
<member>
62+
&a;
63+
</member>
64+
EOF
65+
66+
XML_WITH_NESTED_PARAMETER_ENTITY = <<EOF
5167
<!DOCTYPE root [
5268
<!ENTITY % a "BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.">
5369
<!ENTITY % b "%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;">
@@ -59,6 +75,20 @@ def test_new
5975
<!ENTITY test "test %g;">
6076
]>
6177
<cd></cd>
78+
EOF
79+
80+
XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY = <<EOF
81+
<!DOCTYPE root [
82+
<!ENTITY % a "">
83+
<!ENTITY % b "%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;">
84+
<!ENTITY % c "%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;">
85+
<!ENTITY % d "%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;">
86+
<!ENTITY % e "%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;">
87+
<!ENTITY % f "%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;">
88+
<!ENTITY % g "%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;">
89+
<!ENTITY test "test %g;">
90+
]>
91+
<cd></cd>
6292
EOF
6393

6494
XML_WITH_4_ENTITY_EXPANSION = <<EOF
@@ -87,6 +117,18 @@ def test_entity_expansion_limit
87117
end
88118
assert_equal(101, doc.entity_expansion_count)
89119

120+
doc = REXML::Document.new(XML_WITH_NESTED_EMPTY_ENTITY)
121+
assert_raise(RuntimeError) do
122+
doc.root.children.first.value
123+
end
124+
REXML::Security.entity_expansion_limit = 100
125+
assert_equal(100, REXML::Security.entity_expansion_limit)
126+
doc = REXML::Document.new(XML_WITH_NESTED_EMPTY_ENTITY)
127+
assert_raise(RuntimeError) do
128+
doc.root.children.first.value
129+
end
130+
assert_equal(101, doc.entity_expansion_count)
131+
90132
REXML::Security.entity_expansion_limit = 4
91133
doc = REXML::Document.new(XML_WITH_4_ENTITY_EXPANSION)
92134
assert_equal("\na\na a\n<\n", doc.root.children.first.value)
@@ -108,6 +150,15 @@ def test_entity_expansion_limit_for_parameter_entity
108150
assert_raise(REXML::ParseException) do
109151
REXML::Document.new(XML_WITH_NESTED_PARAMETER_ENTITY)
110152
end
153+
154+
assert_raise(REXML::ParseException) do
155+
REXML::Document.new(XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY)
156+
end
157+
REXML::Security.entity_expansion_limit = 100
158+
assert_equal(100, REXML::Security.entity_expansion_limit)
159+
assert_raise(REXML::ParseException) do
160+
REXML::Document.new(XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY)
161+
end
111162
ensure
112163
REXML::Security.entity_expansion_limit = 10000
113164
end

test/ruby/envutil.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def self.diagnostic_reports(signame, cmd, pid, now)
192192
log = File.read(name) rescue next
193193
if /\AProcess:\s+#{cmd} \[#{pid}\]$/ =~ log
194194
File.unlink(name)
195-
File.unlink("#{path}/.#{File.basename(name)}.plist")
195+
File.unlink("#{path}/.#{File.basename(name)}.plist") rescue nil
196196
return log
197197
end
198198
end

version.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#define RUBY_VERSION "2.1.4"
2-
#define RUBY_RELEASE_DATE "2014-10-27"
3-
#define RUBY_PATCHLEVEL 265
1+
#define RUBY_VERSION "2.1.5"
2+
#define RUBY_RELEASE_DATE "2014-11-13"
3+
#define RUBY_PATCHLEVEL 273
44

55
#define RUBY_RELEASE_YEAR 2014
6-
#define RUBY_RELEASE_MONTH 10
7-
#define RUBY_RELEASE_DAY 27
6+
#define RUBY_RELEASE_MONTH 11
7+
#define RUBY_RELEASE_DAY 13
88

99
#include "ruby/version.h"
1010

0 commit comments

Comments
 (0)
0