summaryrefslogtreecommitdiff
path: root/tool/ruby_vm/views/_insn_len_info.erb
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2024-04-30 17:22:04 -0400
committerPeter Zhu <peter@peterzhu.ca>2024-05-01 08:54:45 -0400
commitd1f14bafb06862e4095aea4598c7625368f6af24 (patch)
treea9fef8ef37aa2d63c8bb34905525282fe5209b47 /tool/ruby_vm/views/_insn_len_info.erb
parent57eca0a80dbe5d829108d9a7f46123eb80cd3254 (diff)
Fix leak reported by Valgrind when setting environment variables
The call to setenv replaces the string in the environ array, which causes the original string to be reported as a memory leak. This commit allocates another copy of environ called alloc_environ that contains the strings allocated by ruby_init_setproctitle. Then in ruby_free_proctitle it frees all the strings in alloc_environ. For example: ENV.each { |k, v| ENV[k] = v.dup } Valgrind reports: 3,321 bytes in 39 blocks are definitely lost in loss record 3 of 3 at 0x484884F: malloc (vg_replace_malloc.c:393) by 0x25CB5B: objspace_xmalloc0 (gc.c:11972) by 0x40344E: ruby_strdup (util.c:540) by 0x59C854: ruby_init_setproctitle (setproctitle.c:143) by 0x38CC44: ruby_process_options (ruby.c:3101) by 0x234DB1: ruby_options (eval.c:117) by 0x15B92E: rb_main (main.c:40) by 0x15B92E: main (main.c:59)
Diffstat (limited to 'tool/ruby_vm/views/_insn_len_info.erb')
0 files changed, 0 insertions, 0 deletions