Skip to content

Commit

Permalink
Merge pull request #22 from github/dbussink-ruby-2-1-5
Browse files Browse the repository at this point in the history
Update to upstream 2.1.5
  • Loading branch information
dbussink committed Nov 14, 2014
2 parents 448f879 + 9d08974 commit d62e0ba
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 12 deletions.
47 changes: 47 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
Thu Nov 13 22:32:34 2014 CHIKANAGA Tomoyuki <[email protected]>

* lib/rexml/document.rb: add REXML::Document#document.
reported by Tomas Hoger <[email protected]> and patched by nahi.

Thu Nov 6 22:57:43 2014 Naohisa Goto <[email protected]>

* bignum.c (absint_numwords_generic): set an array element after
definition of a variable to fix compile error with older version
of fcc (Fujitsu C Compiler) 5.6 on Solaris 10 on Sparc.
[Bug #10350] [ruby-dev:48608]

Thu Nov 6 22:36:55 2014 Naohisa Goto <[email protected]>

* compile.c (compile_data_alloc): add padding when strict alignment
is required for memory access. Currently, the padding is enabled
only when the CPU is 32-bit SPARC and the compiler is GCC.
[Bug #9681] [ruby-core:61715]

* compile.c (STRICT_ALIGNMENT): defined if strict alignment is required

* compile.c (ALIGNMENT_SIZE, ALIGNMENT_SIZE_MASK, PADDING_SIZE_MAX):
new macros for alignemnt word size, bit mask, max size of padding.

* compile.c (calc_padding): new function to calculate padding size.

Wed Nov 5 00:18:22 2014 Nobuyoshi Nakada <[email protected]>

* configure.in (__builtin_setjmp): disable with gcc/clang earlier
than 4.3 on Mac OS X. [ruby-core:65174] [Bug #10272]

Wed Nov 5 00:01:04 2014 Tanaka Akira <[email protected]>

* bignum.c (bary_mul_balance_with_mulfunc): Fix free work area
location.
[ruby-dev:48723] [Bug #10464]
[ruby-core:66044] [Bug #10465]
Reported by Kohji Nishihama.

Tue Oct 28 22:30:21 2014 NARUSE, Yui <[email protected]>

* configure.in: remove apple-gcc4.2 from CC candidates.

火 10 28 22:19:44 2014 CHIKANAGA Tomoyuki <[email protected]>

* version.h (RUBY_VERSION): bump RUBY_VERSION to 2.1.5.

Mon Oct 27 20:20:14 2014 NAKAMURA Usaku <[email protected]>

* lib/rexml/entity.rb: keep the entity size within the limitation.
Expand Down
6 changes: 4 additions & 2 deletions bignum.c
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ bary_mul_balance_with_mulfunc(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t
}
tds = zds + n;
MEMCPY(wds, zds + n, BDIGIT, xn);
mulfunc(tds, tn, xds, xn, yds + n, r, wds-xn, wn-xn);
mulfunc(tds, tn, xds, xn, yds + n, r, wds+xn, wn-xn);
bary_add(zds + n, tn,
zds + n, tn,
wds, xn);
Expand Down Expand Up @@ -3294,7 +3294,7 @@ absint_numwords_generic(size_t numbytes, int nlz_bits_in_msbyte, size_t word_num
static const BDIGIT char_bit[1] = { CHAR_BIT };
BDIGIT numbytes_bary[bdigit_roomof(sizeof(numbytes))];
BDIGIT val_numbits_bary[bdigit_roomof(sizeof(numbytes) + 1)];
BDIGIT nlz_bits_in_msbyte_bary[1] = { nlz_bits_in_msbyte };
BDIGIT nlz_bits_in_msbyte_bary[1];
BDIGIT word_numbits_bary[bdigit_roomof(sizeof(word_numbits))];
BDIGIT div_bary[numberof(val_numbits_bary) + BIGDIVREM_EXTRA_WORDS];
BDIGIT mod_bary[numberof(word_numbits_bary)];
Expand All @@ -3304,6 +3304,8 @@ absint_numwords_generic(size_t numbytes, int nlz_bits_in_msbyte, size_t word_num
int sign;
size_t numwords;

nlz_bits_in_msbyte_bary[0] = nlz_bits_in_msbyte;

/*
* val_numbits = numbytes * CHAR_BIT - nlz_bits_in_msbyte
* div, mod = val_numbits.divmod(word_numbits)
Expand Down
65 changes: 63 additions & 2 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,18 +583,72 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
/* definition of data structure for compiler */
/*********************************************/

/*
* On 32-bit SPARC, GCC by default generates SPARC V7 code that may require
* 8-byte word alignment. On the other hand, Oracle Solaris Studio seems to
* generate SPARCV8PLUS code with unaligned memory accesss instructions.

This comment has been minimized.

Copy link
@z-weed

z-weed Nov 18, 2014

access :P

* That is why the STRICT_ALIGNMENT is defined only with GCC.
*/
#if defined(__sparc) && SIZEOF_VOIDP == 4 && defined(__GNUC__)
#define STRICT_ALIGNMENT
#endif

#ifdef STRICT_ALIGNMENT
#if defined(HAVE_TRUE_LONG_LONG) && SIZEOF_LONG_LONG > SIZEOF_VALUE
#define ALIGNMENT_SIZE SIZEOF_LONG_LONG
#else
#define ALIGNMENT_SIZE SIZEOF_VALUE
#endif
#define PADDING_SIZE_MAX ((size_t)((ALIGNMENT_SIZE) - 1))
#define ALIGNMENT_SIZE_MASK PADDING_SIZE_MAX
/* Note: ALIGNMENT_SIZE == (2 ** N) is expected. */
#else
#define PADDING_SIZE_MAX 0
#endif /* STRICT_ALIGNMENT */

#ifdef STRICT_ALIGNMENT
/* calculate padding size for aligned memory access */
static size_t
calc_padding(void *ptr, size_t size)
{
size_t mis;
size_t padding = 0;

mis = (size_t)ptr & ALIGNMENT_SIZE_MASK;
if (mis > 0) {
padding = ALIGNMENT_SIZE - mis;
}
/*
* On 32-bit sparc or equivalents, when a single VALUE is requested
* and padding == sizeof(VALUE), it is clear that no padding is needed.
*/
#if ALIGNMENT_SIZE > SIZEOF_VALUE
if (size == sizeof(VALUE) && padding == sizeof(VALUE)) {
padding = 0;
}
#endif

return padding;
}
#endif /* STRICT_ALIGNMENT */

static void *
compile_data_alloc(rb_iseq_t *iseq, size_t size)
{
void *ptr = 0;
struct iseq_compile_data_storage *storage =
iseq->compile_data->storage_current;
#ifdef STRICT_ALIGNMENT
size_t padding = calc_padding((void *)&storage->buff[storage->pos], size);
#else
const size_t padding = 0; /* expected to be optimized by compiler */
#endif /* STRICT_ALIGNMENT */

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

retry:
if (alloc_size < size) {
if (alloc_size < size + PADDING_SIZE_MAX) {
alloc_size *= 2;
goto retry;
}
Expand All @@ -606,8 +660,15 @@ compile_data_alloc(rb_iseq_t *iseq, size_t size)
storage->pos = 0;
storage->size = alloc_size;
storage->buff = (char *)(&storage->buff + 1);
#ifdef STRICT_ALIGNMENT
padding = calc_padding((void *)&storage->buff[storage->pos], size);
#endif /* STRICT_ALIGNMENT */
}

#ifdef STRICT_ALIGNMENT
storage->pos += (int)padding;
#endif /* STRICT_ALIGNMENT */

ptr = (void *)&storage->buff[storage->pos];
storage->pos += size;
return ptr;
Expand Down
7 changes: 6 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ fi
RUBY_NACL
AS_CASE(["$host_os:$build_os"],
[darwin*:darwin*], [
AC_CHECK_TOOLS(CC, [gcc-4.2 clang gcc cc])
AC_CHECK_TOOLS(CC, [clang gcc cc])
# Following Apple deployed clang are broken
# clang version 1.0 (http://llvm.org/svn/llvm-project/cfe/tags/Apple/clang-23 exported)
# Apple clang version 2.0 (tags/Apple/clang-137) (based on LLVM 2.9svn)
Expand Down Expand Up @@ -453,7 +453,9 @@ if test "$GCC" = yes; then
linker_flag=-Wl,
: ${optflags=-O3}
gcc_major=`echo =__GNUC__ | $CC -E -xc - | sed '/^=/!d;s///'`
gcc_minor=`echo =__GNUC_MINOR__ | $CC -E -xc - | sed '/^=/!d;s///'`
test -n "$gcc_major" || gcc_major=0
test -n "$gcc_minor" || gcc_minor=0
# RUBY_APPEND_OPTIONS(XCFLAGS, ["-include ruby/config.h" "-include ruby/missing.h"])
else
linker_flag=
Expand Down Expand Up @@ -956,6 +958,9 @@ AS_CASE(["$target_os"],
ac_cv_type_getgroups=gid_t # getgroups() on Rosetta fills garbage
ac_cv_lib_crypt_crypt=no
ac_cv_func_fdatasync=no # Mac OS X wrongly reports it has fdatasync()
if test $gcc_major -lt 4 -o \( $gcc_major -eq 4 -a $gcc_minor -lt 3 \); then
ac_cv_func___builtin_setjmp=no
fi
AC_CACHE_CHECK(for broken crypt with 8bit chars, rb_cv_broken_crypt,
[AC_TRY_RUN([
#include <stdio.h>
Expand Down
4 changes: 4 additions & 0 deletions lib/rexml/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ def record_entity_expansion
end
end

def document
self
end

private
def build( source )
Parsers::TreeParser.new( source, self ).parse
Expand Down
1 change: 1 addition & 0 deletions lib/rexml/entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def value

# This is a set of entity constants -- the ones defined in the XML
# specification. These are +gt+, +lt+, +amp+, +quot+ and +apos+.
# CAUTION: these entities does not have parent and document
module EntityConst
# +>+
GT = Entity.new( 'gt', '>' )
Expand Down
53 changes: 52 additions & 1 deletion test/rexml/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,23 @@ def test_new
</member>
EOF

XML_WITH_NESTED_PARAMETER_ENTITY = <<EOF
XML_WITH_NESTED_EMPTY_ENTITY = <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE member [
<!ENTITY a "&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;">
<!ENTITY b "&c;&c;&c;&c;&c;&c;&c;&c;&c;&c;">
<!ENTITY c "&d;&d;&d;&d;&d;&d;&d;&d;&d;&d;">
<!ENTITY d "&e;&e;&e;&e;&e;&e;&e;&e;&e;&e;">
<!ENTITY e "&f;&f;&f;&f;&f;&f;&f;&f;&f;&f;">
<!ENTITY f "&g;&g;&g;&g;&g;&g;&g;&g;&g;&g;">
<!ENTITY g "">
]>
<member>
&a;
</member>
EOF

XML_WITH_NESTED_PARAMETER_ENTITY = <<EOF
<!DOCTYPE root [
<!ENTITY % a "BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.BOOM.">
<!ENTITY % b "%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;">
Expand All @@ -59,6 +75,20 @@ def test_new
<!ENTITY test "test %g;">
]>
<cd></cd>
EOF

XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY = <<EOF
<!DOCTYPE root [
<!ENTITY % a "">
<!ENTITY % b "%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;%a;">
<!ENTITY % c "%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;%b;">
<!ENTITY % d "%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;%c;">
<!ENTITY % e "%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;">
<!ENTITY % f "%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;%e;">
<!ENTITY % g "%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;%f;">
<!ENTITY test "test %g;">
]>
<cd></cd>
EOF

XML_WITH_4_ENTITY_EXPANSION = <<EOF
Expand Down Expand Up @@ -87,6 +117,18 @@ def test_entity_expansion_limit
end
assert_equal(101, doc.entity_expansion_count)

doc = REXML::Document.new(XML_WITH_NESTED_EMPTY_ENTITY)
assert_raise(RuntimeError) do
doc.root.children.first.value
end
REXML::Security.entity_expansion_limit = 100
assert_equal(100, REXML::Security.entity_expansion_limit)
doc = REXML::Document.new(XML_WITH_NESTED_EMPTY_ENTITY)
assert_raise(RuntimeError) do
doc.root.children.first.value
end
assert_equal(101, doc.entity_expansion_count)

REXML::Security.entity_expansion_limit = 4
doc = REXML::Document.new(XML_WITH_4_ENTITY_EXPANSION)
assert_equal("\na\na a\n<\n", doc.root.children.first.value)
Expand All @@ -108,6 +150,15 @@ def test_entity_expansion_limit_for_parameter_entity
assert_raise(REXML::ParseException) do
REXML::Document.new(XML_WITH_NESTED_PARAMETER_ENTITY)
end

assert_raise(REXML::ParseException) do
REXML::Document.new(XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY)
end
REXML::Security.entity_expansion_limit = 100
assert_equal(100, REXML::Security.entity_expansion_limit)
assert_raise(REXML::ParseException) do
REXML::Document.new(XML_WITH_NESTED_EMPTY_PARAMETER_ENTITY)
end
ensure
REXML::Security.entity_expansion_limit = 10000
end
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/envutil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def self.diagnostic_reports(signame, cmd, pid, now)
log = File.read(name) rescue next
if /\AProcess:\s+#{cmd} \[#{pid}\]$/ =~ log
File.unlink(name)
File.unlink("#{path}/.#{File.basename(name)}.plist")
File.unlink("#{path}/.#{File.basename(name)}.plist") rescue nil
return log
end
end
Expand Down
10 changes: 5 additions & 5 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.1.4"
#define RUBY_RELEASE_DATE "2014-10-27"
#define RUBY_PATCHLEVEL 265
#define RUBY_VERSION "2.1.5"
#define RUBY_RELEASE_DATE "2014-11-13"
#define RUBY_PATCHLEVEL 273

#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 10
#define RUBY_RELEASE_DAY 27
#define RUBY_RELEASE_MONTH 11
#define RUBY_RELEASE_DAY 13

#include "ruby/version.h"

Expand Down

0 comments on commit d62e0ba

Please sign in to comment.