Skip to content

Fix HTTPInfo::unmarshal function memory leak by call ats_malloc. - #4872

Closed
WolfgangBai wants to merge 1 commit into
apache:masterfrom
WolfgangBai:master
Closed

WolfgangBai wants to merge 1 commit into
apache:masterfrom
WolfgangBai:master

Conversation

@WolfgangBai

Copy link
Copy Markdown
Contributor

about Issue 2436 #2436. @SolidWallOfCode

@oknet

oknet commented Jan 26, 2019

Copy link
Copy Markdown
Member

[approve ci]

@oknet oknet added this to the 9.0.0 milestone Jan 26, 2019
@scw00

scw00 commented Jan 26, 2019 •

Copy link
Copy Markdown
Member

I'm wondering if we clean that copy of frag_table, What should we do with the HttpTransaction::State::object_read and the raw data in RamCache.

@scw00

scw00 commented Jan 26, 2019 •

Copy link
Copy Markdown
Member

There are several scenarios that I am worried about:

  • Some reader might already got the alternate in ram cache before writer call updateVector. So read might crash when it tries to access fragments_table.
  • object_read is still valid for HttpSM after writer call updateVector.
  • RamCache should also release fragments_table.

Not sure here, but need more eyes.

@scw00

scw00 commented Jan 28, 2019

Copy link
Copy Markdown
Member

I push another fixes to refactor the m_frag_offsets marshaling.

@SolidWallOfCode

Copy link
Copy Markdown
Member

The fragment table should be cleaned up in HttpCacheAlt::destroy when the instance is put on the proxy allocator free list. Is there any evidence that is not happening?

@WolfgangBai

Copy link
Copy Markdown
Contributor Author

tim 20190128221315
yes, you can see unmarshal_helper.it is not have a HTTPInfo instance when it was called.

@SolidWallOfCode

Copy link
Copy Markdown
Member

Interesting. However, that's an error case. It seems to be the better approach would be to change unmarshal_helper to clean up the fragment table at that moment, rather than making a more complex change elsewhere which might have unanticipated side effects. Or, alternatively, change HTTPINfo::unmarshal to not allocate the fragment table until the URL and MIME heaps have been successfully unpacked.

@WolfgangBai

Copy link
Copy Markdown
Contributor Author

first of all.this problem from https://github.com/apache/trafficserver/commit/84fa7a4d7123c86e6debc42bac2684945769bb3c.if it is ture,it will influences all above 3.3.1.
besides, I generally agree with your two ideas. first idea, because HTTPCacheAlt::copy_frag_offsets_from function use that ats_malloc memory, so i free in a new function HTTPCacheAlt::copy_frag_offsets_from_and_free. second idea is https://github.com/apache/trafficserver/pull/4874
finally,No matter pick which solution, I just hope that the problem can be paid attention to and solved. I hope that trafficserver will become better and better.

@zwoop

zwoop commented Feb 13, 2019

Copy link
Copy Markdown
Contributor

Can we close this now that we landed scw00s fix? We don’t need both, right? And thanks for the work and PR!

@WolfgangBai

Copy link
Copy Markdown
Contributor Author

sure,you can!

@zwoop zwoop removed this from the 9.0.0 milestone Mar 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants