[#71931] [Ruby trunk - Feature #11786] [Open] [PATCH] micro-optimize case dispatch even harder — normalperson@...

Issue #11786 has been reported by Eric Wong.

9 messages 2015/12/08

[#72045] Ruby 2.3.0-preview2 Released — "NARUSE, Yui" <naruse@...>

We are pleased to announce the release of Ruby 2.3.0-preview2.

10 messages 2015/12/11
[#72336] Ruby 2.3.0-preview2 Released — Joseph Jones <joeyi5216@...> 2015/12/18

Joseph Jones liked your message with Boxer. On December 10, 2015 at 18:40:14 MST, NARUSE, Yui <naruse@airemix.jp> wrote:We are pleased to announce the release of Ruby 2.3.0-preview2.Ruby 2.3.0-preview2 is the second preview of Ruby 2.3.0.Many new features and improvements are included.A [Frozen String Literal Pragma](https://bugs.ruby-lang.org/issues/11473)is introduced.With Ruby 2.1, `"str".freeze` has been optimized to reduce object allocation.Ruby 2.3 introduces a new magic comment and command line option tofreeze all string literals in the source files.Additionally for debugging, you can get where the object is created on`"can't modify frozen String"` error by`--debug=frozen-string-literal` command line option.A [safe navigation operator](https://bugs.ruby-lang.org/issues/11537)([so-called lonely operator](https://instagram.com/p/-M9l6mRPLR/)) `&.`,which already exists in C#, Groovy, and Swift, is introduced to ease`nil` handling as `obj&.foo`. `Array#dig` and `Hash#dig` are also added.The [did_you_mean gem is bundled](https://bugs.ruby-lang.org/issues/11252).The did_you_mean gemshows the candidates on the `NameError` and `NoMethodError` to easedebugging.[RubyVM::InstructionSequence#to_binary and .load_from_binary](https://bugs.ruby-lang.org/issues/11788) are introduced asexperimental feature. With these features, we can make a ISeq(bytecode) pre-compilation system.Ruby 2.3 includes many performance tuning fixes.For example, [optimize Proc#call] (https://bugs.ruby-lang.org/issues/11569),[reconsider method entry data structure](https://bugs.ruby-lang.org/issues/11278),[introducing new table data structure](https://bugs.ruby-lang.org/issues/11420),machine code level tuning for object allocation and method calling code,and other many optimizations.Try and enjoy programming with Ruby 2.3.0-preview2, and report us yourknowledge!## Notable Changes since 2.2See [NEWS](https://github.com/ruby/ruby/blob/v2_3_0_preview2/NEWS) and[ChangeLog](https://github.com/ruby/ruby/blob/v2_3_0_preview2/ChangeLog)for detail.With those changes, [1097 files changed, 97466 insertions(+), 58685deletions(-)](https://github.com/ruby/ruby/compare/v2_2_0...v2_3_0_preview2)since Ruby 2.2.0!## Download* * SIZE: 14126752 bytes * SHA1: 7e717ef7a0a1523ad696b5fe693f7f7a613a3810 * SHA256: e9b0464e50b2e5c31546e6b8ca8cad71fe2d2146ccf88b7419bbe9626af741cb * SHA512: e397f321d4338edba8d005d871408775f03d975da90c8abcfdb457a1bc7e6c87efe58c53b2c3bc122e9f58f619767b271bcc8d5d9663ed4b4288c60556e8d288* * SIZE: 17623519 bytes * SHA1: 2deaf3ccbbfc5e08d3d840a4f1c33ff5f62f931d * SHA256: cb1c745bda33ba9e812b48c87852571ef6486f985c5e6ff4508a137d1c9734a3 * SHA512: 83022f99775eb139beec281d59029dcc7c59de1e313182685b0a785334ac53d0c445212460d00d065169b922949263f30a1f981e19fc6e59814e79e6e53ae8e0* * SIZE: 11249780 bytes * SHA1: e1dfca06cd3c2cf6456a7feb0b1cd0752bde1a3b * SHA256: 7c3119268af87c137f415301b299281762453ad78f86e35562be014dabd67b11 * SHA512: ab3376145d95a2188e6345984f0e5592c8d33515d7046a2ab2565dc418fa2306cdcf797aae9494d4d10446ada54ba638d8a8ad2d4b7510544d7eaea3de4faa87* * SIZE: 19841531 bytes * SHA1: db7fa5291d90e0a9c6f75c0cd068bc54050520d6 * SHA256: 90d036fd1ec40aa8f5493821ac162bf69f505c5977db54afe53b8bf689d79b9d * SHA512: 05784df420018aaae7d09d41e872df708e861cacc74dc8ee97a9e3ac7458cb12b937523ad6def34d5ae2890a0cf037a8d61e365beb88d28acd84879b9391ad65## Release CommentSee also the release schedule and other information:[ReleaseEngineering23](https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/ReleaseEngineering23)-- NARUSE, Yui

[#72237] [Ruby trunk - Bug #11733] Compile of ruby 2.2.3 fails on AIX 6.1 TL07 SP03 — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 7, 2015 at 00:55:22 MST, naruse@airemix.jp wrote:Issue #11733 has been updated by Yui NARUSE.Assignee set to cruby-aix----------------------------------------Bug #11733: Compile of ruby 2.2.3 fails on AIX 6.1 TL07 SP03https://bugs.ruby-lang.org/issues/11733#change-55299* Author: Perry Smith* Status: Open* Priority: Normal* Assignee: cruby-aix* ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------The build on AIX fails in the ext/-test-/file directory with errors such ascompiling /usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c: In function 'get_fsname':/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c:39:14: error: storage size of 'st' isn't known/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c:44:5: warning: implicit declaration of function 'statvfs'/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c:39:14: warning: unused variable 'st'make: *** [fs.o] Error 1This can be avoided if line 65 is modified but then we encounter a second error:compiling /usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c: In function 'get_fsname':/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c:45:5: warning: implicit declaration of function 'statvfs'/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c:49:11: error: 'struct statfs' has no member named 'f_basetype'/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c:50:9: error: 'struct statfs' has no member named 'f_basetype'/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c:50:9: error: 'struct statfs' has no member named 'f_basetype'/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c:50:9: error: 'struct statfs' has no member named 'f_basetype'/usr/work/src/ruby-2.2.3/ext/-test-/file/fs.c:50:9: error: 'struct statfs' has no member named 'f_basetype'In the extconf.rb, they test for struct statfs -- which AIX has but the code declares variables of statfs_t which AIX does not have.The AIX statfs is defined in /usr/include/sys/statfs.h (which is included by vfs.h). It has an f_type field but not an f_basetype field.To get around the issue, I kludged extconf.rb to fail to find the structures it was looking for and then it built but this is clearly not a real solution.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72242] [Ruby trunk - Bug #11791] [Open] The literal quotes should accept more quote characters (aka more unicode characters) — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 8, 2015 at 14:55:58 MST, eike@inter.net wrote:Issue #11791 has been reported by Eike Dierks.----------------------------------------Bug #11791: The literal quotes should accept more quote characters (aka more unicode characters)https://bugs.ruby-lang.org/issues/11791* Author: Eike Dierks* Status: Open* Priority: Normal* Assignee: * ruby -v: ruby 2.2.4p180 (2015-10-06 revision 50899) [x86_64-darwin15]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------I frequently use literal quoting, aka %q[], %w[], %i[]I'd like to suggest that the set of quoting characters should be extended.I believe that some pairs of unicode character should also be allowed as paired quoting characters.Actually some characters from the unicode math symbol plane come in pairs and would be candidates.I found some initial reference here: http://xahlee.info/comp/unicode_matching_brackets.htmlThis obviously would extend the syntax parsing rules beyond ascii,but we are there already, and it would not break existing ascii codes.I believe this could be useful in two scenarios:- it would add expressiveness to math codes- it would remove ambiguities for ascii literalsI'm more interested in the later.So for example when embedding javascript code as a literal,it would be helpful to bracket that code with a unicode bracket,because that bracket would not occur within the literal.Another option would be (I should try this)to enclose in:%q>>but I believe this will break existing code.---Sorry for reporting on the literals again,please look up my previous feature requests on this topic.I'm not even sure if we should go beyond ascii.But ruby is fully unicode already (another first)I believe this could really add to how ruby code looks.Imagine some Math code using unicode math symbols.I believe that the set of characters that we might use to write our codeshould no longer bound by a standard set by the americans in the early 70's,and even then based one the least common denominator from the 6bit age.But now days there are so many more chars,so we need to clearly define which ones are allowed,in this case: which ones we newly accept as bracketing chars.I previously asked about chars from the unicode operators plane.I'd like to suggest that this should be a twofold process:- mark ranges of unicode as reserved for further use (aka exclude them from use as identifiers)- include chars explicitely as to be use as operators or bracketing chars-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72247] [Ruby trunk - Feature #11737] Pass in expression to then block in `case expression` — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 2, 2015 at 21:07:58 MST, s.wanabe@gmail.com wrote:Issue #11737 has been updated by _ wanabe.Nobuyoshi Nakada wrote:> It reminded me a rejected proposal:> > ~~~ruby> case expr> when matcher => result> ...> end> ~~~Is the proposal [ruby-dev:17615]?Or other?----------------------------------------Feature #11737: Pass in expression to then block in `case expression`https://bugs.ruby-lang.org/issues/11737#change-55214* Author: Daniel P. Clark* Status: Open* Priority: Normal* Assignee: ----------------------------------------Ruby's `case ` scenario allows the expression to be tested in the `when` test with `:===`, but in the then block the expression is not accessible. Only if the expression has been assigned to a variable beforehand can it be checked.~~~rubycase 4when ->i{ puts :when; true} ->i{ puts i}else :fooend# when# => # case 4when ->i{ puts :when; true} puts _else :fooend# when# ## => nil case 4when 4then _end# => nilcase 4when 4then ->i{puts i}end# => # ~~~If some one wanted to give an expression after case that wasn't assigned to a variable then there is no access to it in the then block.I suggest assigning the expression to the `_` variable during a case/when/then scenario. Here's a rather contrived example use case.~~~rubycase Enumerator.new do |y| y when ->e{ 2.times e.next; true}then _.peekend == 3~~~-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72248] [Ruby trunk - Feature #11735] Porting String#squish and String#squish! from Ruby on Rails' Active Support — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 7, 2015 at 00:50:42 MST, ko1@atdot.net wrote:Issue #11735 has been updated by Koichi Sasada.Assignee set to Yukihiro Matsumoto----------------------------------------Feature #11735: Porting String#squish and String#squish! from Ruby on Rails' Active Supporthttps://bugs.ruby-lang.org/issues/11735#change-55296* Author: Prem Sichanugrist* Status: Open* Priority: Normal* Assignee: Yukihiro Matsumoto----------------------------------------Hi,I have been using this `String#squish` method so many time when I'm using Rails, and I think it should be a useful addition to core.Here's the method on Rails' documentation: http://api.rubyonrails.org/v4.2.5/classes/String.html#method-i-squishThis method is very useful when you have to write a multi-line string using heredoc, but you actually does not care about the white-spaces before, after, and in-between the string.For example:~~~ruby SELECT * FROM users WHERE users.username = 'sikachu'SQL#=> "SELECT * FROM users WHERE users.username='sikachu'"~~~Another example usage is when you are on the project that have a line length code standard, and you have to write a long warning message that needs to be printed to stdout:~~~rubyputs Unable to connect to the server. Please double-check that you are currently connecting to the internet and your proxy server is working.WARNING#=> Unable to connect to the server. Please double-check that you are currently connecting to the internet and your proxy server is working.~~~By the way, this is my first patch and my first time writing something in C, so there might be something that does not look right to you. I'll happy to revise this patch (and learn about C in the process!) from your feedback.Thank you,Prem---Files--------------------------------0001-Introduce-String-squish-and-String-squish.patch (4.67 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72249] [Ruby trunk - Feature #9098] Indent heredoc against the left margin by default when \"indented closing identifier\" is turned on. — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On November 30, 2015 at 23:20:35 MST, nobu@ruby-lang.org wrote:Issue #9098 has been updated by Nobuyoshi Nakada."8 spaces for tab stops" is not enough to make the spec.When tabs and spaces are mixed, e.g., there are`"\t"*2+"2 tabs"` line and `" "*10+"10 spaces"` line, what should be expected?1. dedent at the greatest indent column where all lines have a white space. a tab which includes the column will remain, but spaces between previous tab stop and the column will be removed. this is the implementation by @bjmllr, and results `"\t"+"2 tabs"` line and `" "*2+"10 spaces"` line.2. dedent at the greatest indent column exclusively tabs a tab which includes the column will remain, and also spaces before the column will be removed. this is like `kill-rectangle` of Emacs, and I've thought this, and results `"\t"+"2 tabs"` line and `"10 spaces"` line.3. expand tabs first tabs are expanded first before dedent, and results `" "*6+"2 tabs"` line and `"10 spaces"` line.4. or, like Andrew M claims, dedent of byte-wise common parts can be an option, I think now.----------------------------------------Feature #9098: Indent heredoc against the left margin by default when "indented closing identifier" is turned on.https://bugs.ruby-lang.org/issues/9098#change-55183* Author: Prem Sichanugrist* Status: Assigned* Priority: Normal* Assignee: Yukihiro Matsumoto----------------------------------------tl;dr: I would like to port +String#strip_heredoc+ (http://api.rubyonrails.org/classes/String.html#method-i-strip_heredoc) from Rails and enable it on `Hi,I've been using here document (heredoc) for a while, and I've found out that it's very annoying that the content is always treated as flushed left. Per syntax doc: Note that the while the closing identifier may be indented, the content is always treated as if it is flush left. If you indent the content those spaces will appear in the output.So, this is the current result if you use heredoc in Ruby: class FancyHello def self.hello puts Hello World! README end end FancyHello.hello # => " Hello\n World!\n"In Rails, the core team has implemented +String#strip_heredoc+, which handles this scenario by remove leading white spaces from the string. However, not many user know that Rails has that method, and instead doing this to get around it: class FancyHello def self.hello puts Hello World! README end end FancyHello.hello # => "Hello\n World!\n"I really think that we could do better on this by removing the leading white spaces, matching +String#strip_heredoc+ method.So, after the change, I want to be able to do this, and get this result: class FancyHello def self.hello puts Hello World! README end end FancyHello.hello # => "Hello\n World!\n"Note: the behavior on `I'll write up a patch and submit it if you think this is a good idea. Please let me know any question or concern you may have.Thank you,Prem---Files--------------------------------dedent_heredoc.patch (12.8 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72251] [Ruby trunk - Feature #11769] [Open] optimize case / when for `nil` — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 3, 2015 at 14:43:24 MST, tenderlove@ruby-lang.org wrote:Issue #11769 has been reported by Aaron Patterson.----------------------------------------Feature #11769: optimize case / when for `nil`https://bugs.ruby-lang.org/issues/11769* Author: Aaron Patterson* Status: Open* Priority: Normal* Assignee: ----------------------------------------Hi,I've noticed that when there are certain values in a case / when statement it gets optimized to a hash lookup. For example, code like this:~~~def foo socket case str = socket.read_nonblock(10, exception: false) when :wait_readable # do something else str endendputs RubyVM::InstructionSequence.of(method(:foo)).disasm~~~The above code will use `opt_case_dispatch` instruction with a hash. However, if I use `nil` in the case statement like this:~~~def foo socket case str = socket.read_nonblock(10, exception: false) when :wait_readable # do something when nil # got an EOF else str endendputs RubyVM::InstructionSequence.of(method(:foo)).disasm~~~Then the optimization is lost.I've attached a patch that adds `nil` to the optimized case such that the above code will use `opt_case_dispatch`. My patch defines `===` on `nil`, then adds nil to the list of "optimizable literals".---Files--------------------------------0001-optimize-case-when-for-nil.patch (3.4 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72252] [Ruby trunk - Bug #8543] new rb_iseq_load crash — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 7, 2015 at 20:11:11 MST, usa@garbagecollect.jp wrote:Issue #8543 has been updated by Usaku NAKAMURA.Backport changed from 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: DONE to 2.0.0: UNKNOWN, 2.1: DONTNEED, 2.2: DONE2.0/2.1 use different code about r51816.So they don't have this problem, I think.----------------------------------------Bug #8543: new rb_iseq_load crashhttps://bugs.ruby-lang.org/issues/8543#change-55336* Author: Alexey Voskov* Status: Closed* Priority: Normal* Assignee: Koichi Sasada* ruby -v: -* Backport: 2.0.0: UNKNOWN, 2.1: DONTNEED, 2.2: DONE----------------------------------------I noticed an unusual behaviour of undocumented rb_iseq_load function. Its work differs in different Ruby versions. I'm trying to protect some Rubysource code by its conversion to YARV p-code and using the next strategy:1. Convert code to array ~~~ruby data = RubyVM::InstructionSequence.compile_file('hello.rb').to_a ~~~2. Pass a compiled source to the rb_iseq_load function and evaluate it ~~~ruby iseq = iseq_load.(data) iseq.eval ~~~Sample programs are supplied in the attachments."hello.rb"```rubyputs "tralivali"def funct(a,b) a**bend3.times { |i| puts "Hello, world#{funct(2,i)}!"}```The differencesRuby 1.9.3 (ruby 1.9.3p194 (2012-04-20) [i386-mingw32])Correct work. Output:```tralivaliHello, world1!Hello, world2!Hello, world4!```Ruby 2.0.0 (ruby 2.0.0p193 (2013-05-14) [x64-mingw32])Incorrect work (omits the code inside code blocks). Output```tralivali```Attempts of loading bigger programs by means of rb_iseq_load in Ruby 2.0.0 usually ends with a segmentation fault.Such behaviour also can be reproduced by means of iseq Ruby extension ("for iseq freaks")https://github.com/wanabe/iseqP.S. I understand that it is an undocumented feature.---Files--------------------------------hello.rb (102 Bytes)rb_pack.rb (931 Bytes)iseq-load-test3.rb (210 Bytes)iseq-load-test3-file.rb (369 Bytes)please-fix-rb_iseq_load-thank-you.pdf (444 KB)iseq-load-test5.rb (4.7 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72254] [Ruby trunk - Bug #11774] [Open] OpenSSL::PKey.read produces ArgumentError on invalid passphrases — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 5, 2015 at 09:54:34 MST, code@temik.me wrote:Issue #11774 has been reported by Artem Yakimenko.----------------------------------------Bug #11774: OpenSSL::PKey.read produces ArgumentError on invalid passphraseshttps://bugs.ruby-lang.org/issues/11774* Author: Artem Yakimenko* Status: Open* Priority: Normal* Assignee: * ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------If we try to read out an RSA encrypted key with an invalid passphrase like so:```require 'openssl'OpenSSL::PKey.read(File.read("#{ENV['HOME']}/.ssh/id_rsa"), 'invalid')```We get an argument error:```ArgumentError: Could not parse PKey: no start linefrom (pry):6:in `read'```However, if I understand the situation correctly, it should produce a decode error: `OpenSSL::PKey::RSAError`, as per the doc:```OpenSSL::PKey::RSAErrorGeneric exception that is raised if an operation on an RSA PKey fails unexpectedly or in case an instantiation of an instance of RSA fails due to non-conformant input data.```Reproduction:1) Create a password protected ssh key (if none exists):ssh-keygen -t rsa -b 40962) Run the following snippet (assuming ~/.ssh/id_rsa is the key location)```require 'openssl'OpenSSL::PKey.read(File.read("#{ENV['HOME']}/.ssh/id_rsa"), 'invalid_passphrase')```Tested on:MacOSX 10.11.1OpenSSL 1.0.2d 9 Jul 2015Ruby 2.1.7Ruby 2.2.3-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72255] [Ruby trunk - Feature #11588] Implement structured warnings — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 5, 2015 at 21:21:50 MST, djberg96@gmail.com wrote:Issue #11588 has been updated by Daniel Berger.Matz, warnings may not affect control flow, but I've seen enough real world application logs filled with warnings we couldn't control to dispute your assertion that they don't need to be handled by machines. And right now they can't really be handled by machines or humans very well.Something like Activesupport::Deprecation would be good, though I don't know how much different that is than what I'm proposing.----------------------------------------Feature #11588: Implement structured warningshttps://bugs.ruby-lang.org/issues/11588#change-55255* Author: Daniel Berger* Status: Open* Priority: Normal* Assignee: ----------------------------------------Ruby’s current warning system is lacking. Warnings are controlled by the -W flag on the command line, and are generated via the Kernel#warn method within code. There are a host of problems with this approach to warnings.First, warnings aren’t currently testable. With Test::Unit, for example, I can ensure that specific errors are raised in certain conditions via the assert_raise method. There is no analogue for warnings. It would be nice if there were so I could test them.Second, there is no backtrace information provided with warnings. If I discover a warning I have to wade through the source and figure out where it was generated, because a Kernel#warn call does not provide a line number or method name that I can refer back to, unless it happened to be generated by rb_warn(). For large code bases that can be problematic.Third, and most significantly, with warning flags it’s all or nothing. I cannot enable or disable specific kinds of warnings. Perl, for example, implements warning control through pragmas. So, for example, I can specify “no warnings uninitialized” in a Perl program and warnings about uninitialized variables go away. With Ruby it’s off, on, or even-more-on (-W0, -W1 or -W2).What I would like to see are structured warnings. By "structured warnings" I mean a system analogous to the Error class, except that a warning would only emit text to STDERR, not cause the interpreter to exit. In our hypothetical Warning class you still have backtrace information available. And, like Exceptions, there would be a standard hierarchy, with Warning at the top, StandardWarning, UninitializedWarning, RedefinedMethodWarning, DeprecatedMethodWarning, etc. Whatever we can think of.Such a system would allow you to raise specific warnings within your code:~~~ class Foo def old_method warn DeprecatedMethodWarning, 'This method is deprecated. Use new_method instead' # Do stuff end end~~~The ability to explicitly raise specific types of warnings then makes them testable:~~~ require 'test/unit' class TC_Foo_Tests def setup @foo = Foo.new end # Assume we've added an assert_warn method to Test::Unit def test_old_method assert_warn(DeprecatedMethodWarning){ @foo.old_method } end end~~~And, for sake of backwards compatibility and convenience, a call to Kernel#warn without an explicit warning type would simply raise a StandardWarning in the same way that "raise" without an explicit error type raises a StandardError. You may be wondering about rescue/retry semantics. My opinion on the matter is that warnings should not be rescuable. They are meant to be informational. They are not meant to control program flow. This also lets us avoid having to worry about retry semantics. Not that anyone would retry based on a warning in practice.Unlike Exceptions you could permanately or temporarily disable warnings to suit your particular preferences in the system I have in mind. For example, in the win32-file library I'm well aware that I've gone and redefined some core File methods. When I run any code that uses win32-file with the -w flag, I get "method redefined" warnings. I don't want to see those because I neither need nor want to be reminded about them. So, using our hypothetical RedefinedMethodWarning class, I could disable them like so:~~~ RedefinedMethodWarning.disable # No more warnings about method redefinitions!~~~Or, with block syntax, we could disable a particular warning temporarily:~~~ # Don't bug me about deprecated method warnings within this block, I know what I'm doing. DeprecatedMethodWarning.disable{ [1,2,3,4,5].indexes(1,3) # Array#indexes is a deprecated method }~~~~~~ # But here I would get a warning since it's outside the block: [1,2,3,4,5].indexes(1,3)~~~Unlike the current warning system, this would allow users to still receive other types of warnings, instead of the on/off switch we have now. And, in case you were wondering why the structured_warnings library isn't quite sufficient, the answer is that it still can’t hook into the existing warnings being raised in core Ruby via rb_warn(), like uninitialized variables or redefined methods.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72260] [Ruby trunk - Bug #11778] [Open] recv_io with mode breaks when klass arg is kind of BasicSocket — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 6, 2015 at 07:27:50 MST, normalperson@yhbt.net wrote:Issue #11778 has been reported by Eric Wong.----------------------------------------Bug #11778: recv_io with mode breaks when klass arg is kind of BasicSockethttps://bugs.ruby-lang.org/issues/11778* Author: Eric Wong* Status: Open* Priority: Normal* Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------Following test show the failure in the second recv_io call.I was writing additional tests for FD passing when I noticed this.I'm not sure if BasicSocket.for_fd should do with the mode flag ifwe change its arity...~~~--- a/test/socket/test_unix.rb+++ b/test/socket/test_unix.rb@@ -37,6 +37,28 @@ def test_fd_passing end end + def test_fd_passing_class_mode+ UNIXSocket.pair do |s1, s2|+ s1.send_io(s1.fileno)+ r = s2.recv_io(nil)+ assert_kind_of Integer, r, 'recv_io with klass=nil returns integer FD'+ assert_not_equal s1.fileno, r+ r = IO.for_fd(r)+ assert_equal s1.stat.ino, r.stat.ino+ r.close++ s1.send_io(s1)+ klass = UNIXSocket+ # OK with File or IO, fails with any BasicSocket subclass since+ # BasicSocket.for_fd only takes one arg+ # klass = File+ r = s2.recv_io(klass, 'r+')+ assert_instance_of klass, r, 'recv_io with proper klass'+ assert_not_equal s1.fileno, r.fileno+ r.close+ end+ end+ def test_fd_passing_n io_ary = [] return if !defined?(Socket::SCM_RIGHTS)~~~-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72261] Re: [ruby-cvs:60055] nobu:r52902 (trunk): console.c: console_getpass — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 6, 2015 at 18:23:36 MST, Eric Wong <normalperson@yhbt.net> wrote:Hi nobu, I get this failure on Debian 7.0 (wheezy) on32-bit x86 (64-bit kernel), x86-64 and Debian 8.0 (jessie) x86-64: 1) Failure:TestIO_Console#test_getpass [/home/ew/ruby/test/io/console/test_io_console.rb:190]: expected but was asdf">.r52910 did not fix this.I'm not too familiar with tty-related code and haven't figure outwhat's going on.Here's the relevant strace from that test, and below is the mkmf.log:13856 clock_gettime(CLOCK_REALTIME, {1449450431, 418795141}) = 013856 waitpid(-1, 0xfff95360, 0) = -1 ECHILD (No child processes)13856 write(1, ".", 1) = 113856 stat64("/proc/self/fd", {st_mode=S_IFDIR|0500, st_size=0, ...}) = 013856 open("/proc/self/fd", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 713856 lseek(7, 0, SEEK_SET) = 013856 getdents64(7, /* 10 entries */, 32768) = 24013856 getdents64(7, /* 0 entries */, 32768) = 013856 close(7) = 013856 clock_gettime(CLOCK_REALTIME, {1449450431, 419229169}) = 013856 open("/dev/ptmx", O_RDWR|O_NOCTTY|O_CLOEXEC) = 713856 fcntl64(7, F_GETFD) = 0x1 (flags FD_CLOEXEC)13856 rt_sigaction(SIGCHLD, {SIG_DFL, [], 0}, {SIG_DFL, [], 0}, 8) = 013856 ioctl(7, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 013856 ioctl(7, TIOCGPTN, [7]) = 013856 stat64("/dev/pts/7", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 7), ...}) = 013856 getuid32() = 100013856 rt_sigaction(SIGCHLD, {SIG_DFL, [], 0}, NULL, 8) = 013856 ioctl(7, TIOCSPTLCK, [0]) = 013856 ioctl(7, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 013856 ioctl(7, TIOCGPTN, [7]) = 013856 stat64("/dev/pts/7", {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 7), ...}) = 013856 chmod("/dev/pts/7", 0600) = 013856 open("/dev/pts/7", O_RDWR|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 813856 mmap2(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x55a2c00013856 mmap2(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x55aad00013856 mprotect(0x55aad000, 4096, PROT_NONE) = 013856 clone(child_stack=0x55b2d494, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x55b2dbd8, {entry_number:12, base_addr:0x55b2db70, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}, child_tidptr=0x55b2dbd8) = 1385913859 set_robust_list(0x55b2dbe0, 0xc 13856 write(7, "> ", 2 13859 ) = 013859 sched_getaffinity(13859, 32, 13856 ) = 213859 {3, 0}) = 813856 ioctl(7, SNDCTL_TMR_TIMEBASE or TCGETS 13859 sigaltstack({ss_sp=0x5849f778, ss_flags=0, ss_size=16384} 13856 , {B38400 opost isig icanon echo ...}) = 013859 , {ss_sp=0, ss_flags=SS_DISABLE, ss_size=0}) = 013859 write(6, "!", 1 13856 ioctl(7, SNDCTL_TMR_TIMEBASE or TCGETS 13859 ) = 113858 ) = 1 ([{fd=5, revents=POLLIN}])13859 futex(0x581b7848, FUTEX_WAIT_PRIVATE, 1, NULL 13858 read(3, 0x56848020, 1024) = -1 EAGAIN (Resource temporarily unavailable)13856 , {B38400 opost isig icanon echo ...}) = 013858 read(5, 13856 ioctl(7, SNDCTL_TMR_CONTINUE or TCSETSF, {B38400 opost isig icanon -echo ...}) = 013856 ioctl(7, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon -echo ...}) = 013858 "!", 1024) = 113856 futex(0x581b7848, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x581b7844, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1} 13858 read(5, 13856 ) = 113858 0x56848020, 1024) = -1 EAGAIN (Resource temporarily unavailable)13856 read(7, 13858 poll([{fd=3, events=POLLIN}], 1, 100 13856 "> ", 8192) = 213859 ) = 013856 futex(0x581b787c, FUTEX_WAIT_PRIVATE, 1, NULL 13859 futex(0x581b787c, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x581b7878, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 013856 ) = -1 EAGAIN (Resource temporarily unavailable)13859 futex(0x581b7828, FUTEX_WAKE_PRIVATE, 1 13856 write(6, "!", 1 13859 ) = 013856 ) = 113859 prctl(PR_SET_NAME, 0x55b2d2fc, 0, 0xfffffffe, 0x581b7ec8 13856 futex(0x581b7828, FUTEX_WAKE_PRIVATE, 1 13859 ) = 013856 ) = 013856 futex(0x581b7848, FUTEX_WAIT_PRIVATE, 3, NULL 13859 time(NULL) = 144945043113859 clock_gettime(CLOCK_MONOTONIC, {4118337, 10691901}) = 013859 clock_gettime(CLOCK_MONOTONIC, {4118337, 10712250}) = 013859 futex(0x581b7848, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x581b7844, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 113856 ) = 013859 clock_gettime(CLOCK_MONOTONIC, 13856 futex(0x581b7828, FUTEX_WAKE_PRIVATE, 1 13859 {4118337, 10782767}) = 013856 ) = 013859 futex(0x5842b214, FUTEX_WAIT_PRIVATE, 1, {0, 99929483} 13856 read(7, 13858 ) = 0 (Timeout)13858 poll([{fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 2, -1) = 1 ([{fd=5, revents=POLLIN}])13858 read(3, 0x56848020, 1024) = -1 EAGAIN (Resource temporarily unavailable)13858 read(5, "!", 1024) = 113858 read(5, 0x56848020, 1024) = -1 EAGAIN (Resource temporarily unavailable)13858 poll([{fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 2, -1 13859 ) = -1 ETIMEDOUT (Connection timed out)13859 futex(0x5842b268, FUTEX_WAKE_PRIVATE, 1) = 013859 clock_gettime(CLOCK_MONOTONIC, {4118337, 110885257}) = 013859 time(NULL) = 144945043113859 write(8, "asdf\n", 5) = 513859 madvise(0x55aad000, 507904, MADV_DONTNEED 13856 "asdf\r\n", 8192) = 613859 ) = 013859 _exit(0) = ?13856 ioctl(7, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon -echo ...}) = 013856 ioctl(7, SNDCTL_TMR_CONTINUE or TCSETSF, {B38400 opost isig icanon echo ...}) = 013856 ioctl(7, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 013856 write(7, "\n", 1) = 113856 close(7) = 013856 close(8) = 013856 clock_gettime(CLOCK_REALTIME, {1449450431, 522078062}) = 013856 waitpid(-1, 0xfff95360, 0) = -1 ECHILD (No child processes)13856 write(1, "F", 1) = 1mkmf.log:"gcc -o conftest -I../../../.ext/include/x86_64-linux -I../../.././include -I../../.././ext/io/console -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L../../.. -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R/home/ew/r/trunk/lib -L/home/ew/r/trunk/lib -lruby-static -lpthread -lrt -lgmp -ldl -lcrypt -lm -lc"checked program was:/* begin */1: #include "ruby.h"2: 3: int main(int argc, char **argv)4: {5: return 0;6: }/* end */"gcc -I../../../.ext/include/x86_64-linux -I../../.././include -I../../.././ext/io/console -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -c conftest.c"conftest.c:5:3: error: #error conftest.c:6:1: error: expected identifier or ‘(’ before ‘|’ tokenchecked program was:/* begin */1: #include "ruby.h"2: 3: /*top*/4: #ifndef _WIN325: # error6: |:/ === _WIN32 undefined === /:|7: #endif/* end */have_header: checking for termios.h... -------------------- yes"gcc -E -I../../../.ext/include/x86_64-linux -I../../.././include -I../../.././ext/io/console -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -o conftest.i"checked program was:/* begin */1: #include "ruby.h"2: 3: #include /* end */--------------------have_func: checking for cfmakeraw() in termios.h... -------------------- yes"gcc -o conftest -I../../../.ext/include/x86_64-linux -I../../.././include -I../../.././ext/io/console -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -L../../.. -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R/home/ew/r/trunk/lib -L/home/ew/r/trunk/lib -lruby-static -lpthread -lrt -lgmp -ldl -lcrypt -lm -lc"checked program was:/* begin */ 1: #include "ruby.h" 2: 3: #include 4: 5: /*top*/ 6: extern int t(void); 7: int main(int argc, char **argv) 8: { 9: if (argc > 1000000) {10: printf("%p", &t);11: }12: 13: return 0;14: }15: int t(void) { void ((*volatile p)()); p = (void ((*)()))cfmakeraw; return !p; }/* end */--------------------have_header: checking for sys/ioctl.h... -------------------- yes"gcc -E -I../../../.ext/include/x86_64-linux -I../../.././include -I../../.././ext/io/console -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -o conftest.i"checked program was:/* begin */1: #include "ruby.h"2: 3: #include /* end */--------------------extconf.h is:/* begin */1: #ifndef EXTCONF_H2: #define EXTCONF_H3: #define HAVE_TERMIOS_H 14: #define HAVE_CFMAKERAW 15: #define HAVE_SYS_IOCTL_H 16: #endif/* end */

1 message 2015/12/18

[#72269] [Ruby trunk - Feature #11747] \"bury\" feature, similar to 'dig' but opposite — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 2, 2015 at 16:36:12 MST, dameyawn@gmail.com wrote:Issue #11747 has been updated by damien sutevski.Tsuyoshi Sawada wrote:> > inferred from the what the user is passing (such as a symbol or string for a hash or an integer for an array)> > I don't think this is a good idea. I think it should rather depend on the class of the receiver.> > {}.bury(:users, 0, :name, 'Matz') # => {:users => {0 => {:name => "Matz"}}}> [].bury(:users, 0, :name, 'Matz') # => error> {}.bury(0, 1, 2, :foo) # => {0 => {1 => {2 => :foo}}}> [].bury(0, 1, 2, :foo) # => [[nil, [nil, nil, :foo]]]> > and similar for struct.I agree. I should clarify that I was assuming the class of the receiver (`data`) was known in my example. The inference I was talking about was that a buried `0` would imply an array position by default instead of a hash key.----------------------------------------Feature #11747: "bury" feature, similar to 'dig' but opposite https://bugs.ruby-lang.org/issues/11747#change-55211* Author: damien sutevski* Status: Feedback* Priority: Normal* Assignee: Yukihiro Matsumoto----------------------------------------In Matz's recent Rubyconf talk, he used this example for the new 'dig' feature coming in Ruby 2.3:~~~ruby# we want thisdata[:users][0][:name]# we can do this w/o nil errorsdata.dig(:users, 0, :name)~~~What I'm proposing is a 'bury' feature that is the opposite of 'dig' in a sense. It inserts a value at an arbitrary depth, for example:~~~rubydata.bury(:users, 0, :name, 'Matz')~~~This will create a nested hash or an array automatically at each step if it doesn't already exist, and that can be inferred from the what the user is passing (such as a symbol or string for a hash or an integer for an array). It's similar to autovivification but more powerful!This behavior is very common, at least in my experience, so a dry method built into Ruby would be awesome! -- https://bugs.ruby-lang.org/

2 messages 2015/12/18

[#72274] [Ruby trunk - Feature #11607] [PATCH] fiddle: release GVL for ffi_call — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 2, 2015 at 20:14:26 MST, ngotogenome@gmail.com wrote:Issue #11607 has been updated by Naohisa Goto.After r52723, SEGV occurred during Fiddle::TestFunc#test_qsort1 test/fiddle/test_func.rb:83 on Solaris 10 i386 on RubyCI.(r52725) http://rubyci.s3.amazonaws.com/unstable10x/ruby-trunk/log/20151123T224815Z.fail.html.gzBecause this occurred in the CI environment, no other detailed information was available.This is not reproduced on sparc Solaris.----------------------------------------Feature #11607: [PATCH] fiddle: release GVL for ffi_callhttps://bugs.ruby-lang.org/issues/11607#change-55213* Author: Eric Wong* Status: Closed* Priority: Normal* Assignee: Aaron Patterson----------------------------------------Some external functions I wish to call may take a long timeand unnecessarily block other threads. This may lead to performanceregressions for fast functions as releasing/acquiring the GVL is notcheap, but can improve performance for long-running functionsin multi-threaded applications.This also means we must reacquire the GVL when calling Ruby-definedcallbacks for Fiddle::Closure, meaning we must detect whether thecurrent thread has the GVL by exporting ruby_thread_has_gvl_pin internal.h---Files--------------------------------0001-fiddle-release-GVL-for-ffi_call.patch (11.3 KB)fiddle-release-GVL-for-ffi_call-v2.patch (11.2 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72276] [Ruby trunk - Bug #11768] [Open] Add a polymorphic inline cache — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 3, 2015 at 12:25:16 MST, tenderlove@ruby-lang.org wrote:Issue #11768 has been reported by Aaron Patterson.----------------------------------------Bug #11768: Add a polymorphic inline cachehttps://bugs.ruby-lang.org/issues/11768* Author: Aaron Patterson* Status: Open* Priority: Normal* Assignee: Koichi Sasada* ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------Hi,I've attached a patch that adds a PIC to the existing Mono IC struct.I haven't run every benchmark that's checked in, but this patch speeds up the polymorphic call benchmark by about 20%. Here is the benchmark *before* my patch:~~~[aaron@TC ruby (trunk)]$ time ./ruby benchmark/bm_vm2_poly_method.rb real 0m3.244suser 0m3.154ssys 0m0.044s[aaron@TC ruby (trunk)]$ time ./ruby benchmark/bm_vm2_poly_method.rb real 0m3.158suser 0m3.090ssys 0m0.042s[aaron@TC ruby (trunk)]$ time ./ruby benchmark/bm_vm2_poly_method.rb real 0m3.162suser 0m3.099ssys 0m0.039s~~~Here it is with my patch applied:~~~[aaron@TC ruby (pic2)]$ time ./ruby benchmark/bm_vm2_poly_method.rb real 0m2.522suser 0m2.455ssys 0m0.044s[aaron@TC ruby (pic2)]$ time ./ruby benchmark/bm_vm2_poly_method.rb real 0m2.515suser 0m2.458ssys 0m0.035s[aaron@TC ruby (pic2)]$ time ./ruby benchmark/bm_vm2_poly_method.rb real 0m2.637suser 0m2.545ssys 0m0.045s~~~Monomorhic call sites maintain the same performance:Before:~~~[aaron@TC ruby (trunk)]$ time ./ruby benchmark/bm_vm2_method.rb real 0m1.416suser 0m1.371ssys 0m0.032s[aaron@TC ruby (trunk)]$ time ./ruby benchmark/bm_vm2_method.rb real 0m1.456suser 0m1.402ssys 0m0.032s[aaron@TC ruby (trunk)]$ time ./ruby benchmark/bm_vm2_method.rb real 0m1.420suser 0m1.372ssys 0m0.032s~~~After:~~~[aaron@TC ruby (pic2)]$ time ./ruby benchmark/bm_vm2_method.rb real 0m1.451suser 0m1.399ssys 0m0.033s[aaron@TC ruby (pic2)]$ time ./ruby benchmark/bm_vm2_method.rb real 0m1.494suser 0m1.438ssys 0m0.033s[aaron@TC ruby (pic2)]$ time ./ruby benchmark/bm_vm2_method.rb real 0m1.466suser 0m1.416ssys 0m0.032s~~~The down side of this patch is that it increases memory usage because the size of the call cache struct gets larger, even if the call site is monomorphic. I think we could make the code expand and contract, but I'm not sure if it's worthwhile. The other downside is that it will probably slow down calls if the global method state changes, but I don't think that is a situation we should optimize for.I've actually attached 2 patches, one adds the PIC, the other adds a tracepoint so that I could log cache hit / miss rates.---Files--------------------------------0001-add-PIC.patch (2.9 KB)0002-add-a-tracepoint-for-PIC-hit-miss.patch (4.33 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72277] [Ruby trunk - Feature #9171] [patch] use fstrings for symbol table — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 3, 2015 at 23:21:47 MST, nobu@ruby-lang.org wrote:Issue #9171 has been updated by Nobuyoshi Nakada.Tracker changed from Bug to FeatureDescription updated----------------------------------------Feature #9171: [patch] use fstrings for symbol tablehttps://bugs.ruby-lang.org/issues/9171#change-55234* Author: Aman Gupta* Status: Closed* Priority: Normal* Assignee: Nobuyoshi Nakada----------------------------------------Here is a simple patch to use fstrings for the table backing symbols.Unfortunately it causes a segfault in test/rdoc/test_rdoc_parser_ruby.rb. Maybe someone wants to investigate.~~~diffdiff --git a/parse.y b/parse.yindex 8207ad7..b1f3112 100644--- a/parse.y+++ b/parse.y@@ -10333,7 +10333,7 @@ register_symid(ID id, const char *name, long len, rb_encoding *enc) static ID register_symid_str(ID id, VALUE str) {- OBJ_FREEZE(str);+ str = rb_fstring(str); if (RUBY_DTRACE_SYMBOL_CREATE_ENABLED()) { RUBY_DTRACE_SYMBOL_CREATE(RSTRING_PTR(str), rb_sourcefile(), rb_sourceline());diff --git a/string.c b/string.cindex 231bb2f..6ae33e3 100644--- a/string.c+++ b/string.c@@ -138,6 +138,9 @@ rb_fstring(VALUE str) st_data_t fstr; Check_Type(str, T_STRING); + if (!frozen_strings)+ frozen_strings = st_init_table(&fstring_hash_type);+ if (FL_TEST(str, RSTRING_FSTR)) return str; @@ -8707,8 +8710,6 @@ Init_String(void) #undef rb_intern #define rb_intern(str) rb_intern_const(str) - frozen_strings = st_init_table(&fstring_hash_type);- rb_cString = rb_define_class("String", rb_cObject); rb_include_module(rb_cString, rb_mComparable); rb_define_alloc_func(rb_cString, empty_str_alloc);-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72278] [Ruby trunk - Bug #9713] __FILE__ return unexpected encoding - breaks Dir.glob — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 4, 2015 at 06:35:43 MST, thomas@thomthom.net wrote:Issue #9713 has been updated by Thomas Thomassen.Revisiting this issue again. Is there a resolution to what can be done to improve this and still satisfy compatibility concerns?----------------------------------------Bug #9713: __FILE__ return unexpected encoding - breaks Dir.globhttps://bugs.ruby-lang.org/issues/9713#change-55235* Author: Thomas Thomassen* Status: Assigned* Priority: Normal* Assignee: cruby-windows* ruby -v: ruby 2.2.0dev (2014-04-07 trunk 45528) [i386-mswin32_100] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN----------------------------------------**C:/てすと/FILE.rb:**~~~# encoding: UTF-8puts "Encoding.find 'filesystem': #{Encoding.find('filesystem').inspect}"puts "Encoding.find 'locale': #{Encoding.find('locale').inspect}"puts "Encoding.default internal: #{Encoding.default_internal.inspect}"puts "Encoding.default external: #{Encoding.default_external.inspect}"puts "Encoding.locale_charmap: #{Encoding.locale_charmap.inspect}"puts "__FILE__: #{__FILE__.encoding.inspect}"puts "'foobar': #{'foobar'.encoding.inspect}"~~~**C:/FILE.rb:**~~~# encoding: UTF-8puts "Encoding.find 'filesystem': #{Encoding.find('filesystem').inspect}"puts "Encoding.find 'locale': #{Encoding.find('locale').inspect}"puts "Encoding.default internal: #{Encoding.default_internal.inspect}"puts "Encoding.default external: #{Encoding.default_external.inspect}"puts "Encoding.locale_charmap: #{Encoding.locale_charmap.inspect}"puts "__FILE__: #{__FILE__.encoding.inspect}"puts "'foobar': #{'foobar'.encoding.inspect}"puts ""puts "Loading C:/てすと/FILE.rb ..."require "C:/てすと/FILE.rb"~~~**Results:**![](media-20140407.png)~~~c:\ruby-220\usr\bin>ruby "C:\FILE.rb"Encoding.find 'filesystem': #Encoding.find 'locale': #Encoding.default internal: nilEncoding.default external: #Encoding.locale_charmap: "CP437"__FILE__: #'foobar': #Loading C:/???/FILE.rb ...Encoding.find 'filesystem': #Encoding.find 'locale': #Encoding.default internal: nilEncoding.default external: #Encoding.locale_charmap: "CP437"__FILE__: #'foobar': #c:\ruby-220\usr\bin>~~~Now, lets see how this affects Dir.glob:Test scenario - a folder structure like this:~~~C:/test/C:/test/foo/C:/test/てすと/~~~**C:/FILE.rb**~~~# encoding: UTF-8puts "Encoding.find 'filesystem': #{Encoding.find('filesystem').inspect}"puts "Encoding.find 'locale': #{Encoding.find('locale').inspect}"puts "Encoding.default internal: #{Encoding.default_internal.inspect}"puts "Encoding.default external: #{Encoding.default_external.inspect}"puts "Encoding.locale_charmap: #{Encoding.locale_charmap.inspect}"puts "__FILE__: #{__FILE__.encoding.inspect}"puts "'foobar': #{'foobar'.encoding.inspect}"puts ""pattern = File.join(File.dirname(__FILE__), "test", "*")puts "pattern.encoding: #{pattern.encoding.inspect}"result = Dir.glob(pattern)p resultp result.map { |file| file.encoding }puts ""puts "force encoding:"pattern.force_encoding("UTF-8")result = Dir.glob(pattern)p resultp result.map { |file| file.encoding }~~~**Result:**~~~c:\ruby-220\usr\bin>ruby "C:\FILE.rb"Encoding.find 'filesystem': #Encoding.find 'locale': #Encoding.default internal: nilEncoding.default external: #Encoding.locale_charmap: "CP437"__FILE__: #'foobar': #pattern.encoding: #["C:/test/foo", "C:/test/???"][#, #]force encoding:["C:/test/foo", "C:/test/\u3066\u3059\u3068"][#, #]c:\ruby-220\usr\bin>~~~Observe how when Dir.glob is fed a string based on __FILE__ it will return strings in the same encoding, even though the string should include Unicode characters. The Unicode characters are replaced by question marks. (Actual ASCII bytes for question mark: 63)Just by forcing the input string to UTF-8 will make Dir.glob return the expected strings with correct Unicode characters.I'm unsure of where the bug lies, but in terms of what I expected I would not have expected __FILE__ to return different encoding depending on the executing file containing Unicode characters. All files have been marked as UTF-8 in the file header.---Files--------------------------------media-20140407.png (83.1 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72279] [Ruby trunk - Bug #9715] ENV data yield ASCII-8BIT encoded strings under Windows with unicode username — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 4, 2015 at 07:09:28 MST, thomas@thomthom.net wrote:Issue #9715 has been updated by Thomas Thomassen.Trying to bump this. Even just some feedback on what an acceptable change would be and I could try to produce a patch.----------------------------------------Bug #9715: ENV data yield ASCII-8BIT encoded strings under Windows with unicode usernamehttps://bugs.ruby-lang.org/issues/9715#change-55236* Author: Thomas Thomassen* Status: Open* Priority: Normal* Assignee: cruby-windows* ruby -v: ruby 2.2.0dev (2014-04-07 trunk 45530) [i386-mswin32_100]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN----------------------------------------My testing scenario:English Windows, Unicode username: てすとHome directory: C:\Users\てすと\The values returned from ENV have different encoding depending on their content. It appear to be OEM encoding label to most value, except when they contain characters not included in the OEM codepage. When they are not, for instance `ENV['HOME']` when the username is "てすと" will have ASCII-8BIT.(I find the "ASCII-8BIT" name for an encoding confusing, as ASCII is 7bit - byte range 0-127)But it appear that "ASCII-8BIT" is also aliased as "binary"? So Ruby is here returning a binary string when ENV contain byte characters not included in the OEM code page?Reading the docs for Encoding:> Returns default internal encoding. Strings will be transcoded to the default internal encoding in the following places if the default internal encoding is not nil:> ...> ::default_internal is initialized by the source file's internal_encoding or -E option.This includes `ENV` - but, even when I run ruby with the `-E` flag the `ENV` encoding doesn't change. It's still using the OEM code page - or ASCII-8BIT.However, regardless of having set `-E` or not, ENV do appear to return UTF-8 bytes in the strings that contain the Unicode username.This is one of several areas where I have found -E to have no effect on Ruby's string handling. I understand that some of Ruby's file handling is for backwards compatibility reasons, but I'm finding it difficult to set up a system which can properly handle Unicode files under Windows. Is this deliberate due to backwards compatibility decisions? Or have I simply not found the correct configuration flags for it? To me it appear bugged - inconsistent with what the documentation says. But please enlighten me if I am incorrect. My ideal situation would be for all strings to default to UTF-8.Examples:~~~C:\ruby-220\usr\bin>ruby -E UTF-8:UTF-8 -e "p ENV['ProgramFiles'].encoding"#C:\ruby-220\usr\bin>ruby -E UTF-8:UTF-8 -e "p ENV['ProgramFiles'].bytes"[67, 58, 92, 80, 114, 111, 103, 114, 97, 109, 32, 70, 105, 108, 101, 115, 32, 40, 120, 56, 54, 41]~~~~~~C:\ruby-220\usr\bin>ruby -e "p ENV['HOME']""C:/Users/\xE3\x81\xA6\xE3\x81\x99\xE3\x81\xA8"C:\ruby-220\usr\bin>ruby -e "p ENV['HOME'].encoding"#C:\ruby-220\usr\bin>ruby -e "p ENV['HOME'].bytes"[67, 58, 47, 85, 115, 101, 114, 115, 47, 227, 129, 166, 227, 129, 153, 227, 129, 168]C:\ruby-220\usr\bin>ruby -e "p __ENCODING__"#C:\ruby-220\usr\bin>ruby -e "p Encoding.default_internal"nilC:\ruby-220\usr\bin>ruby -e "p Encoding.default_external"#C:\ruby-220\usr\bin>ruby -e "p Encoding.find('filesystem')"#C:\ruby-220\usr\bin>ruby -E UTF-8:UTF-8 -e "p ENV['HOME'].encoding"#C:\ruby-220\usr\bin>ruby -E UTF-8:UTF-8 -e "p ENV['HOME'].bytes"[67, 58, 47, 85, 115, 101, 114, 115, 47, 227, 129, 166, 227, 129, 153, 227, 129, 168]~~~-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72280] [Ruby trunk - Feature #10930] Allow splat operator to work for string interpolation — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 4, 2015 at 21:53:25 MST, 6ftdan@gmail.com wrote:Issue #10930 has been updated by Daniel P. Clark.~~~rubyclass Example def method_missing m, *a puts "Method #{m} called with arguments ", *a endendExample.new.foo :bar, :baz#Method foo called with arguments #bar#bazclass Example def method_missing m, *a puts "Method #{m} called with arguments #{a}" endendExample.new.foo :bar, :baz#Method foo called with arguments [:bar, :baz]~~~Neither of these are the desired behavior. It ends up needing to be implemented like this.~~~rubyclass Example def method_missing m, *a puts "Method #{m} called with arguments #{a.to_s[1..-2]}" endendExample.new.foo :bar, :baz#Method foo called with arguments :bar, :baz~~~----------------------------------------Feature #10930: Allow splat operator to work for string interpolationhttps://bugs.ruby-lang.org/issues/10930#change-55245* Author: Daniel P. Clark* Status: Feedback* Priority: Normal* Assignee: ----------------------------------------Currently when you use the splat operator in a method it pulls the items out of the array for method parameters.~~~rubydef foo(a,b,c) puts "#{a}, #{b}, #{c}"endbar = [1,2,3]foo(*bar)# => "1, 2, 3"~~~So I would expect to be able to do "#{*bar}" and get either "1, 2, 3" or "1,2,3". But when attempting this I get.~~~rubybaz = [1,2,3]"#{*baz}"# SyntaxError: (irb):53: syntax error, unexpected tSTRING_DEND, expecting '='# "#{*baz}"# ^# (irb):53: unterminated string meets end of file"#{*[1,2,3]}"# SyntaxError: (irb):54: syntax error, unexpected tSTRING_DEND, expecting :: or '[' or '.'# "#{*[1,2,3]}"# ^# (irb):54: unterminated string meets end of file~~~This doesn't work on any of the Ruby versions available 1.8 through 2.2.1. They each produce the same error.I propose allowing the splat operator within string interpolation to work the same as [1,2,3].join(',')~~~rubyfiz = [1,2,3]"#{*fiz}"# => "1,2,3""#{*[1,2,3]}"# => "1,2,3"~~~-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72281] Re: [Ruby trunk - Feature #11741] Migrate Ruby to Git from Subversion — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 1, 2015 at 13:58:19 MST, Eric Wong <normalperson@yhbt.net> wrote:web2004@sytse.com wrote:> Eric Wong wrote:> > The main site's Terms of Service (or any ToS) is still a problem> > for me. Currently there is no ToS at all on our Redmine instance> > and registration is completely non-intuitive on GitLab w/o JS.> 1. Is this about the terms of service for GitLab.com or something> else? Since I think a self hosted GitLab instance is proposed I think> there are no ToS.OK for the proposed instance. But if we find a problem with the hostedinstance and want to report the problem to GitLab itself, the reporterwould still have to deal with the ToS of GitLab.comA bigger problem is none of these centralized messaging systems have anyinteropability with each other. Different Redmine/GitLab instancescannot talk to each other; and Redmine instances can't talk to GitLabinstances, etc. Bugs do cross project boundaries occasionally...Plain-text email is still the only interoperable way to communicate.Debian's BTS actually gets this right and interoperates well withexisting mailing lists. From my limited experience, RT does as well.> 2. If better non-javascript functionality is needed for the conversion> to happen we would be happy to add that.For one, the registration page I noted earlier only shows a bunchof unlabeled input boxes on w3m (which has no JS or CSS support).Does GitLab have mailing list integration? Fwiw, I would not havebothered contributing to Ruby if we did not have ruby-core mailing listintegration with Redmine (but I'm only an occasional contributor toRuby).> 3. If GitLab Inc. is acquired by another company (which is unlikely)> GitLab the project will still continue. It is in use by more than> 100,000 organizations and has over 800 contributors and is MIT> licensed.It's likely the Gitorious guys were thinking the same a few years ago :)Really, I remain unconvinced GitLab is any better than Redmine.What I can comfortably say is git is better than SVN in most aspects:* robustness/data integrity* disconnected operation* speed* scriptability with a stable plumbing interface* ease-of-contributing (open-to-everyone mailing list)Of course git likely loses in terms of usability and learning curve[1],and maybe still doesn't work as well on non-Free OSes.[1] Side note: I recommend anybody new to git to learn the blob/tree/commit data relationships with the plumbing, first; but maybe that's just me.

1 message 2015/12/18

[#72283] [Ruby trunk - Bug #11401] Net::HTTP SSL session resumption does not send SNI — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On November 30, 2015 at 05:17:42 MST, usa@garbagecollect.jp wrote:Issue #11401 has been updated by Usaku NAKAMURA.Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE to 2.0.0: REQUIRED, 2.1: DONE, 2.2: DONEruby_2_1 r52799 merged revision(s) 52682.----------------------------------------Bug #11401: Net::HTTP SSL session resumption does not send SNIhttps://bugs.ruby-lang.org/issues/11401#change-55162* Author: Michiel Karnebeek* Status: Closed* Priority: Normal* Assignee: openssl* ruby -v: * Backport: 2.0.0: REQUIRED, 2.1: DONE, 2.2: DONE----------------------------------------See https://github.com/ruby/ruby/pull/964## ProblemWhen an initial SSL request is done, Net::HTTP stores the OpenSSL::SSL::Session object in @ssl_session.When (after the http-keep-alive timeout has expired, or the connection was closed for some other reason) a second http request is made by Net::Http, resulting in calling Net::Http#connect (see the relevant pieces of code below, while reading the following points).* #connect first calls `OpenSSL::SSL::SSLSocket#session=` at http.rb:924, which, in C code, eventually calls the C-method ossl_ssl_setup * which executes the `if(!ssl) {` block at ossl_ssl.c:1205, but since @hostname has not been set yet, it will not execute SSL_set_tlsext_host_name. Also, because the OpenSSL::SSL::Session object does not contain a hostname, it is not known to OpenSSL at this point.* it then calls `OpenSSL::SSL::SSLSocket#hostname=` at http.rb:927 which only sets @hostname on OpenSSL::SSL::SSLSocket* and then it calls `OpenSSL::SSL::SSLSocket#connect` at http.rb:941 * which is doing the second call to the C-method ossl_ssl_setup, but since the `if(!ssl) {` already ran, it won't run again, and won't set the hostname from @hostname to SSL_set_tlsext_host_name.This causes the second request to contains a SSL Session Ticket, but not a SNI header. This is easily verified by doing 2 calls in a ruby script, with a sleep 2.1 in between (http-keep-alive timeout is 2 seconds by default) and checking the second Client Hello message in Wireshark.Normally this does not cause any issues, because the server looks at the SSL Session Ticket and knows for which virtual host it issued the ticket. So when a second request comes in with that ticket, it assumes the request should be handled by that vhost.However, this breaks when the client (Ruby) thinks the session ticket is still valid (#10533 did some fixing), sends it to the server, but the server denies it. The server then starts to renegotiate the SSL session, but since the SNI header is missing, it won't know for which vhost, and sends the SSL certificate for the default vhost, which may not be the vhost it wants to connect to. The client (Ruby) then checks the certificate against the hostname it was connecting to, and finds out it doesn't match.So, this only occurs on SSL session resumption (the second http request after http-keep-alive expired, or the connection was closed), when connecting to non-default vhosts which has a different certificate set than the default vhost, and when the client thinks the SSL Session Ticket is valid, but the server disagrees.Why would the server deny the SSL session ticket? The client already checked if it was valid, right? Well, all kind of reasons:* Server may have invalidated the ticket earlier than the client* Server rebooted* Time drift* ...* but mostly because the SSL termination for a specific hostname may be handled by multiple servers, which are not sharing their SSL session tickets (or sharing them in a delayed matter).## SolutionThe solution is to move the call to `OpenSSL::SSL::SSLSocket#hostname=` before the call to `OpenSSL::SSL::SSLSocket#session=`, so the hostname gets set when ossl_ssl_set_session calls ossl_ssl_setup## Relevant code pieceshttp.rb~~~868 def connect...878 s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {...885 }886 s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)887 D "opened"888 if use_ssl?...897 @ssl_context = OpenSSL::SSL::SSLContext.new898 @ssl_context.set_params(ssl_parameters)899 D "starting SSL for #{conn_address}:#{conn_port}..."900 s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context) 901 s.sync_close = true902 D "SSL established"903 end904 @socket = BufferedIO.new(s)...908 if use_ssl?909 begin910 if proxy?...921 end922 if @ssl_session and923 Process.clock_gettime(Process::CLOCK_REALTIME) 924 s.session = @ssl_session if @ssl_session (calls the C-method ossl_ssl_setup) also, this does not set the hostname, as OpenSSL::SSL::Session does not contain a hostname925 end926 # Server Name Indication (SNI) RFC 3546927 s.hostname = @address if s.respond_to? :hostname= It relies on ossl_ssl_setup to actually set it to openssl (SSL_set_tlsext_host_name at ossl_ssl.c:1221928 if timeout = @open_timeout929 while true930 raise Net::OpenTimeout if timeout 931 start = Process.clock_gettime Process::CLOCK_MONOTONIC932 # to_io is requied because SSLSocket doesn't have wait_readable yet933 case s.connect_nonblock(exception: false)934 when :wait_readable; s.to_io.wait_readable(timeout)935 when :wait_writable; s.to_io.wait_writable(timeout)936 else; break937 end938 timeout -= Process.clock_gettime(Process::CLOCK_MONOTONIC) - start939 end940 else941 s.connect but does not set up hostname, as it already ran once (see ossl_ssl.c:1205)942 end943 if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE944 s.post_connection_check(@address)945 end946 @ssl_session = s.session 947 rescue => exception948 D "Conn close because of connect error #{exception}"949 @socket.close if @socket and not @socket.closed?950 raise exception951 end952 end953 on_connect954 end~~~ossl_ssl.c~~~101 static const char *ossl_ssl_attrs[] = {102 #ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME103 "hostname",104 #endif105 "sync_close",106 };...1330 ossl_ssl_connect(VALUE self)1331 {1332 ossl_ssl_setup(self);1333 return ossl_start_ssl(self, SSL_connect, "SSL_connect", 0, 0);1334 }...1197 ossl_ssl_setup(VALUE self) 1198 { 1199 VALUE io, v_ctx, cb; 1200 SSL_CTX *ctx; 1201 SSL *ssl; 1202 rb_io_t *fptr; 1203 1204 GetSSL(self, ssl); 1205 if(!ssl){ 1206 #ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME 1207 VALUE hostname = rb_iv_get(self, "@hostname");1208 #endif 1209 1210 v_ctx = ossl_ssl_get_ctx(self); 1211 GetSSLCTX(v_ctx, ctx); 1212 1213 ssl = SSL_new(ctx); 1214 if (!ssl) { 1215 ossl_raise(eSSLError, "SSL_new"); 1216 } 1217 DATA_PTR(self) = ssl; 1218 1219 #ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME 1220 if (!NIL_P(hostname)) { 1221 if (SSL_set_tlsext_host_name(ssl, StringValuePtr(hostname)) != 1) 1222 ossl_raise(eSSLError, "SSL_set_tlsext_host_name"); 1223 } 1224 #endif 1225 io = ossl_ssl_get_io(self); 1226 GetOpenFile(io, fptr); 1227 rb_io_check_readable(fptr); 1228 rb_io_check_writable(fptr); 1229 SSL_set_fd(ssl, TO_SOCKET(FPTR_TO_FD(fptr))); 1230 SSL_set_ex_data(ssl, ossl_ssl_ex_ptr_idx, (void*)self);1231 cb = ossl_sslctx_get_verify_cb(v_ctx);1232 SSL_set_ex_data(ssl, ossl_ssl_ex_vcb_idx, (void*)cb);1233 cb = ossl_sslctx_get_client_cert_cb(v_ctx);1234 SSL_set_ex_data(ssl, ossl_ssl_ex_client_cert_cb_idx, (void*)cb);1235 cb = ossl_sslctx_get_tmp_dh_cb(v_ctx);1236 SSL_set_ex_data(ssl, ossl_ssl_ex_tmp_dh_callback_idx, (void*)cb);1237 SSL_set_info_callback(ssl, ssl_info_cb);1238 } 1239 1240 return Qtrue; 1241 } ...1825 ossl_ssl_set_session(VALUE self, VALUE arg1)1826 {1827 SSL *ssl;1828 SSL_SESSION *sess;1829 1830 /* why is ossl_ssl_setup delayed? */1831 ossl_ssl_setup(self);1832 1833 ossl_ssl_data_get_struct(self, ssl);1834 1835 SafeGetSSLSession(arg1, sess);1836 1837 if (SSL_set_session(ssl, sess) != 1)1838 ossl_raise(eSSLError, "SSL_set_session");1839 1840 return arg1;1841 }~~~Patch to http.rb:~~~@@ -914,12 +914,12 @@ module Net #:nodoc: @socket.write(buf) HTTPResponse.read_new(@socket).value end+ # Server Name Indication (SNI) RFC 3546+ s.hostname = @address if s.respond_to? :hostname= if @ssl_session and Process.clock_gettime(Process::CLOCK_REALTIME) s.session = @ssl_session if @ssl_session end- # Server Name Indication (SNI) RFC 3546- s.hostname = @address if s.respond_to? :hostname= Timeout.timeout(@open_timeout, Net::OpenTimeout) { s.connect } if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE s.post_connection_check(@address)~~~---Files--------------------------------net.http.bug.patch (884 Bytes)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72284] [Ruby trunk - Bug #11595] Time#utc? and Time#gmt? return misleading results based on $TZ — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On November 30, 2015 at 06:24:39 MST, yasuhiro6194@gmail.com wrote:Issue #11595 has been updated by Yasuhiro Nakamura.Assignee set to Akira Tanaka----------------------------------------Bug #11595: Time#utc? and Time#gmt? return misleading results based on $TZhttps://bugs.ruby-lang.org/issues/11595#change-55165* Author: David Celis* Status: Open* Priority: Normal* Assignee: Akira Tanaka* ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------There is an issue with Time#utc? and its alias, Time#gmt?, that return misleading results based on the value of the TZ environment variable. It seems that the only way for a Time instance to return `true` for `utc?` is if you explicitly call `#utc` on it before:~~~ENV['TZ'] = 'UTC'# => "UTC"time = Time.now# => 2015-10-14 19:30:00 +0000time.utc?# => falsetime = time.utc# => 2015-10-14 19:30:00 UTCtime.utc?# => true~~~This seems misleading based on the value of $TZ being "UTC". The expected result for calling `Time.now.utc?` in this case would be `true`, as would that be expected for time zones that are considered links to "UTC" based on the [tzdata list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). These include "UTC", "GMT", "Etc/UTC", "Etc/GMT", "Universal", etc.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72285] [Ruby trunk - Bug #11753] Building ruby-git on Arch Linux eats all memory on ./configure — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On November 30, 2015 at 07:45:26 MST, bar.hofesh@safe-t.com wrote:Issue #11753 has been updated by Bar Hofesh.Bar Hofesh wrote:> Hi, > > I'm trying to build Ruby from sources.> > What I tried:> > 1) Build from git using git clone, autoconf, ./configure> 2) Build with RVM versions 2.2.1, 2.2-head, 2.1.5, ruby-head> > All have failed when reaching the "./configure" phase.> It seems that all memory is getting eat up and the system hangs unless a quick "Ctrl + C" is pressed to stop the process.> > Notes:> > * I had ruby installed and working until trying to re-build> * I had a system restore which left most of /home/ with wrong permissions (was taken care of but maybe Ruby's configure needs some files with +x which don't have them right now?)> * Other programs which relays on "./configure" scripts work and build without issues.Ok, using the "echo here and there" debug method I got to the part where it is getting stuck:`# Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. echo "Testing 1" if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec;echo "Testing 2" # We cannot yet assume a decent shell, so we have to provide a# neutralization value for shells without unset; and this also# works around shells that cannot unset nonexistent variables.# Preserve -v and -x to the replacement shell.`I see "Testing 1"But not "Testing 2"----------------------------------------Bug #11753: Building ruby-git on Arch Linux eats all memory on ./configure https://bugs.ruby-lang.org/issues/11753#change-55168* Author: Bar Hofesh* Status: Open* Priority: Normal* Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------Hi, I'm trying to build Ruby from sources.What I tried:1) Build from git using git clone, autoconf, ./configure2) Build with RVM versions 2.2.1, 2.2-head, 2.1.5, ruby-headAll have failed when reaching the "./configure" phase.It seems that all memory is getting eat up and the system hangs unless a quick "Ctrl + C" is pressed to stop the process.Notes:* I had ruby installed and working until trying to re-build* I had a system restore which left most of /home/ with wrong permissions (was taken care of but maybe Ruby's configure needs some files with +x which don't have them right now?)* Other programs which relays on "./configure" scripts work and build without issues.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72292] [Ruby trunk - Bug #11830] [Open] hash.each(&:destroy) dumps core — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 16, 2015 at 22:42:46 MST, tietew@tietew.net wrote:Issue #11830 has been reported by Toru Iwase.----------------------------------------Bug #11830: hash.each(&:destroy) dumps corehttps://bugs.ruby-lang.org/issues/11830* Author: Toru Iwase* Status: Open* Priority: Normal* Assignee: * ruby -v: ruby 2.3.0dev (2015-12-17 trunk 53168) [x86_64-linux]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------Following small code dumps core.~~~$ ./ruby --disable-gems -e '{}.each(&:destroy)'-e:1: [BUG] Segmentation fault at 0x00000000aaf12cruby 2.3.0dev (2015-12-17 trunk 53168) [x86_64-linux]... see attached crash report ...Aborted (core dumped)~~~Array and Range works fine.~~~$ ./ruby -e '[1].each(&:destroy)'-e:1:in `each': undefined method `destroy' for 1:Fixnum (NoMethodError) from -e:1:in `'$ ./ruby -e '(1..2).each(&:destroy)'-e:1:in `each': undefined method `destroy' for 1:Fixnum (NoMethodError) from -e:1:in `'~~~In rb_block_arity(), block->proc and block->iseq are invalid value I think.~~~$ gdb /home/tietew/ruby/ruby2.3-trunk/bin/ruby coreGNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1...Program terminated with signal SIGABRT, Aborted.(gdb) bt...#5 #6 rb_block_arity () at proc.c:960...(gdb) frame 6#6 rb_block_arity () at proc.c:960960 GetProcPtr(proc_value, proc);(gdb) p proc_value$1 = 7643404(gdb) p proc$2 = (gdb) p *(struct RBasic *)proc_valueCannot access memory at address 0x74a10c(gdb) p *block$5 = {self = 139733405230640, ep = 0x7f16380bd9d0, iseq = 0x74a10c, proc = 7643404}(gdb)~~~---Files--------------------------------crash.txt (8.71 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72293] [Ruby trunk - Bug #11827] [Feedback] StringIO with set_encoding broken with enabled frozen string literal — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 16, 2015 at 19:23:16 MST, shugo@ruby-lang.org wrote:Issue #11827 has been updated by Shugo Maeda.Status changed from Open to Feedbackdeepj # wrote:> I'm not sure if this the following problem is an expected behavior. But I guess, it is a bug when I run the code below. It throws `set_encoding': can't modify frozen String (RuntimeError).> > ~~~> # frozen_string_literal: true> > io = StringIO.new('')> io.set_encoding(Encoding::BINARY)> ~~~> > I wouldn't expect this kind of behavior.What behavior do you expect?StringIO is a wrapper to provide IO-like interface for String, so the argument of `StringIO.new` should not be copied.```rubys = "foo"io = StringIO.new(s)io.putc(?b)p s #=> "boo"```If you specify writable mode explicitly, you can get an exception earlier:```ruby# frozen_string_literal: trueio = StringIO.new("", "w") #=> Errno::EACCESS```----------------------------------------Bug #11827: StringIO with set_encoding broken with enabled frozen string literalhttps://bugs.ruby-lang.org/issues/11827#change-55612* Author: deepj #* Status: Feedback* Priority: Normal* Assignee: * ruby -v: ruby 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-darwin15]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------I'm not sure if this the following problem is an expected behavior. But I guess, it is a bug when I run the code below. It throws `set_encoding': can't modify frozen String (RuntimeError).~~~# frozen_string_literal: trueio = StringIO.new('')io.set_encoding(Encoding::BINARY)~~~I wouldn't expect this kind of behavior.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72295] [Ruby trunk - Bug #11816] [Open] Partial safe navigation operator — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 14, 2015 at 11:19:37 MST, ruby-core@marc-andre.ca wrote:Issue #11816 has been reported by Marc-Andre Lafortune.----------------------------------------Bug #11816: Partial safe navigation operatorhttps://bugs.ruby-lang.org/issues/11816* Author: Marc-Andre Lafortune* Status: Open* Priority: Normal* Assignee: Yukihiro Matsumoto* ruby -v: preview 2* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------I'm extremely surprised (and disappointed) that, currently: x = nil x&.foo.bar # => NoMethodError: undefined method `bar' for nil:NilClassTo make it safe, you have to write `x&.foo&.bar`. But if `foo` is never supposed to return `nil`, then that code isn't "fail early" in case it actually does. `nil&.foo.bar` is more expressive, simpler and is perfect if you want to an error if `foo` returned `nil`. To actually get what you want, you have to resort using the old form `x && x.foo.bar`...In CoffeeScript, you can write `x()?.foo.bar` and it will work well, since it gets compiled to if ((_ref = x()) != null) { _ref.foo.bar; }All the discussion in #11537 focuses on `x&.foo&.bar`, so I have to ask:Matz, what is your understanding of `x&.foo.bar`?I feel the current implementation is not useful and should be changed to what I had in mind. I can't see any legitimate use of `x&.foo.bar` currently.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72296] [Ruby trunk - Bug #11657] Abort Trap 6 when running a test suite — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 16, 2015 at 11:12:14 MST, ko1@atdot.net wrote:Issue #11657 has been updated by Koichi Sasada.Thank you.minimal reproducible script is here:```rubyclass C attr_accessor :foo alias set_foo :foo=endc = C.new2.times{ c.set_foo foo: 1, bar: 2}```This is because a bug of method cache.I'll commit fix.Your provided code is so much helpful. Thank you!----------------------------------------Bug #11657: Abort Trap 6 when running a test suitehttps://bugs.ruby-lang.org/issues/11657#change-55601* Author: Andrew Hodgkinson* Status: Open* Priority: Normal* Assignee: Koichi Sasada* ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15] *OR* ruby 2.3.0dev (2015-11-01 trunk 52421) [x86_64-darwin15]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------An internal Ruby gem I develop for my company has a test suite that works fine on Ruby 2.1.x but crashes on **2.2.3 and 2.3.0-dev** with:~~~[BUG] Stack consistency error (sp: 273, bp: 271)~~~I've tried this on both OS X (10.11.1) and a Debian build in a Virtualbox VM to try and eliminate OS X as the problem, with the same results (as in, an abort and a 'stack consistency error' in the logs). I have attached the backtrace log data from both the OS X and Debian builds, from Ruby 2.2.3p173 (though as I say, I did try 2.3.0-dev too and the same stack error arose).At present, the component in question is closed source. We are actually planning to open source it, but it'll be a while. I'm unable to replicate this as some isolated test case at present I'm afraid - it seems quite a lot of "stuff" needs to happen before it dies.---Files--------------------------------ruby_crash_osx.log (141 KB)ruby_crash_debian.log (160 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72299] [Ruby trunk - Bug #11826] [Assigned] After prepending a module, rewrite Hash#[] takes no effect for calls like Hash.new[:a] — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 16, 2015 at 18:23:40 MST, shugo@ruby-lang.org wrote:Issue #11826 has been updated by Shugo Maeda.Status changed from Open to AssignedAssignee set to Koichi Sasadacichol tsai wrote:> It seems like an issue only for [] method, maybe something about syntax.> But if use 'include' instead of 'prepend', the 'h[:a]' can give an output.> Please help me check if it is a bug, sorry for bothering.It seems that redefinition check of optimized methods doesn't work properly for prepended classes.Is the following patch correct, ko1?```diffdiff --git a/vm.c b/vm.cindex a03e068..cf528e8 100644--- a/vm.c+++ b/vm.c@@ -1400,6 +1400,9 @@ static void rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me, VALUE klass) { st_data_t bop;+ if (RB_TYPE_P(klass, T_ICLASS) && FL_TEST(klass, RICLASS_IS_ORIGIN)) {+ klass = RBASIC_CLASS(klass);+ } if (me->def->type == VM_METHOD_TYPE_CFUNC) { if (st_lookup(vm_opt_method_table, (st_data_t)me, &bop)) { int flag = vm_redefinition_check_flag(klass);```----------------------------------------Bug #11826: After prepending a module, rewrite Hash#[] takes no effect for calls like Hash.new[:a]https://bugs.ruby-lang.org/issues/11826#change-55609* Author: cichol tsai* Status: Assigned* Priority: Normal* Assignee: Koichi Sasada* ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------~~~module M def self.prepended(clz) clz.class_eval do def [](k) p 1 end end endendmodule N def self.included(clz) clz.class_eval do def []=(k, v) p 2 end end endendclass Hash prepend M include NendHash.new[1]Hash.new[1]=1~~~Running this example gives no output, which is expected to be '1 2'.I am using 'ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]'.Thanks in advanced.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72300] [Ruby trunk - Bug #11825] MatchData#names returns ASCII-8BIT — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 16, 2015 at 18:36:24 MST, nobu@ruby-lang.org wrote:Issue #11825 has been updated by Nobuyoshi Nakada.Description updatedBackport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED----------------------------------------Bug #11825: MatchData#names returns ASCII-8BIThttps://bugs.ruby-lang.org/issues/11825#change-55611* Author: Toru Iwase* Status: Closed* Priority: Normal* Assignee: * ruby -v: ruby 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-linux]* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED----------------------------------------`MatchData#names` returns ASCII-8BIT.But `MatchData#[]` doesn't accept ASCII-8BIT name if name has non-ASCII chars.`MatchData#names` should return same encoding of regexp. (UTF-8 by default)~~~$ irbruby 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-linux]irb(main):001:0> m = /(?ルビー)/.match('ルビー')=> #irb(main):002:0> m.names=> ["\xE5\xAE\x9D\xE7\x9F\xB3"]irb(main):003:0> m[m.names[0]]IndexError: undefined group name reference: "\xE5\xAE\x9D\xE7\x9F\xB3" from (irb):3:in `[]' from (irb):3 from /usr/local/anyenv/envs/rbenv/versions/2.3.0-preview2/bin/irb:11:in `'irb(main):004:0> m['宝石']=> "ルビー"irb(main):005:0> m.names[0].encoding=> #irb(main):006:0> m = /(?ルビー)/.match('ルビー')=> #irb(main):007:0> m.names=> ["gem"]irb(main):008:0> m.names[0].encoding=> #irb(main):009:0> m[m.names[0]]=> "ルビー"~~~-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72305] [Ruby trunk - Bug #11837] [Open] ./miniruby.exe: No such file or directory — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 17, 2015 at 17:06:54 MST, duerst@it.aoyama.ac.jp wrote:Issue #11837 has been reported by Martin D端rst.----------------------------------------Bug #11837: ./miniruby.exe: No such file or directoryhttps://bugs.ruby-lang.org/issues/11837* Author: Martin D端rst* Status: Open* Priority: Normal* Assignee: Nobuyoshi Nakada* ruby -v: ruby 2.3.0dev (2015-12-17 trunk 53170) [x86_64-cygwin]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------I get the error below when running autoconf; ./configure on a new checkout. It seems to be pretty clear that there will be no ./miniruby around at this point, so I'm not sure why it is necessary.checking for prefix of external symbols... NONEchecking pthread.h usability... yeschecking pthread.h presence... yeschecking for pthread.h... yeschecking for nroff... /usr/bin/nroff.ext/include/x86_64-cygwin/ruby/config.h updatedconfigure: ruby library version = 2.3.0configure: creating ./config.statusconfig.status: creating GNUmakefileconfig.status: creating Makefileconfig.status: creating ruby-2.3.pccompiling version.cgenerating x86_64-cygwin-fake.rb/bin/sh: line 1: ./miniruby.exe: No such file or directoryuncommon.mk:568: recipe for target 'x86_64-cygwin-fake.rb' failedmake: *** [x86_64-cygwin-fake.rb] Error 127-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72307] [Ruby trunk - Feature #10130] String format with nested hash — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 12, 2015 at 06:29:33 MST, sawadatsuyoshi@gmail.com wrote:Issue #10130 has been updated by Tsuyoshi Sawada.Now that we have `Hash#dig` and `Array#dig` coming for Ruby 2.3, I think that this proposal of mine from the past makes more sense. Regarding Matz' point (2), this proposal should parallel the feature of `dig`. It doesn't add extra cognitive load to us beyond what we would know about `dig` in the coming version of Ruby.Regarding Matz' point (3), string format (`%{}`) cannot be replaced by string interpolation (`#{}`) when we want a static file that is to be used as a template, to which values would be inserted later to output a page. Interpolation requires dynamic evaluation of the string each time.Regarding Matz' point (1), instead of using the period as the delimiter, we can use a comma (followed by optional space characters), which would resemble how `dig` is called. "Author: %{author, name} (%{author, affiliation}), %{date}" % {author: {name: "Ruby Taro", affiliation: "Ruby co."}, date: "2014, 8, 14"} #=> "Author: Ruby Taro (Ruby co.), 2014, 8, 14"This requires a key with a comma inside `%{}` not to be interpreted as a single symbol but as a sequence of symbols separated by the comma (followed by space characters). Since it is rare that a comma is used in a symbol, I don't think it will affect existing code.----------------------------------------Feature #10130: String format with nested hashhttps://bugs.ruby-lang.org/issues/10130#change-55495* Author: Tsuyoshi Sawada* Status: Rejected* Priority: Normal* Assignee: Yukihiro Matsumoto----------------------------------------When we do string format with hashes, we have the restriction that the hash cannot be a nested one. When we want to handle more complicated string formats, for example in templates, it is more convenient if we can use a nested hash. "Author: %{author.name} (%{author.affiliation}), %{date}" % {author: {name: "Ruby Taro", affiliation: "Ruby co."}, date: "2014, 8, 14"} #=> "Author: Ruby Taro (Ruby co.), 2014, 8, 14"-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72308] [Ruby trunk - Feature #11815] [Open] Proposal for method `Array#difference` — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 14, 2015 at 01:27:10 MST, cary@swoveland.com wrote:Issue #11815 has been reported by Cary Swoveland.----------------------------------------Feature #11815: Proposal for method `Array#difference`https://bugs.ruby-lang.org/issues/11815* Author: Cary Swoveland* Status: Open* Priority: Normal* Assignee: ----------------------------------------I propose that a method `Array#difference` be added to the Ruby core. It is similar to [Array#-](http://ruby-doc.org/core-2.2.0/Array.html#method-i-2D) but for each element of the (array) argument it remove only one matching element from the receiver. For example: a = [1,2,3,4,3,2,2,4] b = [2,3,4,4,4] a - b #=> [1] c = a.difference b #=> [1, 3, 2, 2] As you see, `a` contains three `2`'s and `b` `1`, so the first `3-1 #=> 2` `2`'s in `a` have been removed from `a` in constructing `c`. When `b` contains as least as many instances of an element as does `a`, `c` contains no instances of that element. It could be implemented as follows: class Array def difference(other) dup.tap do |cpy| other.each do |e| ndx = cpy.index(e) cpy.delete_at(ndx) if ndx end end end endHere are a few examples of its use:*Identify an array's non-unique elements* a = [1,3,2,4,3,4] u = a.uniq #=> [1, 2, 3, 4] u - a.difference(u) #=> [1, 2]*Determine if two words of the same size are anagrams of each other* w1, w2 = "stop", "pots" w1.chars.difference(w2.chars).empty? #=> true*Identify a maximal number of 1-1 matches between the elements of two arrays and return an array of all elements from both arrays that were not matched* a = [1, 2, 4, 2, 1, 7, 4, 2, 9] b = [4, 7, 3, 2, 2, 7] a.difference(b).concat(b.difference(a)) # => [1, 1, 4, 2, 9, 3, 7] To remove elements from `a` starting at the end (rather the beginning) of `a`: a = [1,2,3,4,3,2,2,4] b = [2,3,4,4,4] a.reverse.difference(b).reverse #=> [1,2,3,2]`Array#difference!` could be defined in the obvious way.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72309] [Ruby trunk - Bug #8860] [Closed] 64-bit x86 ruby 1.9.3-p448 on Solaris core dumps on bug4950 test case — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 14, 2015 at 22:24:39 MST, ngotogenome@gmail.com wrote:Issue #8860 has been updated by Naohisa Goto.Status changed from Feedback to ClosedClosed because of no feedback, and because 1.9.3 is EOL.Recently, some problems about fork and exec on Solaris have been fixed.See [Bug #11265], [Bug #11336], and [Bug #11353], though these may not be related with this issue.----------------------------------------Bug #8860: 64-bit x86 ruby 1.9.3-p448 on Solaris core dumps on bug4950 test casehttps://bugs.ruby-lang.org/issues/8860#change-55547* Author: April Chin* Status: Closed* Priority: Normal* Assignee: Naohisa Goto* ruby -v: ruby 1.9.3p448 (2013-06-27 revision 41675) [i386-solaris2.12]* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN----------------------------------------64-bit ruby 1.9.3-p448 on x86 in Solaris, compiled with the Studio 12.1 compiler,core dumps against the test case for bug 4950 in bootstraptest/test_fork.rb.This problem sounds similar to issue 6334, which was rejected dueto lack of information.The core dump does not occur with 64-bit ruby 1.9.3 on sparc.configure options used:--prefix=/usr/ruby/1.9 --mandir=/usr/ruby/1.9/share/man --bindir=/usr/ruby/1.9/bin --libdir=/usr/ruby/1.9/lib --sbindir=/usr/ruby/1.9/sbin --enable-shared --enable-rpath --enable-install-doc --disable-option-checking --with-openssl CFLAGS="-m64 -xO2 -xchip=generic -Ui386 -U__i386 -D__amd64 -xregs=no%frameptr -mt -DFFI_NO_RAW_API"$ cat bug4950a = []trap(:INT) { a.push(1) }trap(:TERM) { a.push(2) }pid = $$fork dosleep 0.5 puts "send start" Process.kill(:INT, pid) Process.kill(:TERM, pid) puts "send end"endputs "sleep start"sleep 3puts "sleep end"p a$ ruby bug4950sleep startsend startsend endMemory fault(coredump)$ pstack corecore 'core' of 24964: ruby bug4950------------ lwp# 1 / thread# 1 --------------- ffff80ffbf5a6797 __lwp_park () + 17 ffff80ffbf5a0062 cond_wait_queue () + 62 ffff80ffbf5a04a0 cond_wait_common () + 1dc ffff80ffbf5a06e5 __cond_timedwait () + 5d ffff80ffbf5a0779 cond_timedwait () + 29 ffff80ffbf5a07ad pthread_cond_timedwait () + 9 ffff80ffb8799564 native_cond_timedwait () + 24 ffff80ffb8799b5c native_sleep () + d8 ffff80ffb879b26d sleep_timeval () + 7d ffff80ffb879b3ff rb_thread_wait_for () + 27 ffff80ffb8712162 rb_f_sleep () + 4a ffff80ffb8789eb4 vm_call_cfunc () + c0 ffff80ffb878a562 vm_call_method () + 2ae ffff80ffb878d57b vm_exec_core () + 1403 ffff80ffb8796e7b vm_exec () + 5c7 ffff80ffb8796f93 rb_iseq_eval_main () + 2b ffff80ffb86b3917 ruby_exec_internal () + 87 ffff80ffb86b39f6 ruby_exec_node () + 1e ffff80ffb86b39bc ruby_run_node () + 24 0000000000400ec8 main () + 4c 0000000000400d1c ???????? ()------------ lwp# 3 / thread# 3 --------------- ffff80ffbf7b189f lookup_sym () + 3b ffff80ffbf7cb9db elf_bndr () + 11b ffff80ffbf7ad073 elf_rtbndr () + 83 ffff80ffbf7ee030 ???????? () ffff80ffbf5a6876 __sighndlr () + 6 ffff80ffbf599bba call_user_handler () + 2ce ffff80ffbf59a063 sigacthandler (f, ffff80ffbf76b6c8, ffff80ffbf76b360) + db --- called from signal handler with signal 15 (SIGTERM) --- ffff80ffbf5b026b _syscall6 () + 1b ffff80ffbf599b01 call_user_handler () + 215 ffff80ffbf59a063 sigacthandler (2, ffff80ffbf76bc98, ffff80ffbf76b930) + db --- called from signal handler with signal 2 (SIGINT) --- ffff80ffbf5af64a __pollsys () + a ffff80ffbf4fc6c5 pselect () + 181 ffff80ffbf4fcb44 select () + 68 ffff80ffb8799f57 thread_timer () + b3 ffff80ffbf5a64a5 _thrp_setup () + a5 ffff80ffbf5a6750 _lwp_start ()---Files--------------------------------core.part1 (3 MB)core.part2 (2.96 MB)test_fork_modified.rb (267 Bytes)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72313] [Ruby trunk - Misc #11783] [Open] Do you have any idea if you have a budgets? — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 7, 2015 at 03:29:55 MST, ko1@atdot.net wrote:Issue #11783 has been reported by Koichi Sasada.----------------------------------------Misc #11783: Do you have any idea if you have a budgets?https://bugs.ruby-lang.org/issues/11783* Author: Koichi Sasada* Status: Open* Priority: Normal* Assignee: ----------------------------------------Do you have any idea about Ruby interpreter implementation to do with budgets?# BackgroundNow, we are summarizing many contributions from many people, organizations and companies.https://docs.google.com/document/d/1y1sQc40qeuWjF84rVrTmH-ogZ_iNGqU-RUSE8GDlRuk/edit?usp=sharing(please let me know if you know any other contributes)(sorry we wrote contributions especially for MRI, because we don't know)The great recent news is we get new mac mini machine to run CI on El Capitan. We already have a mac mini machine running CI, but on Yosemite. So we can run CI on both Yosemite and El Capitan.This new mac mini machine was sponsored by YassLab, Japanese small company.At first, we ask Nihon-Ruby-no-Kai to prepare this machine, and Takahashi-san (chair man of this organization) tweet about it ("anyone can support it?"). Yasukawa-san, the president of YassLab answers "ok, we'll support it".We learned that if we show requirements explicitly, anyone may help us.Listing is important.# Any idea?Today's developers meeting, we had discussed about that and itemize some dreams.> nurse: VPS severs for CI are welcome. Especially for Azure.> ko1: travel fee (1,000,000 JPY?) for hackathon to gather MRI developers in one place> ko1: physical machines for development and benchmarks (300,000 JPY)> nobu: development machine (400,000 JPY) because he has several trouble on current machine.> nurse: icc (and other softwares) to try.> martin: grant project for MRI development topics> ko1: education to grow other MRI developer (no estimation)Do you have any other idea?I'll show these list at RubyKaigi, and someone may consider to support us.(IMO, maybe sponsoring nobu's machine is great contribution for Ruby worlds. Nobu will put companies logo stickers on his laptop)Thanks,Koichi-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72315] [Ruby trunk - Feature #11708] Specify a way to override Struct-subclass constructor — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 12, 2015 at 12:48:40 MST, prijutme4ty@gmail.com wrote:Issue #11708 has been updated by Ilya Vorontsov.Assignee set to Yukihiro Matsumoto----------------------------------------Feature #11708: Specify a way to override Struct-subclass constructorhttps://bugs.ruby-lang.org/issues/11708#change-55498* Author: Ilya Vorontsov* Status: Open* Priority: Normal* Assignee: Yukihiro Matsumoto----------------------------------------It's common to create simple data-object with some constraints. One can either implement custom class or use `Struct`. Struct is generally simpler and helps to avoid some mistakes as non-defined `#hash` and `#eql?`. But at the same time it's more difficult to make validation for `Struct` subclass.```rubyPoint = Struct.new(:x, :y)NonnegativePoint = Struct.new(:x,:y) do def initialize(*args, &block) super raise 'Negative coordinates are not allowed' if x endend```Above written code solves the problem but has one flaw. `Struct.new` creates a subclass of `Struct` and defines some methods as `#x`, `#x=`. And there are no guarantees that `NonnegativePoint#initialize` wasn't redefined too.We can check that `Point.new` without explicitly defined `#initialize` actually hits `Struct#initialize` and `Point#initialize` not defined:```rubyPoint.instance_method(:initialize)# => #NonnegativePoint.instance_method(:initialize)# => #```But nothing in `Struct` documentation or test suite states that this behavior can't be changed in newer ruby versions.I propose either to declare in docs and test that initialize method can be safely overriden because `#initialize` is not defined in `Struct` subclasses.In you assume that one day current behavior can change (e.g. for perfomance reasons), then it's reasonable to create an extension point like '#after_initialize' which is called from `Struct`'s subclass `#initialize` method.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72321] [Ruby trunk - Bug #11805] [Open] Cannot run Ruby — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 11, 2015 at 03:24:10 MST, sawadatsuyoshi@gmail.com wrote:Issue #11805 has been reported by Tsuyoshi Sawada.----------------------------------------Bug #11805: Cannot run Rubyhttps://bugs.ruby-lang.org/issues/11805* Author: Tsuyoshi Sawada* Status: Open* Priority: Normal* Assignee: * ruby -v: ruby 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-linux]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------I installed the new Ruby, and tried to run Ruby, but it raises the following error.(Since I installed Ruby 2.3.0preview1, it had a bug, and I had not been able to run Ruby, and now, after having waited for a month, I installed the new one, and there still is a bug. Disappointed a little bit.) /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/stub_specification.rb:112:in `initialize': Permission denied @ rb_sysopen - /usr/local/lib/ruby/gems/2.3.0/specifications/did_you_mean-1.0.0.beta3.gemspec (Errno::EACCES) from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/stub_specification.rb:112:in `open' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/stub_specification.rb:112:in `data' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/stub_specification.rb:203:in `valid?' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:748:in `select' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:748:in `gemspec_stubs_in' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:773:in `block in map_stubs' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:770:in `each' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:770:in `flat_map' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:770:in `map_stubs' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:762:in `installed_stubs' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:830:in `stubs' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:1035:in `find_by_path' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems.rb:188:in `try_activate' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:124:in `rescue in require' from /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:39:in `require' from :6:in `'-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72326] [Ruby trunk - Bug #11648] Undocumented features of String#oct — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 14, 2015 at 05:43:34 MST, yugui@yugui.jp wrote:Issue #11648 has been updated by Yuki Sonoda.Assignee set to Yukihiro MatsumotoIt is surprising for me too. But this behavior was introduced in r373 by intention.I hope Matz remembers the original intention.I guess Ruby followed the behavior of Perl and it was useful to handle string representation of file permissions?----------------------------------------Bug #11648: Undocumented features of String#octhttps://bugs.ruby-lang.org/issues/11648#change-55532* Author: Mike Pastore* Status: Open* Priority: Normal* Assignee: Yukihiro Matsumoto* ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------String#oct will adjust the base of the stringy number being converted to 2 (if prefixed with 0B), 8 (also the default, if prefixed with 0O), 10 (if prefixed with 0D), or 16 (if prefixed with 0X). Much to my surprise this behavior is not documented at ruby-doc.org [1]. Is this the intended behavior and if so should the documentation be updated? If it is not the intended behavior, perhaps String#oct should raise an exception if someone tries to use this undocumented feature? 1. http://ruby-doc.org/core-2.2.3/String.html#method-i-oct-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72327] [Ruby trunk - Feature #11817] [Open] map.parallel — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 14, 2015 at 15:53:42 MST, eike@inter.net wrote:Issue #11817 has been reported by Eike Dierks.----------------------------------------Feature #11817: map.parallelhttps://bugs.ruby-lang.org/issues/11817* Author: Eike Dierks* Status: Open* Priority: Normal* Assignee: ----------------------------------------I'd like to suggest a new method: #parallelThat method should take care of executing workloads in parallel across multiple cores.I believe that #map can sometimes be distributed to many simultaneous threads.So we would spread out the map blocks into parallel processing,and then collect the results in order.I believe this would need some new infrastructure like apple did with great_central,so I'm talking along these lines.(Aka we only want to open up as many threads as there are cores)This would not help much with a simple map (because we need to collect and serialize the results in the end)but it could be cool for more complex mappings.Maybe this should have been a rails topic first,because there it might make a lot of sense to render partials in parallel,this could really speed up rails response rendering ;-)But I believe this is a topic for ruby in general.Given that we now go to really many cores,it should be at the heart of ruby to use that.For a start we could just declare #parallel as -> return self.and than improve on it.A naive implementation would just open a new thread for every parallel map block,but that would not work well -- it actually would be very slow.So we actually need a thread management,along the lines of great central.I believe this should be built into the very core libs of the ruby language.I know this is hard stuff, but it needs to be done.Let's go parallel from the heart of the language.---Please let us discuss if adding the #parallel method would be a good idea.Let's come up with some implementations to find the problems.I'm explicitly referring to map#parallel here.In rails that might be cache.parallel (if you followed)for some math tasks it might also be parallel do {}-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72328] [Ruby trunk - Bug #11714] [Rejected] `include Module` affects scope of code loaded by require statements on Ruby 2.2+ — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 14, 2015 at 19:57:40 MST, shugo@ruby-lang.org wrote:Issue #11714 has been updated by Shugo Maeda.Status changed from Open to RejectedAntonio Terceiro wrote:> This seems to be a regression with Ruby 2.2 and beyond, I can still reproduce this in Ruby trunk from today. Ruby 2.1 works just fine.> > ~~~> $ cat /tmp/test.rb > module MyThing> class Date > end> end> include MyThing> > require 'date'It's not a regression.Even in Ruby 2.1, `include MyThing` affects date.rb, but it doesn't affect `Date` because ::Date is defined by RubyGems before inclusion of `MyThing`.You can see the same error in Ruby 2.1 by the option `--disable=gems`:```$ ruby --disable=gems test.rb```Without --disable=gems, you can see that `Date` is not affected by inclusion of `MyThing` even in test.rb:```module MyThing class Date endendinclude MyThingp Date #=> Date, not MyThing::Date```----------------------------------------Bug #11714: `include Module` affects scope of code loaded by require statements on Ruby 2.2+https://bugs.ruby-lang.org/issues/11714#change-55538* Author: Antonio Terceiro* Status: Rejected* Priority: Normal* Assignee: * ruby -v: ruby 2.3.0dev (2015-11-19 master 52671) [x86_64-linux]* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN----------------------------------------This seems to be a regression with Ruby 2.2 and beyond, I can still reproduce this in Ruby trunk from today. Ruby 2.1 works just fine.~~~$ cat /tmp/test.rb module MyThing class Date endendinclude MyThingrequire 'date'$ ruby2.1 /tmp/test.rb $ ruby2.2 /tmp/test.rb /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': superclass mismatch for class Date (TypeError) from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/lib/ruby/2.2.0/date.rb:3:in `' from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /tmp/test.rb:7:in `'[1]$ /var/tmp/ruby-trunk/bin/ruby /tmp/test.rb/var/tmp/ruby-trunk/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require': superclass mismatch for class Date (TypeError) from /var/tmp/ruby-trunk/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /var/tmp/ruby-trunk/lib/ruby/2.3.0/date.rb:3:in `' from /var/tmp/ruby-trunk/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /var/tmp/ruby-trunk/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /tmp/test.rb:7:in `'~~~-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72330] [Ruby trunk - Feature #10617] Change multiple assignment in conditional from parse error to warning — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 10, 2015 at 11:05:50 MST, alxtskrnk@gmail.com wrote:Issue #10617 has been updated by bug hit.Why hasn't this been accepted? There is no good reason that an expression that could be nil should not be testable.----------------------------------------Feature #10617: Change multiple assignment in conditional from parse error to warninghttps://bugs.ruby-lang.org/issues/10617#change-55449* Author: Recursive Madman* Status: Open* Priority: Normal* Assignee: ----------------------------------------There is currently an inconsistency between regular and multiple assignment in conditionals.Regular assignment causes a **warning**, multiple assignment causes a **parse error**.The historical reason for this is that in 1.8 multiple assignment would always return an Array, but since 1.9 it returns whatever the RHS evaluates to.**Examples:**```rubya, b = nil #=> nila, b = [] #=> [] (but a and b are both nil)a, b = 1,2 #=> [1, 2]```Since multiple assignment behavior has changed, it makes sense to remove the (artificial) parse error for multiple assignments.That makes it possible to test the return value of a method used for multiple assignment without having to use a temporary variable.**Example:**```ruby# CURRENTLY WORKING CODE:tmp = some_method_returning_array_or_nila, b = tmpif tmp # method returned an array (possibly empty)else # method returned nil.end# PROPOSED WORKING CODE:if(a, b = some_method_returning_array_or_nil) # method returned an array (possibly empty)else # method returned nilend```(the parenthesis are needed due to LALR limitations, as discussed in #10450)Attached is a patch that does the necessary change.---Files--------------------------------0001-turn-parse-error-on-multiple-assignment-into-warning.patch (752 Bytes)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72333] [Ruby trunk - Feature #11405] [Assigned] [PATCH] hash.c: minor speedups to int/fixnum keys — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 10, 2015 at 03:34:29 MST, mame@ruby-lang.org wrote:Issue #11405 has been updated by Yusuke Endoh.Status changed from Closed to AssignedAssignee set to Eric WongThis caused a lot of trivial hash conflicts of Fixnums that is >= 16384.~~~~$ ./miniruby -ve 'p 16384.hash; p 16385.hash'ruby 2.3.0dev (2015-12-10 master 52945) [x86_64-linux]11048010433492078001104801043349207800~~~~Other pairs:~~~~p [16386, 16387].map {|n| n.hash }.uniq #=> [2133837449075777600]p [16388, 16389].map {|n| n.hash }.uniq #=> [3903799135928350277]p [16390, 16391].map {|n| n.hash }.uniq #=> [-3836391686716480155]p [16392, 16393].map {|n| n.hash }.uniq #=> [1714559302010572050]p [16394, 16395].map {|n| n.hash }.uniq #=> [2147130354083423794]p [16396, 16397].map {|n| n.hash }.uniq #=> [-679539024000319657]p [16398, 16399].map {|n| n.hash }.uniq #=> [4056286416392832887]p [16400, 16401].map {|n| n.hash }.uniq #=> [2733766810351706956]p [16402, 16403].map {|n| n.hash }.uniq #=> [-1228876631044862612]p [16404, 16405].map {|n| n.hash }.uniq #=> [1418226818996216529]~~~~Unlike the name suggests, rb_objid_hash is also used to calculate a hash value of Fixnum.IMO, we must fix this issue before 2.3.0 release.-- Yusuke Endoh ----------------------------------------Feature #11405: [PATCH] hash.c: minor speedups to int/fixnum keyshttps://bugs.ruby-lang.org/issues/11405#change-55440* Author: Eric Wong* Status: Assigned* Priority: Normal* Assignee: Eric Wong----------------------------------------Noticed with [ruby-core:70159] [Bug #11396]The low bits of Ruby object IDs are rarely populated in the currentimplementation, so ensure the get used.Early versions of this patch redundantly shifted static symbols in`any_hash`, causing regressions with static symbols in `hash_aref_sym`* hash.c (any_hash): skip rb_objid_hash for static syms (rb_num_hash_start): extract from rb_ident_hash (rb_objid_hash): call rb_num_hash_start (rb_ident_hash): ditto~~~target 0: a (ruby 2.3.0dev (2015-07-30 trunk 51437) [x86_64-linux]target 1: b (ruby 2.3.0dev (2015-07-30 patch 51437) [x86_64-linux]benchmark results from Xeon E3-1230 v3 @ 3.30GHz (turbo disabled):minimum results in each 10 measurements.Execution time (sec)name a bhash_aref_dsym 0.316 0.300hash_aref_dsym_long 5.106 5.063hash_aref_fix 0.304 0.297hash_aref_flo 0.061 0.060hash_aref_miss 0.433 0.430hash_aref_str 0.408 0.396hash_aref_sym 0.312 0.306hash_aref_sym_long 0.482 0.469hash_flatten 0.385 0.273hash_ident_flo 0.036 0.037hash_ident_num 0.277 0.276hash_ident_obj 0.291 0.284hash_ident_str 0.289 0.286hash_ident_sym 0.285 0.281hash_keys 0.269 0.271hash_shift 0.020 0.016hash_values 0.264 0.264loop_whileloop2 0.101 0.099vm2_bighash* 3.066 2.972Speedup ratio: compare with the result of `a' (greater is better)name bhash_aref_dsym 1.052hash_aref_dsym_long 1.008hash_aref_fix 1.024hash_aref_flo 1.015hash_aref_miss 1.007hash_aref_str 1.031hash_aref_sym 1.018hash_aref_sym_long 1.027hash_flatten 1.410hash_ident_flo 0.994hash_ident_num 1.001hash_ident_obj 1.022hash_ident_str 1.012hash_ident_sym 1.016hash_keys 0.992hash_shift 1.237hash_values 1.001loop_whileloop2 1.013vm2_bighash* 1.032~~~I will commit in a few weeks if everyone is OK with this.---Files--------------------------------0001-hash.c-improve-integer-fixnum-hashing.patch (5.17 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72334] [Ruby trunk - Feature #11100] Permit multiple captures with String[Regexp, ...] — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 10, 2015 at 16:35:21 MST, djberg96@gmail.com wrote:Issue #11100 has been updated by Daniel Berger.I support allowing multiple captures. I think the [1,2] syntax is the most intuitive.----------------------------------------Feature #11100: Permit multiple captures with String[Regexp, ...]https://bugs.ruby-lang.org/issues/11100#change-55454* Author: D.E. Akers* Status: Open* Priority: Normal* Assignee: ----------------------------------------I propose that if we are able to conveniently grab one capture with this method, we ought to be able to grab more than one. Still, there are some caveats worth considering:* It should return an array, but every other `#[]` variant returns a string or `nil`.* Should the argument be an array, or should the method be variadic? - Array argument looks a little "noisy"? `'123abc'[/(\d+)(\w+)/, [2, 1]]` - Variadic method requires intrusive modification of internal calls to `rb_str_subpat()`.* Complementary `#[]=` would be crpytic, overly complex, and likely go unused, but not adding it would break the symmetry.I realize this is essentially an outline of why not to implement this feature, but I figured I'd toss it out there for feedback. Thoughts?---Files--------------------------------string_slice_many_captures.patch (906 Bytes)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72338] [Ruby trunk - Bug #10097] Case-insensitive Regexp matching for Windows-1252 not working for ŠšŽžŒœÿŸ — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 11, 2015 at 01:04:08 MST, duerst@it.aoyama.ac.jp wrote:Issue #10097 has been updated by Martin Dürst.Nobuyoshi Nakada wrote:> Is this correct?> https://github.com/nobu/ruby/compare/windows-1252Sorry for the very slow response. Please commit. Thanks!----------------------------------------Bug #10097: Case-insensitive Regexp matching for Windows-1252 not working for ŠšŽžŒœÿŸhttps://bugs.ruby-lang.org/issues/10097#change-55458* Author: Martin Dürst* Status: Open* Priority: Normal* Assignee: * ruby -v: 1.9.3p545* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN----------------------------------------By chance I had a look at enc/iso_8859_1.c and found~~~CENC_REPLICATE("Windows-1252", "ISO-8859-1")~~~on line 288. But this does not work for case folding:~~~ruby# http://en.wikipedia.org/wiki/Windows-1252s1 = "\u0160".encode 'windows-1252' # 'Š'r1 = Regexp.new("\u0161".encode('windows-1252'), Regexp::IGNORECASE) # /š/is1 =~ r1 # => nils2 = "\u0178".encode 'windows-1252' # 'Ÿ'r2 = Regexp.new("\u00FF".encode('windows-1252'), Regexp::IGNORECASE) # /ÿ/is2 =~ r2 # => nils3 = "\u00C0".encode 'windows-1252' # 'À'r3 = Regexp.new("\u00E0".encode('windows-1252'), Regexp::IGNORECASE) # /à/is3 =~ r3 # => 0~~~So case-insensitive matching works when both characters are in iso-8859-1, but not when one (ÿŸ) or both (ŠšŽžŒœ) characters are not in iso-8859-1.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72339] [Ruby trunk - Feature #11788] [Open] New ISeq serialize binary format — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 8, 2015 at 03:56:15 MST, ko1@atdot.net wrote:Issue #11788 has been reported by Koichi Sasada.----------------------------------------Feature #11788: New ISeq serialize binary formathttps://bugs.ruby-lang.org/issues/11788* Author: Koichi Sasada* Status: Open* Priority: Normal* Assignee: Koichi Sasada----------------------------------------# AbstractI wrote a new RubyVM::InstructionSequence (ISeq) object serializer and de-serializer binary format.Matz had approved to introduce this feature to Ruby 2.3 as *experimental* feature.So I'll commit them.There are two methods to serialize and de-serialize.* RubyVM::InstructionSequence#to_binary_format returns binary format data as String object.* RubyVM::InstructionSequence.from_binary_format(data) de-serialize it.The goal of this project is to provide "machine dependent" binary file to achieve:* fast bootstrap time for big applications* reduce memory consumption with several techniques"Machine dependent" means you can't migrate compiled binaries to other machines.They are not goals of this project:* packing scripts to one package* migrate obfuscate binary to other node to hide source codeTo achieve such goals, we need to consider compatibility issues such as `__FILE__`, `__dir__`, `DATA`, and so on (for example, consider about this code: `Dir.glob(File.join(__dir__, '*.rb')`).This proposal doesn't contain "how to store compiled binaries".For example, Rubinius makes *.rbc file automatically.However, Matz does not like such automatic compilation.So that my proposal only show user storage class interface.People can try to make your own ISeq binary storage.For example,* making a compiled binary files automatically in same directory of script files like Rubinius,* store compiled binaries in some DB* make storage data structure in your own.I wrote several samples:* dbm: use dbm* fs: [default] use file system. locate compiled file in same directory of script file like Rubinius. foo.rb.yarb will be created for foo.rb.* fs2: use file system. locate compiled file in specified directory.* nothing: do nothing.You can see my sample implementation:https://github.com/ko1/ruby/blob/iseq_p1/sample/iseq_loader.rbThe key interface is `RubyVM::InstructionSequence.load_iseq(fname)`.When MRI try to load any script named `fname`, then call this method with `fname` if defined.The return value is an ISeq object, then MRI use this ISeq object instead of parsing/compiling `fname` file.Note that this proposal is "experimental".These interfaces are only for experiments.For example, if we want to use several binary storage,this interface doesn't support multiple storage (lack of extensibility).# Current statusThe current implementation is not matured because the binary size is very big because pointer size consumes 32/64 bits.It is easy to reduce, but I remain this weak point.Now, one goal "reduction of memory consumption" is not achieved because no techniques are introduced to share/unload or something.This is future work.# EvaluationSeveral evaluation results:## resolv.rbTry to load resolv.rb 1,000 times (and remove Resolv class each time).```compile 12.360000 0.310000 12.670000 ( 13.413011)compile 12.120000 0.300000 12.420000 ( 13.195313)compile 12.230000 0.270000 12.500000 ( 13.242140)eager loadload 3.750000 0.180000 3.930000 ( 3.918169)load 4.000000 0.170000 4.170000 ( 4.178442)load 4.120000 0.200000 4.320000 ( 4.320233)lazy loadload 2.410000 0.090000 2.500000 ( 2.609716)load 2.280000 0.210000 2.490000 ( 2.518892)load 2.310000 0.110000 2.420000 ( 2.419687)```3.25 times faster than normal compilation.If we use lazy loading technique, it is 5.2 times faster.## fileutils.rbTry similar to resolv.rb.``` user system total realcompile 8.540000 0.130000 8.670000 ( 8.703615)compile 8.540000 0.150000 8.690000 ( 8.693870)compile 8.430000 0.120000 8.550000 ( 8.547480)eager loadload 4.470000 0.150000 4.620000 ( 4.659934)load 4.500000 0.140000 4.640000 ( 4.640365)load 4.610000 0.100000 4.710000 ( 4.708825)lazy loadload 3.510000 0.140000 3.650000 ( 3.694146)load 3.470000 0.130000 3.600000 ( 3.609040)load 3.550000 0.150000 3.700000 ( 3.831015)```Only 1.8 times faster (eager) and 2.4 times faster (lazy).This is because the initialization of FileUtils class run long time.It uses module_eval(str) to add methods.## Simple rails applicationrun `time rails r ''` on simple Rails application (https://github.com/ko1/tracer_demo_rails_app tracers are disabled).```compile:real 0m2.049suser 0m1.601ssys 0m0.402seager:real 0m1.544suser 0m1.094ssys 0m0.422slazy:$ time rails r ''real 0m1.536suser 0m1.112ssys 0m0.388s```Not so impressive result. It seems there are many initialization code.-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72340] [Ruby trunk - Feature #5478] import Set into core, add syntax — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 10, 2015 at 06:53:05 MST, alexey.muranov@gmail.com wrote:Issue #5478 has been updated by Alexey Muranov.Another syntax idea:```ruby{|1,2,3|}```----------------------------------------Feature #5478: import Set into core, add syntaxhttps://bugs.ruby-lang.org/issues/5478#change-55443* Author: Konstantin Haase* Status: Open* Priority: Normal* Assignee: ----------------------------------------=beginA set is a central data structure. However, a lot of Ruby developers use arrays for situations where it would be more reasonable to use a set. One reason for that is that it is way easier to use Array then Set at the moment, another one is that developers are simply not aware it exists.I propose moving Set from the stdlib to core and possibly add a syntax or a method on array for creating Set literals.First class syntax suggestions: # might be tricky to parse #[1, 2, 3] # would collide with comments $[1, 2, 3] ${1, 2, 3}Method suggestions: ~[1, 2, 3] +[1, 2, 3]Whitespace separated String Sets could look like this: %w # creates an array at the moment #w[foo bar blah] # would collide with comments $w[foo bar blah] # would collide with sending :[] to $w $w{foo bar blah} ~%w[foo bar blah] # not really shorter than using an array with strings +%w[foo bar balh] # not really shorter than using an array with stringsMaybe it's ok to not have a whitespace separated syntax, I'm just brainstorming here.The issue with the method approach is that it would create an Array to send the message to first.I favor the syntax, possibly without the ability to create a whitespace separated version.I'd be willing to work on a patch not only for MRI but also for JRuby and Rubinius if you would consider this to be useful.Although I would need help with the parser.=end-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72347] [Ruby trunk - Feature #11786] [Open] [PATCH] micro-optimize case dispatch even harder — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 7, 2015 at 20:36:29 MST, normalperson@yhbt.net wrote:Issue #11786 has been reported by Eric Wong.----------------------------------------Feature #11786: [PATCH] micro-optimize case dispatch even harderhttps://bugs.ruby-lang.org/issues/11786* Author: Eric Wong* Status: Open* Priority: Normal* Assignee: ----------------------------------------I noticed these optimizations while working on r52931.By using a bare hash table, we avoid the overhead of rb_hash_*functions as well as the cost of translating FIX2INT for jumplabels.This also reduces GC overhead, as the iseq mark array no longercarries redundant objects nor the Hash object.Summary speedup:loop_whileloop2 1.000vm2_case* 1.225vm2_case_lit* 1.000vm2_case_small* 1.162Passes all tests and specs, so probably safe to commit soon...Full results:2015-12-08 03:26:19 +0000target 0: a (ruby 2.3.0dev (2015-12-08 trunk 52932) [x86_64-linux]) at "/home/ew/rrrr/b/ruby"target 1: b (ruby 2.3.0dev (2015-12-08 master 52932) [x86_64-linux]last_commit=micro-optimize case dispatch even harder) at "/home/ew/ruby/b/ruby"-----------------------------------------------------------loop_whileloop2i = 0while i i += 1enda 0.10256672604009509a 0.10279557690955698a 0.10286601004190743a 0.10278227413073182a 0.10278794192709029b 0.10288732498884201b 0.10327051300555468b 0.1026718900538981b 0.10263488302007318b 0.10256404406391084-----------------------------------------------------------vm2_casei = 0while i case :foo when :bar raise when :baz raise when :boo raise when :foo i += 1 endenda 0.18099936190992594a 0.1836838680319488a 0.1825075231026858a 0.18087006197310984a 0.18375545786693692b 0.16652655508369207b 0.16673082998022437b 0.16754083498381078b 0.16704767406918108b 0.16648077592253685-----------------------------------------------------------vm2_case_liti = 0@ret = [ "foo", true, false, :sym, 6, nil, 0.1, 0xffffffffffffffff ]def foo(i) @ret[i % @ret.size]endwhile i case foo(i) when "foo" then :foo when true then true when false then false when :sym then :sym when 6 then :fix when nil then nil when 0.1 then :float when 0xffffffffffffffff then :big end i += 1enda 0.670805990928784a 0.6559841448906809a 0.6560367799829692a 0.655022048857063a 0.671947613125667b 0.659776204964146b 0.6549702121410519b 0.6788892599288374b 0.6793588208965957b 0.6878500080201775-----------------------------------------------------------vm2_case_smalli = 0while i case :foo when :foo i += 1 else raise endenda 0.1667630800511688a 0.16669297800399363a 0.1665362489875406a 0.16644068900495768a 0.16646360605955124b 0.15790433110669255b 0.15774213010445237b 0.15753646893426776b 0.15781028987839818b 0.15771835204213858Elapsed time: 11.069307098 (sec)-----------------------------------------------------------benchmark results:minimum results in each 5 measurements.Execution time (sec)name a bloop_whileloop2 0.103 0.103vm2_case* 0.078 0.064vm2_case_lit* 0.552 0.552vm2_case_small* 0.064 0.055---Files--------------------------------0001-micro-optimize-case-dispatch-even-harder.patch (9.34 KB)-- https://bugs.ruby-lang.org/

1 message 2015/12/18

[#72353] [Ruby trunk - Feature #11797] [Open] `Enumerator#with_object` with multiple objects — Joseph Jones <joeyi5216@...>

Joseph Jones liked your message with Boxer. On December 9, 2015 at 09:15:54 MST, sawadatsuyoshi@gmail.com wrote:Issue #11797 has been reported by Tsuyoshi Sawada.----------------------------------------Feature #11797: `Enumerator#with_object` with multiple objectshttps://bugs.ruby-lang.org/issues/11797* Author: Tsuyoshi Sawada* Status: Open* Priority: Normal* Assignee: ----------------------------------------Sometimes, when working with `Enumerator#with_object`, I want to keep some additional temporary objects besides the one to return. A use case is as follows (I got this from this StackOverflow question: http://stackoverflow.com/questions/3418123). Suppose I have an enumerator created from an array: e = ["a", "b", "c", "c", "a", "c"].to_enumand want to get an array of its repeated elements in the order they are repeated (i.e., appears for the second time): # => ["c", "a"]I can do it using `Enumerator#with_object` like this: e.to_enum.with_object([{}, []]){|c, (h, a)| h[c] ? a.push(c) : h.store(c, true)}.last.uniqHere, I am getting the array referred to as `a` in the block, but besides that, I am using a temporal hash `h`. I thought it would be nice if `Enumerator#with_object` accepts one or more objects, pass them individually as block arguments, and returns only the last argument so that I can do this: e.to_enum.with_object({}, []){|c, h, a| h[c] ? a.push(c) : h.store(c, true)}.uniq-- https://bugs.ruby-lang.org/

2 messages 2015/12/18

[ruby-core:72129] [Ruby trunk - Bug #11816] Partial safe navigation operator

From: matz@...
Date: 2015-12-15 04:25:53 UTC
List: ruby-core #72129
Issue #11816 has been updated by Yukihiro Matsumoto.


Marc,

We need more clarification. Did you mean all method calling dots should be interpreted as `&.`?
What about other calls like array/hash indexing or operators?

Matz.


----------------------------------------
Bug #11816: Partial safe navigation operator
https://bugs.ruby-lang.org/issues/11816#change-55540

* Author: Marc-Andre Lafortune
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* ruby -v: preview 2
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
I'm extremely surprised (and disappointed) that, currently:

    x = nil
    x&.foo.bar # => NoMethodError: undefined method `bar' for nil:NilClass

To make it safe, you have to write `x&.foo&.bar`. But if `foo` is never supposed to return `nil`, then that code isn't "fail early" in case it actually does. `nil&.foo.bar` is more expressive, simpler and is perfect if you want to an error if `foo` returned `nil`. To actually get what you want, you have to resort using the old form `x && x.foo.bar`...

In CoffeeScript, you can write `x()?.foo.bar` and it will work well, since it gets compiled to

    if ((_ref = x()) != null) {
      _ref.foo.bar;
    }

All the discussion in #11537 focuses on `x&.foo&.bar`, so I have to ask:

Matz, what is your understanding of `x&.foo.bar`?

I feel the current implementation is not useful and should be changed to what I had in mind. I can't see any legitimate use of `x&.foo.bar` currently.




-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next