From: "jeremyevans0 (Jeremy Evans)" Date: 2013-03-08T02:02:06+09:00 Subject: [ruby-core:53197] [ruby-trunk - Feature #7791] Let symbols be garbage collected Issue #7791 has been updated by jeremyevans0 (Jeremy Evans). rosenfeld (Rodrigo Rosenfeld Rosas) wrote: > Jeremy, I don't understand how #to_existing_sym could avoid the issue. Take your gem "sequel" for instance. In my application there is a class that will generate dynamic queries based on the user params. Sequel will always convert those dynamic column alias (like "v786") to symbols. Those symbols won't exist when the application boots. If Sequel used #to_existing_sym for creating the symbol it would raise since that symbol wouldn't exist. I wouldn't use #to_existing_sym for identifiers returned from databases. It is assumed that there is a fixed number that will be used, and allowing user-controlled identifiers can be a security issue. If your identifiers are based on user params, and you aren't validating them, you currently have denial of service at the least and possible SQL injection depending on the adapter in use. There are other cases in Sequel where #to_existing_sym would might make sense using, though (connection string options, JSON/XML deserialization). ---------------------------------------- Feature #7791: Let symbols be garbage collected https://bugs.ruby-lang.org/issues/7791#change-37365 Author: rosenfeld (Rodrigo Rosenfeld Rosas) Status: Feedback Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: next minor Lots of Denial-of-Service security vulnerabilities exploited in Ruby programs rely on symbols not being collected by garbage collector. Ideally I'd prefer symbols and strings to behave exactly the same being just alternate ways of writing strings but I'll let this to another ticket. This one simply asks for symbols to be allowed to be garbage collected when low on memory. Maybe one could set up some up-limit memory constraints dedicated to storing symbols. That way, the most accessed symbols would remain in that memory region and the least used ones would be reclaimed when the memory for symbols is over and a new symbol is created. Or you could just allow symbols to be garbage collected any time. Any reasons why this would be a bad idea? Any performance benchmark demonstrating how using symbols instead of strings would make a real-world software perform much better? Currently I only see symbols slowing down processing because people don't want to worry about it and will often use something like ActiveSupport Hash#with_indifferent_access or some other method to convert a string to symbol or vice versa... -- http://bugs.ruby-lang.org/