merge revision(s) 45291,45299,45314,45325: [Backport #9599]

	* ext/dl/cptr.c (dlptr_free), ext/dl/handle.c (dlhandle_free),
	  ext/fiddle/handle.c (fiddle_handle_free),
	  ext/fiddle/pointer.c (fiddle_ptr_free): fix memory leak.
	  based on the patch Heesob Park at [ruby-dev:48021] [Bug #9599].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 45637: [Backport #9726]

	* parse.y (primary): flush cmdarg flags inside left-paren in a
	  command argument, to allow parenthesed do-block as an argument
	  without arguments parentheses.  [ruby-core:61950] [Bug #9726]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 39239,45045,45530: [Backport #9697]

	* ext/socket: always operate length of socket addess companion with
	  socket address. 

	* ext/socket/rubysocket.h (rsock_make_ipaddr): add an argument for
	  socket address length.
	  (rsock_ipaddr): ditto.

	* ext/socket/ipsocket.c (ip_addr): pass length to rsock_ipaddr.
	  (ip_peeraddr): ditto.
	  (ip_s_getaddress): pass length to rsock_make_ipaddr.

	* ext/socket/socket.c (make_addrinfo): pass length to rsock_ipaddr.
	  (sock_s_getnameinfo): pass actual address length to rb_getnameinfo.
	  (sock_s_unpack_sockaddr_in): pass length to rsock_make_ipaddr.
	  

	* ext/socket/init.c (rsock_s_recvfrom): pass length to rsock_ipaddr.
	  (rsock_s_recvfrom_nonblock): ditto.

	* ext/socket/tcpsocket.c (tcp_sockaddr): pass length to
	  rsock_make_ipaddr.

	* ext/socket/raddrinfo.c (make_ipaddr0): add an argument for socket
	  address length.  pass the length to rb_getnameinfo.
	  (rsock_ipaddr): ditto.
	  (rsock_make_ipaddr): add an argument for socket address length. 
	  pass the length to make_ipaddr0.
	  (make_inetaddr): pass length to make_ipaddr0.
	  a local variable renamed.
	  (host_str): a local variable renamed.
	  (port_str): ditto.

	* ext/socket/ipsocket.c (ip_s_getaddress): Don't access freed memory.

	* ext/socket/socket.c (sock_s_getnameinfo): Save errno for EAI_SYSTEM.
	  Reported by Saravana kumar.  [ruby-core:61820] [Bug #9697]
	  Fixed by Heesob Park.  [ruby-core:61868]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 45287:45290: [Backport #9600]

	* process.c (obj2uid, obj2gid): now getpwnam_r() and getgrnam_r()
	  may need larger buffers than sysconf values, so retry with
	  expanding the buffer when ERANGE is returned.
	  [ruby-core:61325] [Bug #9600]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 44474,44538,44539,44890,44896,45954: [Backport #8358]

	* configure.in: use SSE2 instructions for drop unexpected
	  precisions.  [ruby-core:54738] [Bug #8358]

	* configure.in: use SSE2 instructions to drop unexpected precisions on
	  other than mingw.  [ruby-core:59472] [Bug #8358]

	* configure.in: -mstackrealign is necessary for -msse2 working.
	  [ruby-core:54716] [Bug #8349]

	* configure.in: -mstackrealign is necessary for -msse2 working.
	  [ruby-core:54716] [Bug #8349]

	* configure.in: add qouting brackets and append wildcard for the
	  rest after target_cpu, to properly detect platform for SSE2
	  instructions.  [ruby-core:60576] [Bug #8358]

	* configure.in: Fix compilation error.
	  https://bugs.ruby-lang.org/issues/8358#note-16

	* configure.in: enable SSE2 on mingw. target='i386-pc-mingw32'.
	  [ruby-core:62095] [Bug #8358]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 46060: [Backport #9627]

	* net/protocol.rb (using_each_crlf_line): fix SMTP dot-stuffing
	  for messages not ending with a new-line.
	  [ruby-core:61441] [Bug #9627] [fix GH-616]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 45287:

	process.c: tmp buffer instead of alloca

	* process.c (OBJ2UID1, OBJ2GID1): separate from OBJ2UID and
  OBJ2GID respectively, need given buffers.

	* process.c (OBJ2UID, OBJ2GID): no longer need PREPARE_GETPWNAM
  and PREPARE_GETGRNAM.

	* process.c (obj2uid, obj2gid): use tmp buffer instead of alloca
  to get rid of potential stack overflow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 45899: [Backport #9751]

	* thread.c (thread_start_func_2): stop if forked in a sub-thread,
	  the thread has become the main thread.
	  [ruby-core:62070] [Bug #9751]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 45874: [Backport #9813]

	* class.c (rb_mod_init_copy): always clear instance variable,
	  constant and method tables first, regardless the source tables.
	  [ruby-dev:48182] [Bug #9813]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 46194: [Backport #9835]

	* signal.c (signal_exec): ignore immediate cmd for SIG_IGN

	* signal.c (trap_handler): set cmd to true for SIG_IGN

	* signal.c (trap): handle nil and true values for oldcmd
	  [Bug #9835]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 43748,45947,45951: [Backport #9739]

	* eval_intern.h (SAVE_ROOT_JMPBUF): workaround for the failure of
	  test/ruby/test_exception.rb on Windows.
	  wrap by __try and __exception statements on mswin to raise SIGSEGV
	  when EXCEPTION_STACK_OVERFLOW is occurred, because MSVCRT doesn't
	  handle the exception.
	  however, (1) mingw-gcc doesn't support __try and __exception
	  statements, and (2) we cannot retry SystemStackError after this
	  change yet (maybe crashed) because SEH and longjmp() are too
	  uncongenial.

	* signal.c (check_stack_overflow, CHECK_STACK_OVERFLOW): now defined on
	  Windows, too.

	* thread_win32.c (ruby_stack_overflowed_p): ditto.

	* thread_win32.c (rb_w32_stack_overflow_handler): use Structured
	  Exception Handling by Addvectoredexceptionhandler() for machine
	  stack overflow on mingw.
	  This would be equivalent to the handling using __try and __exept
	  on mswin introduced by r43748.
	  Exception Handling by AddVectoredExceptionHandler() for machine
	  This would be equivalent to the handling using __try and __except


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 46182: [Backport #9872]

	* lib/net/ftp.rb (transfercmd): Close TCP server socket even if an
	  exception occur.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 45793: [Backport #9608]

	* complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END
	  [Bug #9608]

	* rational.c (read_digits): ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 45863,45871: [Backport #9750]

	* ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept):
	  Consider Socket#accept as well as TCPServer#accept.
	  Reported by Sam Stelfox.  [ruby-core:62064] [Bug #9750]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 45979: [Backport #9847]

	* io.c (io_setstrbuf): always check if the buffer is modifiable.
	  [ruby-core:62643] [Bug #9847]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 46075: [Backport #9856]

	* process.c (proc_getgroups, proc_setgroups): use ALLOCV_N
	  [Bug #9856]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 46098: [Backport #9861]

	* vsnprintf.c (BSD_vfprintf): fix string width when precision is
	  given.  as the result of `memchr` is NULL or its offset from the
	  start cannot exceed the size, the comparison was always false.
	  [ruby-core:62737] [Bug #9861]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 46233: [Backport #9878]

	* signal.c (ruby_signal): should return either `old.sa_sigaction`
	  or `old.sa_handler`, depending on whether `SA_SIGINFO` is set in
	  `old.sa_flags`, because they may not be a union.
	  [ruby-core:62836] [Bug #9878]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
merge revision(s) 46243,46244: [Backport #9882] [Backport #9883]

	* string.c (rb_str_substr): need to reset code range for shared
	  string too, not only copied string.
	  [ruby-core:62842] [Bug #9882]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby/envutil.rb (assert_no_memory_leak): changed the threshold to avoid
  false-positives on some CI.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e