Skip to content

Commit

Permalink
Add leak detection during server termination
Browse files Browse the repository at this point in the history
Memory leak detection may occur when working with the server:

    g.test_foo = function()
        ...
        g.server:exec(function()
            -- there is an error in `stderr` here
        end)
        g.server:exec(function()
           -- server is alive
        end)
        t.assert(true)
    end)

    g.after_all(function()
        g.server:drop() -- `test_foo` has been passed
    end)

We have added a check of the `stderr` from the server for the presence
of the `LeakSanitizer` substring. If it's found, an error will be caused
(test will be failed).

Closes #349
  • Loading branch information
Oleg Chaplashkin committed Mar 14, 2024
1 parent f8a1c10 commit 1de9aa7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- Add logging to unified file (gh-324).
- Add memory leak detection during server termination (gh-349).

## 1.0.1

Expand Down
11 changes: 11 additions & 0 deletions luatest/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,17 @@ function Server:stop()
)
)
end
if self.process.output_beautifier.stderr:find('LeakSanitizer') then
error(
('Memory leak during process termination (alias: %s, workdir: %s, pid: %s)\n%s')
:format(
self.alias,
fio.basename(self.workdir),
self.process.pid,
self.process.output_beautifier.stderr
)
)
end
log.debug('Killed server process PID ' .. self.process.pid)
self.process = nil
end
Expand Down

0 comments on commit 1de9aa7

Please sign in to comment.