[pacman-dev] [PATCH] lock file may be left behind when a signal arrives while in cleanup
When a SIGINT or SIGHUP arrives before alpm_unlock (in alpm_release) but after remove_soft_interrupt_handler, the lock file will be left behind. Signed-off-by: lilydjwg <lilydjwg@gmail.com> --- src/pacman/pacman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index fefd3fa4..2d2e41d2 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -287,7 +287,6 @@ static void setuseragent(void) */ static void cleanup(int ret) { - remove_soft_interrupt_handler(); if(config) { /* free alpm library resources */ if(config->handle && alpm_release(config->handle) == -1) { @@ -297,6 +296,7 @@ static void cleanup(int ret) config_free(config); config = NULL; } + remove_soft_interrupt_handler(); /* free memory */ FREELIST(pm_targets); -- 2.28.0
On 08/12/20 at 01:36pm, lilydjwg wrote:
When a SIGINT or SIGHUP arrives before alpm_unlock (in alpm_release) but after remove_soft_interrupt_handler, the lock file will be left behind.
Signed-off-by: lilydjwg <lilydjwg@gmail.com> --- src/pacman/pacman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index fefd3fa4..2d2e41d2 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -287,7 +287,6 @@ static void setuseragent(void) */ static void cleanup(int ret) { - remove_soft_interrupt_handler(); if(config) { /* free alpm library resources */ if(config->handle && alpm_release(config->handle) == -1) { @@ -297,6 +296,7 @@ static void cleanup(int ret) config_free(config); config = NULL; }
The signal handler uses config->handle; this will segfault if a signal arrives between alpm_release and here.
+ remove_soft_interrupt_handler();
/* free memory */ FREELIST(pm_targets); -- 2.28.0
When a SIGINT or SIGHUP arrives before alpm_unlock (in alpm_release) but after remove_soft_interrupt_handler, the lock file will be left behind. Signed-off-by: lilydjwg <lilydjwg@gmail.com> --- Oops, here is an updated version that calls _alpm_handle_unlock before remove_soft_interrupt_handler. It should be fine to call _alpm_handle_unlock twice. src/pacman/pacman.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index fefd3fa4..8928ccc4 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -287,6 +287,9 @@ static void setuseragent(void) */ static void cleanup(int ret) { + if(config) { + _alpm_handle_unlock(config->handle); + } remove_soft_interrupt_handler(); if(config) { /* free alpm library resources */ -- 2.28.0
Hi there, Is there anything remaining I could do to get this merged? Yesterday we had a dangling db.lck again when a member lost his connection to the server while running devtools. On Wed, Aug 12, 2020 at 11:17:49PM +0800, lilydjwg wrote:
When a SIGINT or SIGHUP arrives before alpm_unlock (in alpm_release) but after remove_soft_interrupt_handler, the lock file will be left behind.
Signed-off-by: lilydjwg <lilydjwg@gmail.com> ---
Oops, here is an updated version that calls _alpm_handle_unlock before remove_soft_interrupt_handler. It should be fine to call _alpm_handle_unlock twice.
src/pacman/pacman.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index fefd3fa4..8928ccc4 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -287,6 +287,9 @@ static void setuseragent(void) */ static void cleanup(int ret) { + if(config) { + _alpm_handle_unlock(config->handle); + } remove_soft_interrupt_handler(); if(config) { /* free alpm library resources */ -- 2.28.0
-- Best regards, lilydjwg
On 12/02/20 at 08:02pm, lilydjwg wrote:
Hi there,
Is there anything remaining I could do to get this merged? Yesterday we had a dangling db.lck again when a member lost his connection to the server while running devtools.
On Wed, Aug 12, 2020 at 11:17:49PM +0800, lilydjwg wrote:
When a SIGINT or SIGHUP arrives before alpm_unlock (in alpm_release) but after remove_soft_interrupt_handler, the lock file will be left behind.
Signed-off-by: lilydjwg <lilydjwg@gmail.com> ---
Oops, here is an updated version that calls _alpm_handle_unlock before remove_soft_interrupt_handler. It should be fine to call _alpm_handle_unlock twice.
src/pacman/pacman.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index fefd3fa4..8928ccc4 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -287,6 +287,9 @@ static void setuseragent(void) */ static void cleanup(int ret) { + if(config) { + _alpm_handle_unlock(config->handle); + } remove_soft_interrupt_handler(); if(config) { /* free alpm library resources */
_alpm_handle_unlock is a private function not exposed to front-ends.
participants (2)
-
Andrew Gregory
-
lilydjwg