Issue #10735 has been updated by Viktor Vasilev.


Zachary Scott wrote:
> I know you tried this with 1.9.3, but could you try to repro on trunk (and newer rubies) first?
> 
> 1.9.3 will be EOL soon, and I want to make sure we fix it upstream before attempting any backports

Hi Zachary,

Just ran the test case against Ruby 2.3.0dev (2015-01-12 trunk 49226) [x86_64-darwin14] and see the exact same memory leak:

~~~
{:count=>7, :heap_allocated_pages=>74, :heap_sorted_length=>75, :heap_allocatable_pages=>0, :heap_available_slots=>30161, :heap_live_slots=>29720, :heap_free_slots=>441, :heap_final_slots=>0, :heap_marked_slots=>11592, :heap_swept_slots=>10966, :heap_eden_pages=>74, :heap_tomb_pages=>0, :total_allocated_pages=>74, :total_freed_pages=>0, :total_allocated_objects=>91749, :total_freed_objects=>62029, :malloc_increase_bytes=>530256, :malloc_increase_bytes_limit=>16777216, :minor_gc_count=>5, :major_gc_count=>2, :remembered_wb_unprotected_objects=>180, :remembered_wb_unprotected_objects_limit=>278, :old_objects=>10540, :old_objects_limit=>10818, :oldmalloc_increase_bytes=>1808128, :oldmalloc_increase_bytes_limit=>16777216}
Memory 11736KB
~~~

<< 100_000 iterations of RSA sign >>

~~~
{:count=>25, :heap_allocated_pages=>74, :heap_sorted_length=>75, :heap_allocatable_pages=>0, :heap_available_slots=>30161, :heap_live_slots=>30108, :heap_free_slots=>53, :heap_final_slots=>0, :heap_marked_slots=>13570, :heap_swept_slots=>11362, :heap_eden_pages=>74, :heap_tomb_pages=>0, :total_allocated_pages=>74, :total_freed_pages=>0, :total_allocated_objects=>392910, :total_freed_objects=>362802, :malloc_increase_bytes=>15616, :malloc_increase_bytes_limit=>16777216, :minor_gc_count=>22, :major_gc_count=>3, :remembered_wb_unprotected_objects=>298, :remembered_wb_unprotected_objects_limit=>596, :old_objects=>13151, :old_objects_limit=>26046, :oldmalloc_increase_bytes=>39904, :oldmalloc_increase_bytes_limit=>16777216}
Memory 26244KB
~~~

Let me know if I can provide further information.

----------------------------------------
Bug #10735: Memory leak in openssl ossl_pkey_sign
https://bugs.ruby-lang.org/issues/10735#change-50969

* Author: Viktor Vasilev
* Status: Assigned
* Priority: Normal
* Assignee: openssl
* ruby -v: ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Similar to the memory leak fixed in https://bugs.ruby-lang.org/issues/9743 there is an issue with ossl_pkey_sign. The ruby heap usage reported through GC.stat remains very stable, while the process heap grows linearly with the number of OpenSSL::PKey::RSA sign calls. 
The documentation at https://www.openssl.org/docs/crypto/EVP_SignInit.html (similar to EVP_VerifyInit) mentions that not disposing the context causes a leak.

To reproduce: https://gist.github.com/viktorium/f032cdc8906f43dac94e
A patch with a fix very similar to issue #9743: https://gist.github.com/viktorium/b466b72c83d2ab90182c



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