[#85349] [Ruby trunk Bug#14334] Segmentation fault after running rspec (ruby/2.5.0/erb.rb:885 / simplecov/source_file.rb:85) — pragtob@...
Issue #14334 has been updated by PragTob (Tobias Pfeiffer).
3 messages
2018/02/02
[#85358] Re: [ruby-cvs:69220] nobu:r62039 (trunk): compile.c: unnecessary freezing — Eric Wong <normalperson@...>
nobu@ruby-lang.org wrote:
5 messages
2018/02/03
[#85612] Why require autoconf 2.67+ — leam hall <leamhall@...>
Please pardon the intrusion; I am new to Ruby and like to pull the
6 messages
2018/02/17
[#85634] [Ruby trunk Bug#14494] [PATCH] tool/m4/ruby_replace_type.m4 use AC_CHECK_TYPES for HAVE_* macros — normalperson@...
Issue #14494 has been reported by normalperson (Eric Wong).
3 messages
2018/02/19
[#85674] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — matz@...
Issue #13618 has been updated by matz (Yukihiro Matsumoto).
5 messages
2018/02/20
[#85686] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2018/02/20
matz@ruby-lang.org wrote:
[#85704] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Koichi Sasada <ko1@...>
2018/02/21
On 2018/02/20 18:06, Eric Wong wrote:
[ruby-core:85607] [Ruby trunk Bug#14372] Memory leak in require with Pathnames in the $LOAD_PATH in 2.3/2.4
From:
nagachika00@...
Date:
2018-02-16 16:26:38 UTC
List:
ruby-core #85607
Issue #14372 has been updated by nagachika (Tomoyuki Chikanaga).
Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: REQUIRED, 2.4: DONE, 2.5: DONTNEED
ruby_2_4 r62440 merged revision(s) 59983,59984.
----------------------------------------
Bug #14372: Memory leak in require with Pathnames in the $LOAD_PATH in 2.3/2.4
https://bugs.ruby-lang.org/issues/14372#change-70403
* Author: jrafanie (Joe Rafaniello)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-darwin16]
* Backport: 2.3: REQUIRED, 2.4: DONE, 2.5: DONTNEED
----------------------------------------
There is a memory leak that we have found on ruby 2.3.6 and 2.4.3 that happens on Mac OSX and Linux. Ruby 2.2.6 and 2.5.0 do not leak. We have not tested other platforms.
If `$LOAD_PATH` contains one or more Pathname objects, `require` without a fully qualified path, such as `require 'ostruct'`, will leak if you do this require many times.
For example, the following script will leak very quickly on ruby 2.3.6 and 2.4.3:
~~~ruby
require 'pathname'
puts Process.pid
$LOAD_PATH.unshift(Pathname.new(__dir__))
dot = "."
filename = "ostruct"
1000.times { 1000.times { require filename }; print dot; GC.start; }
~~~
From what we can understand, it appears that `rb_require_internal` calls `rb_feature_p` which ultimately calls `rb_file_expand_path_fast` and resizes a string. It doesn't seem like the memory is ever freed either in c or the garbage collector. This happens many times, perhaps because Pathname objects, unlike Strings, aren't cached in loaded features so they get expanded each time. See below:
https://github.com/ruby/ruby/blob/v2_3_6/load.c#L43-L47
We can workaround this problem by converting Pathname objects in `$LOAD_PATH` to Strings, but this leak should be fixed since this it's common to use Pathname objects in `$LOAD_PATH`.
We used the instruments tool on OSX to show one such leak and the callstack, see attached image.
---Files--------------------------------
Instruments2 2018-01-18 11-43-32.png (181 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>