Commit graph

1582 commits

Author SHA1 Message Date
usa
f8efd7f9e8 merge revision(s) 5b1bf8dd2d: [Backport #16099]
UTF LE is fixed at least the first 2 bytes
	
	* io.c (io_strip_bom): if the first 2 bytes are 0xFF0xFE, it
	  should be a little-endian UTF, 16 or 32.  [Bug #16099]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@67772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-08-26 16:44:03 +00:00
usa
bad6483364 merge revision(s) f4fe2a76b0: [Backport #15793]
merge revision(s) 7b7043e5da: [Backport
	 #15793]

		eliminate use of freed memory

		rb_io_fptr_finalize_internal frees the memory region.

		=================================================================
		==85264==ERROR: AddressSanitizer: heap-use-after-free on address 0x610000000d8c at pc 0x5608e38077f7 bp 0x7ffee12d5440 sp 0x7ffee12d5438
		READ of size 4 at 0x610000000d8c thread T0
		    #0 0x5608e38077f6 in rb_io_memsize io.c:4749:24
		    #1 0x5608e37a0481 in obj_memsize_of gc.c:3547:14
		    #2 0x5608e37a4f30 in check_rvalue_consistency gc.c:1107:2
		    #3 0x5608e37a2624 in RVALUE_OLD_P gc.c:1218:5
		    #4 0x5608e37a5bae in rb_gc_force_recycle gc.c:6652:18
		    #5 0x5608e38191f9 in rb_f_backquote io.c:9021:5
		    #6 0x5608e3d8aa14 in call_cfunc_1 vm_insnhelper.c:2058:12
		    #7 0x5608e3d6e23d in vm_call_cfunc_with_frame vm_insnhelper.c:2211:11
		    #8 0x5608e3d54a35 in vm_call_cfunc vm_insnhelper.c:2229:12
		    #9 0x5608e3d5253b in vm_call_method_each_type vm_insnhelper.c:2564:9
		    #10 0x5608e3d51f50 in vm_call_method vm_insnhelper.c:2701:13
		    #11 0x5608e3cf2de4 in vm_call_general vm_insnhelper.c:2734:12
		    #12 0x5608e3d79918 in vm_sendish vm_insnhelper.c:3627:11
		    #13 0x5608e3d06cf5 in vm_exec_core insns.def:789:11
		    #14 0x5608e3d43700 in rb_vm_exec vm.c:1892:22
		    #15 0x5608e3d47cbf in rb_iseq_eval_main vm.c:2151:11
		    #16 0x5608e37620ca in ruby_exec_internal eval.c:262:2
		    #17 0x5608e376198b in ruby_exec_node eval.c:326:12
		    #18 0x5608e37617d0 in ruby_run_node eval.c:318:25
		    #19 0x5608e35c9486 in main main.c:42:9
		    #20 0x7f62e9421b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
		    #21 0x5608e3522289 in _start (miniruby+0x15f289)

		0x610000000d8c is located 76 bytes inside of 192-byte region [0x610000000d40,0x610000000e00)
		freed by thread T0 here:
		    #0 0x5608e359a2ed in free (miniruby+0x1d72ed)
		    #1 0x5608e37af421 in objspace_xfree gc.c:9591:5
		    #2 0x5608e37af3da in ruby_sized_xfree gc.c:9687:2
		    #3 0x5608e3799ac8 in ruby_xfree gc.c:9694:5
		    #4 0x5608e380746d in rb_io_fptr_finalize_internal io.c:4728:5
		    #5 0x5608e38191ed in rb_f_backquote io.c:9020:5
		    #6 0x5608e3d8aa14 in call_cfunc_1 vm_insnhelper.c:2058:12
		    #7 0x5608e3d6e23d in vm_call_cfunc_with_frame vm_insnhelper.c:2211:11
		    #8 0x5608e3d54a35 in vm_call_cfunc vm_insnhelper.c:2229:12
		    #9 0x5608e3d5253b in vm_call_method_each_type vm_insnhelper.c:2564:9
		    #10 0x5608e3d51f50 in vm_call_method vm_insnhelper.c:2701:13
		    #11 0x5608e3cf2de4 in vm_call_general vm_insnhelper.c:2734:12
		    #12 0x5608e3d79918 in vm_sendish vm_insnhelper.c:3627:11
		    #13 0x5608e3d06cf5 in vm_exec_core insns.def:789:11
		    #14 0x5608e3d43700 in rb_vm_exec vm.c:1892:22
		    #15 0x5608e3d47cbf in rb_iseq_eval_main vm.c:2151:11
		    #16 0x5608e37620ca in ruby_exec_internal eval.c:262:2
		    #17 0x5608e376198b in ruby_exec_node eval.c:326:12
		    #18 0x5608e37617d0 in ruby_run_node eval.c:318:25
		    #19 0x5608e35c9486 in main main.c:42:9
		    #20 0x7f62e9421b96 in __libc_start_main
		/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310

		previously allocated by thread T0 here:
		    #0 0x5608e359a56d in malloc (miniruby+0x1d756d)
		    #1 0x5608e37aed12 in objspace_xmalloc0 gc.c:9416:5
		    #2 0x5608e37aebe7 in ruby_xmalloc0 gc.c:9600:12
		    #3 0x5608e37aea8b in ruby_xmalloc_body gc.c:9609:12
		    #4 0x5608e37a6d64 in ruby_xmalloc gc.c:11469:12
		    #5 0x5608e380e4b4 in rb_io_fptr_new io.c:8040:19
		    #6 0x5608e380e446 in rb_io_make_open_file io.c:8077:10
		    #7 0x5608e3850ea0 in pipe_open io.c:6707:5
		    #8 0x5608e384edb4 in pipe_open_s io.c:6772:12
		    #9 0x5608e381910b in rb_f_backquote io.c:9014:12
		    #10 0x5608e3d8aa14 in call_cfunc_1 vm_insnhelper.c:2058:12
		    #11 0x5608e3d6e23d in vm_call_cfunc_with_frame vm_insnhelper.c:2211:11
		    #12 0x5608e3d54a35 in vm_call_cfunc vm_insnhelper.c:2229:12
		    #13 0x5608e3d5253b in vm_call_method_each_type vm_insnhelper.c:2564:9
		    #14 0x5608e3d51f50 in vm_call_method vm_insnhelper.c:2701:13
		    #15 0x5608e3cf2de4 in vm_call_general vm_insnhelper.c:2734:12
		    #16 0x5608e3d79918 in vm_sendish vm_insnhelper.c:3627:11
		    #17 0x5608e3d06cf5 in vm_exec_core insns.def:789:11
		    #18 0x5608e3d43700 in rb_vm_exec vm.c:1892:22
		    #19 0x5608e3d47cbf in rb_iseq_eval_main vm.c:2151:11
		    #20 0x5608e37620ca in ruby_exec_internal eval.c:262:2
		    #21 0x5608e376198b in ruby_exec_node eval.c:326:12
		    #22 0x5608e37617d0 in ruby_run_node eval.c:318:25
		    #23 0x5608e35c9486 in main main.c:42:9
		    #24 0x7f62e9421b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310

		SUMMARY: AddressSanitizer: heap-use-after-free io.c:4749:24 in
		rb_io_memsize
		Shadow bytes around the buggy address:
		  0x0c207fff8160: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
		  0x0c207fff8170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
		  0x0c207fff8180: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
		  0x0c207fff8190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
		  0x0c207fff81a0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
		=>0x0c207fff81b0: fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd
		  0x0c207fff81c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
		  0x0c207fff81d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
		  0x0c207fff81e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
		  0x0c207fff81f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
		  0x0c207fff8200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
		Shadow byte legend (one shadow byte represents 8 application bytes):
		  Addressable:           00
		  Partially addressable: 01 02 03 04 05 06 07
		  Heap left redzone:       fa
		  Freed heap region:       fd
		  Stack left redzone:      f1
		  Stack mid redzone:       f2
		  Stack right redzone:     f3
		  Stack after return:      f5
		  Stack use after scope:   f8
		  Global redzone:          f9
		  Global init order:       f6
		  Poisoned by user:        f7
		  Container overflow:      fc
		  Array cookie:            ac
		  Intra object redzone:    bb
		  ASan internal:           fe
		  Left alloca redzone:     ca
		  Right alloca redzone:    cb
		  Shadow gap:              cc
		==85264==ABORTING

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@67748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-08-19 06:35:25 +00:00
usa
0e38368894 merge revision(s) 374c8f4eba: [Backport #15823]
Fixed about ARGF.lineno

[Bug #15823]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@67722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-07-31 14:58:36 +00:00
nagachika
7bd41bd2ca merge revision(s) 67188: [Backport #15642]
io.c: chomp CR at the end of read buffer

	* io.c (rb_io_getline_fast): chomp CR followed by LF but separated
	  by the read buffer boundary.  [ruby-core:91707] [Bug #15642]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@67191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-07 15:19:34 +00:00
nagachika
d6ea20ff49 merge revision(s) 66242: [Backport #15387]
io.c (io_write_nonblock): add RB_GC_GUARD, io_fflush may switch threads

	Since io_fflush may block on mutex or rb_io_wait_readable and
	switch threads, we need to ensure the `str' VALUE returned by
	`rb_obj_as_string` is visible to GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@66876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-20 04:47:51 +00:00
nagachika
fcb4a3d88f merge revision(s) 63304: [Backport #14713]
io.c: workaround for EPROTOTYPE

	* io.c (internal_write_func, internal_writev_func): retry at
	  unexpected EPROTOTYPE on macOS, to get rid of a kernel bug.
	  [ruby-core:86690] [Bug #14713]

	* ext/socket/init.c (rsock_{sendto,send,write}_blocking): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@63826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-02 09:15:33 +00:00
kazu
9f68d0f591 [DOC] Improve example of IO#pread [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-24 02:41:00 +00:00
kazu
13247fa417 [DOC] Use File.open with block instead of File.new without close [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-24 01:26:46 +00:00
glass
072ed558d5 io.c: ignore EPERM
* io.c (nogvl_copy_file_range): ignore EPERM and fallback to
  sendfile(2) or read/write. copy_file_range(2) may not exist
  even if __NR_copy_file_range is defined in the build environment.
  [Bug #14207]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 08:47:39 +00:00
normal
3b174fb7d6 io.c: IO#pwrite uses tmp buffer to avoid parallel modification
Since we release GVL, we must freeze and duplicate the string buffer
to prevent other threads from modifying our buffer while we are
waiting on pwrite(2).

* io.c (rb_io_pwrite): use_rb_str_tmp_frozen_{acquire/release}
  [Bug #14195]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-21 00:26:24 +00:00
nobu
d2f685eed7 io.c: opening external command
* io.c (rb_io_open_generic): try to open the named file as usual,
  if klass is not IO nor File, so that Errno::ENOENT will be
  raised probably.  calling on File will be same in the future.

From: Nobuyoshi Nakada <nobu@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18 07:15:07 +00:00
nobu
6b718de1d6 io.c: open generic in binread
* io.c (rb_io_s_binread): fix r61317, unintentional change.

From: Nobuyoshi Nakada <nobu@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18 07:10:15 +00:00
nobu
2ad35b31bb io.c: opening external command
* io.c (rb_io_open_generic): when external command will be invoked
  as other than IO singleton method, probably unintentionally,
  warn if it is File or raise ArgumentError.

From: Nobuyoshi Nakada <nobu@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18 04:32:54 +00:00
nobu
7d24c27d21 io.c: open_key_args by rb_io_open
* io.c (open_key_args): open by rb_io_open always also when
  open_args: option is given.

From: Nobuyoshi Nakada <nobu@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18 03:38:20 +00:00
kazu
a9419fbd4f [DOC] IO.new accepts external_encoding
Revert part of r61278 [Bug #13655]
[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-15 11:52:41 +00:00
naruse
9fa7722bbc IO.new doesn't recive "-" as external_encoding [Bug #13655]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-15 08:26:33 +00:00
shugo
3616b07c9a Fix a documentation error of IO#putc.
IO#putc is multi-byte character safe when a String is given as its argument.
[ruby-core:82019] [Bug #13741]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-03 08:10:42 +00:00
usa
c88c7d911f bold/underscore support in traceback before Windows10
* io.c (rb_write_error2): call `rb_w32_write_console()` when the device is tty,
  like `rb_write_error_str()`.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 05:32:29 +00:00
nobu
1046eae781 io.c: read BOM only for reading
* io.c (io_strip_bom): just abandon detecting UTF encoding by BOM
  unless opened for reading.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-23 07:10:56 +00:00
stomar
e36ccef549 io.c: improve docs for the chomp option
* io.c: [DOC] improve the description for the chomp option and
  add examples to IO.readlines and IO#readlines; other small fixes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-02 20:38:04 +00:00
stomar
b1e77e85b6 io.c: improve docs
* io.c: [DOC] fix rdoc for some cross references; fix grammar.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 20:58:36 +00:00
stomar
bf9ffeed31 io.c: docs for IO#write
* io.c: [DOC] fix example and language in IO#write docs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 20:57:29 +00:00
nobu
8354b6d2cd io.c: honor buffered mode
* io.c (io_writev): honor buffered mode to get rid of broken pipe
  error when stdout is redirected to a pipeline.
  [ruby-core:83578] [Feature #14042]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 05:46:23 +00:00
nobu
85195203f4 io.c: convert to string at writev
* io.c (io_fwritev): needs conversion to string before accessing
  the content, as well as single argument case, not to segfault.
  [Feature #9323]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 00:43:34 +00:00
kazu
f0c3df3113 Add note to close_{read,write} too
when call on closed stream
[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28 16:34:30 +00:00
normal
524e660877 io.c: fix IO.copy_stream on O_APPEND destination on Linux
Linux copy_file_range(2) fails with EBADF if the destination FD
has O_APPEND set.  Preserve existing (Ruby <= 2.4) behavior by
falling back to alternative copy mechanisms if this is the case
(instead of raising Errno::EBADF).

* io.c (nogvl_copy_file_range): do not raise on O_APPEND dst
* test/ruby/test_io.rb (test_copy_stream_append): new test
  [Feature #13867]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 18:37:23 +00:00
nobu
6b818dd961 common conversion functions
* array.c (rb_to_array_type): make public to share common code
  internally.

* hash.c (rb_to_hash_type): make public to share common code
  internally.

* symbol.c (rb_to_symbol_type): make public to share common code
  internally.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26 07:23:23 +00:00
nobu
1b27af8d56 io.c: let rb_p use writev
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25 12:33:42 +00:00
nobu
237901a41b io.c: warn old write
* io.c (rb_io_puts): warn if write method accepts just one
  argument.  [ruby-core:83529] [Feature #14042]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25 12:04:53 +00:00
nobu
635d0822cd io.c: write a newline together
* io.c (rb_io_puts): write a newline together at once for each
  argument.  based on the patch by rohitpaulk (Rohit Kuruvilla) at
  [ruby-core:83508].  [Feature #14042]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25 05:44:38 +00:00
kazu
9885c1c79f Update call-seq of ARGF.read_nonblock
ARGF.read_nonblock supports `exception: false' like IO#read_nonblock
since 2.3.0.
[Feature #11358]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 12:10:32 +00:00
hsbt
0e2d2e6a79 Drop to support NaCl platform.
Because NaCl and PNaCl are already sunset status.
  see https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160

  configure.ac: Patch for this file was provided by @nobu.

  [Feature #14041][ruby-core:83497][fix GH-1726]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23 05:56:25 +00:00
nobu
08524bc594 io.c: fix infinite retry
* io.c (io_binwritev): fix infinite retry when flushing buffered
  data.  [Feature #9323]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23 05:28:12 +00:00
nobu
71a7ef31d7 io.c: fix buffered output
* io.c (io_binwritev): append to buffered data, not overwriting.
  [Feature #9323]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23 05:09:35 +00:00
nobu
92023a8f60 io.c: fix total
* io.c (io_writev): total may be a bignum.  [Feature #9323]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23 05:09:34 +00:00
nobu
c0f40369b6 io.c: no restriction
* io.c (io_write_m): remove argc restriction upto IOV_MAX-1.
  [Feature #9323]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-23 02:25:58 +00:00
kazu
d9cfbb3cad Fix indent and comment [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 06:30:47 +00:00
nobu
6e3ff2ecd9 io.c: fix local variables
* io.c (io_writev): fix local variable declarations, when
  writev(2) is not available.  [Feature #9323]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 06:22:50 +00:00
glass
3efa7126e5 Make IO#write accept multiple arguments
io.c: make IO#write accept multiple arguments.
it uses writev(2) if possible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 02:11:07 +00:00
hsbt
2c27e52f8e Add documentation for chomp option.
https://github.com/ruby/ruby/pull/1717

  Patch by @ksss [fix GH-1717]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 16:11:58 +00:00
hsbt
2476bf2bb1 Clarify the behavior of IO.write without offset in write mode.
https://github.com/ruby/ruby/pull/1571

  Patch by @takanabe [fix GH-1571]
  [Bug #11638][ruby-core:71277]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:16:54 +00:00
glass
0686d5f4eb io.c: introduce copy offload to IO.copy_stream
io.c (rb_io_s_copy_stream): add copy offload feature (by using
copy_file_range(2) if available) to IO.copy_stream

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 14:25:46 +00:00
akr
ae2578f6bc [DOC] describe methods used for src and dst argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 06:45:41 +00:00
nobu
20685cdc85 Get rid of shadowing local variables
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-18 04:35:25 +00:00
nobu
5e52f06529 io.c: encoding of ARGF.inplace_mode
* io.c (argf_next_argv): encode inplace mode suffix to the path
  encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-10 12:30:42 +00:00
nobu
4ed65f1242 io.c: path name conversion at ARGF
* io.c (argf_next_argv): the standard conversion to path name
  should take place.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-10 10:42:52 +00:00
nobu
09e60b5af5 io.c: [DOC] about buffering [ci skip]
* io.c (rb_file_initialize): [DOC] stated that non-tty file is
  buffered by the default, and added links to related methods.
  [ruby-core:83081] [Bug #13965]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-05 02:35:58 +00:00
nobu
8148b7013c io.c: check null char
* io.c (ruby_set_inplace_mode): check if null is contained.  based
  on the patch by tommy (Masahiro Tomita) in [ruby-dev:50272].
  [Bug #13960]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-02 06:46:42 +00:00
shirosaki
fd50c2ee44 io.c: fix segfault with closing socket on Windows
* io.c (fptr_finalize_flush): add an argument to keep GVL.
* io.c (fptr_finalize): adjust for above change.
* io.c (io_close_fptr): closing without GVL causes another
  exception while raising exception in another thread. This causes
  segfault on Windows. Keep GVL while closing when another thread
  raises.
  [Bug #13856] [ruby-core:82602]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-28 13:43:21 +00:00
sorah
75cda5e22f File#path: Raise IOError when a file is O_TMPFILE
File#path for a file opened with O_TMPFILE has no meaning.

A filepath returned by this method isn't guarranteed about its accuracy,
but files opened with O_TMPFILE are known its recorded path has no
meaning. So let them not to return any pathname.

After a discussion in ruby-core, just returning Qnil makes guessing the
root cause difficult. Instead, this patch makes the method to raise an
error.

Other consideration is calling fnctl(2) on rb_file_path, but it adds a
overhead, and it's difficult to determine O_TMPFILE status  after fd has
been closed.

[Feature #13568]

* io.c(rb_file_open_generic): Set Qnil to fptr->pathv when opening a
  file using O_TMPFILE

* file.c(rb_file_path): Raise IOError when fptr->pathv is Qnil

* file.c(rb_file_path): [DOC] Update for the new behavior

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-31 11:14:36 +00:00