Skip to content

Fix Segfault in SpoolDevice::~SpoolDevice()#535

Merged
arogge merged 3 commits intobareos:masterfrom
arogge:dev/arogge/master/fix-spool-segfault
Jun 9, 2020
Merged

Fix Segfault in SpoolDevice::~SpoolDevice()#535
arogge merged 3 commits intobareos:masterfrom
arogge:dev/arogge/master/fix-spool-segfault

Conversation

@arogge
Copy link
Member

@arogge arogge commented Jun 2, 2020

This series of patches adds a new systemtest that runs a backup with data spooling enabled to show a crash in that configuration. It also fixes the crash triggered by the systemtest.
Last, but not least, it fixes a deadlock in signalhandler that surfaced during testing.

arogge added 3 commits June 2, 2020 17:22
Previously the signal handler allocated memory by calling
GetPoolMemory() indirectly via the BErrNo ctor.
In case the signal handler was called while the mutex for pool memory
was locked, the result was a deadlock.
This patch removes the usage of BErrNo in favor of standard strerror()
which avoids GetPoolMemory() and in turn fixed the deadlock.
Near the end of DespoolData() rdev->dev_name and rdev->errmsg are freed.
However, the pointers are not set to nullptr, which leads to a
double-free when the dtor runs.
This patch removes the FreeMemory()/FreePoolMemory() calls and leaves
cleaning to the dtor alone.
@arogge arogge requested review from franku and pstorz June 2, 2020 15:31
Copy link
Contributor

@franku franku 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, ran systemtest successful on my laptop.
Thanks you found that!

@arogge arogge merged commit 0ec2c5b into bareos:master Jun 9, 2020
@arogge arogge deleted the dev/arogge/master/fix-spool-segfault branch August 10, 2020 08:11
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