Skip to content

[Bug #19835] [Bug #19836] Fix memory leaks in parser#8192

Merged
peterzhu2118 merged 2 commits intoruby:masterfrom
peterzhu2118:parser-incomplete-mem-leak
Aug 9, 2023
Merged

[Bug #19835] [Bug #19836] Fix memory leaks in parser#8192
peterzhu2118 merged 2 commits intoruby:masterfrom
peterzhu2118:parser-incomplete-mem-leak

Conversation

@peterzhu2118
Copy link
Copy Markdown
Member

@peterzhu2118 peterzhu2118 commented Aug 9, 2023

See commit messages for details.

Copy link
Copy Markdown
Contributor

@kddnewton kddnewton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

[Bug #19835]

The parser does not free the `tbl` of the `struct vtable` when there are
leftover `lvtbl` in the parser. This causes a memory leak.

The following script reproduces this issue:

```
10.times do
  100_000.times do
    Ripper.parse("class Foo")
  end

  puts `ps -o rss= -p #{$$}`
end
```
[Bug #19836]

The parser does not free the chain of `struct vtable`, which causes
memory leaks.

The following script reproduces this issue:

```
10.times do
  100_000.times do
    Ripper.parse("-> {")
  end

  puts `ps -o rss= -p #{$$}`
end
```
@peterzhu2118 peterzhu2118 changed the title [Bug #19835] Fix memory leak in parser for incomplete tokens [Bug #19835] [Bug #19836] Fix memory leaks in parser Aug 9, 2023
@peterzhu2118 peterzhu2118 force-pushed the parser-incomplete-mem-leak branch from 1aeee1c to e8d9655 Compare August 9, 2023 16:23
@peterzhu2118 peterzhu2118 merged commit 0b8f155 into ruby:master Aug 9, 2023
@peterzhu2118 peterzhu2118 deleted the parser-incomplete-mem-leak branch August 9, 2023 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants