Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug / leak in JS function processors #12600

Merged

Conversation

andrewkroh
Copy link
Member

In an effort to minimize allocations a slice used to hold function arguments is reused rather than allocation new each time a Javascript function processor is used. However there was a typo in re-slicing code so instead of reseting the length to 0 it was a no-op. Hence all future invocations appended to the slice causing a leak. This affects code that uses native Javascript functions in a processor chain (e.g. new process.Chain().Add(function(event) { event.Put("x", "y"); }).Build()).

@andrewkroh andrewkroh added bug review needs_backport PR is waiting to be backported to other branches. :Processors labels Jun 18, 2019
@andrewkroh andrewkroh requested a review from a team as a code owner June 18, 2019 14:35
In an effort to minimize allocations a slice used to hold function arguments is reused rather than allocation new each time a Javascript function processor is used. However there was a typo in re-slicing code so instead of reseting the length to 0 it was a no-op. Hence all future invocations appended to the slice causing a leak. This affects code that uses native Javascript functions in a processor chain (e.g. `new process.Chain().Add(function(event) { event.Put("x", "y"); }).Build()`).
@andrewkroh andrewkroh force-pushed the bugfix/libbeat/js-processor-leak branch from a27995a to e869272 Compare June 18, 2019 14:35
@andrewkroh andrewkroh requested a review from a team June 18, 2019 14:47
@andrewkroh andrewkroh merged commit eb06c9a into elastic:master Jun 18, 2019
@andrewkroh andrewkroh added v7.2.0 and removed needs_backport PR is waiting to be backported to other branches. labels Jun 18, 2019
andrewkroh added a commit to andrewkroh/beats that referenced this pull request Jun 18, 2019
In an effort to minimize allocations a slice used to hold function arguments is reused rather than allocation new each time a Javascript function processor is used. However there was a typo in re-slicing code so instead of reseting the length to 0 it was a no-op. Hence all future invocations appended to the slice causing a leak. This affects code that uses native Javascript functions in a processor chain (e.g. `new process.Chain().Add(function(event) { event.Put("x", "y"); }).Build()`).

(cherry picked from commit eb06c9a)
andrewkroh added a commit that referenced this pull request Jun 18, 2019
In an effort to minimize allocations a slice used to hold function arguments is reused rather than allocation new each time a Javascript function processor is used. However there was a typo in re-slicing code so instead of reseting the length to 0 it was a no-op. Hence all future invocations appended to the slice causing a leak. This affects code that uses native Javascript functions in a processor chain (e.g. `new process.Chain().Add(function(event) { event.Put("x", "y"); }).Build()`).

(cherry picked from commit eb06c9a)
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
In an effort to minimize allocations a slice used to hold function arguments is reused rather than allocation new each time a Javascript function processor is used. However there was a typo in re-slicing code so instead of reseting the length to 0 it was a no-op. Hence all future invocations appended to the slice causing a leak. This affects code that uses native Javascript functions in a processor chain (e.g. `new process.Chain().Add(function(event) { event.Put("x", "y"); }).Build()`).

(cherry picked from commit f69330a)
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.

2 participants