[#114774] [Ruby master Feature#19884] Make Safe Navigation Operator work on classes — "p8 (Petrik de Heus) via ruby-core" <ruby-core@...>
Issue #19884 has been reported by p8 (Petrik de Heus).
13 messages
2023/09/15
[ruby-core:114849] [Ruby master Bug#19895] Memory leak in Ripper#sexp_raw called with invalid syntax
From:
"jemmai (Jemma Issroff) via ruby-core" <ruby-core@...>
Date:
2023-09-20 18:10:08 UTC
List:
ruby-core #114849
Issue #19895 has been updated by jemmai (Jemma Issroff).
Status changed from Open to Closed
Duplicate of [#19835]
----------------------------------------
Bug #19895: Memory leak in Ripper#sexp_raw called with invalid syntax
https://bugs.ruby-lang.org/issues/19895#change-104694
* Author: jemmai (Jemma Issroff)
* Status: Closed
* Priority: Normal
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
There is a memory leak in `Ripper#sexp_raw` with invalid syntax
I used [the ruby_memcheck gem](https://github.com/Shopify/ruby_memcheck) to find this leak.
# Script to reproduce:
```
$ ruby_memcheck -e 'require "ripper"; Ripper.sexp_raw("break 1,;")'
```
# Stack trace
```
64 bytes in 1 blocks are definitely lost in loss record 8,335 of 11,879
malloc (at /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
objspace_xmalloc0 (gc.c:11465)
*vtable_alloc_gen (ripper.y:6209)
*local_push.constprop.0 (ripper.y:12587)
*ripper_yyparse (ripper.y:1329)
*ripper_parse0 (ripper.y:13817)
rb_ensure (eval.c:997)
*ripper_parse (ripper.y:13855)
vm_call_cfunc_with_frame (vm_insnhelper.c:3037)
vm_sendish (vm_insnhelper.c:4751)
vm_exec_core (insns.def:778)
rb_vm_exec (vm.c:2220)
rb_ec_exec_node (eval.c:280)
ruby_run_node (eval.c:321)
main (main.c:47)
88 (24 direct, 64 indirect) bytes in 1 blocks are definitely lost in loss record 8,508 of 11,879
malloc (at /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
objspace_xmalloc0 (gc.c:11465)
*vtable_alloc_gen (ripper.y:6206)
*local_push.constprop.0 (ripper.y:12586)
*ripper_yyparse (ripper.y:1329)
*ripper_parse0 (ripper.y:13817)
rb_ensure (eval.c:997)
*ripper_parse (ripper.y:13855)
vm_call_cfunc_with_frame (vm_insnhelper.c:3037)
vm_sendish (vm_insnhelper.c:4751)
vm_exec_core (insns.def:778)
rb_vm_exec (vm.c:2220)
rb_ec_exec_node (eval.c:280)
ruby_run_node (eval.c:321)
main (main.c:47)
Valgrind reported errors (e.g. memory leak or use-after-free) (RuntimeError)
```
# Expected behavior
The [`Ripper#sexp_raw` docs](https://docs.ruby-lang.org/en/master/Ripper.html#method-c-sexp_raw) state that "By default, this method does not handle syntax errors in src, returning nil in such cases." Expected behavior, according to the documentation, would be `nil` returned without any memory leak
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/