Project

General

Profile

Bug #1171

lttng_ust_delete_fd_from_tracker: Assertion failure

Added by Stefan Palade 7 months ago. Updated 5 months ago.

Status:
Resolved
Priority:
Normal
Target version:
Start date:
11/14/2018
Due date:
% Done:

100%

Estimated time:

Description

$> ./lttng_ust_elf_test
..lttng_ust_delete_fd_from_tracker: Assertion `IS_FD_SET(fd, lttng_fd_set)' failed.
Aborted

It seems to be introduced in 2.9.3 and 2.10.1 ( http://git.lttng.org/?p=lttng-ust.git;a=commit;h=0dd6b494078f56264600e17d93e6c980f8bc36ba )

ANALYSIS:
It seems the file descriptor is initialized to 0 in lttng_ust_elf_create() and later on it is trying to clean up in error path when the file ("/home/..... (deleted)") can not be opened. Not really sure how it can be triggered from application, but the executable have of some reason been deleted at the time it tries to read ELF info.

Please see the attached test program for triggering.
We have a fix proposal but I'm inclined to see your opinion on root cause maybe these a deeper reason why this happens.


Files

lttng_ust_elf_test.c (1.05 KB) lttng_ust_elf_test.c Stefan Palade, 11/14/2018 01:35 PM

Associated revisions

Revision 1ac2e79c (diff)
Added by Jonathan Rajotte Julien 5 months ago

Fix: Initialize fd field of struct lttng_ust_elf to -1 at allocation

In rare cases when the executable cannot be open, using a default value
of zero lead to invalid close call and fd tracker removal.

fixes #1171

Reported-by: Stefan Palade <>
Signed-off-by: Jonathan Rajotte <>
Signed-off-by: Mathieu Desnoyers <>

History

#1

Updated by Jonathan Rajotte Julien 7 months ago

  • Status changed from New to Confirmed
  • Assignee set to Jonathan Rajotte Julien

Hi Stefan,

I'm looking into it. I was able to reproduce the problem.

In the mean time could you share with us your potential fix?

Thanks

#3

Updated by Jonathan Rajotte Julien 7 months ago

  • Status changed from Confirmed to Needs feedback
#4

Updated by Stefan Palade 7 months ago

Jonathan Rajotte Julien wrote:

Hi Stefan,

I'm looking into it. I was able to reproduce the problem.

In the mean time could you share with us your potential fix?

Thanks

The fix on our side was the same as your proposal.

--- a/liblttng-ust/lttng-ust-elf.c
++ b/liblttng-ust/lttng-ust-elf.c
@ -249,7 +249,7 @ struct lttng_ust_elf *lttng_ust_elf_create(const char *path)
if (!elf) {
goto error;
}

elf>fd = -1;

elf->path = strdup(path);
if (!elf->path) {
#5

Updated by Stefan Palade 7 months ago

Stefan Palade wrote:

Jonathan Rajotte Julien wrote:

Hi Stefan,

I'm looking into it. I was able to reproduce the problem.

In the mean time could you share with us your potential fix?

Thanks

The fix on our side was the same as your proposal.

 --- a/liblttng-ust/lttng-ust-elf.c
 +++ b/liblttng-ust/lttng-ust-elf.c
 @@ -249,7 +249,7 @@ struct lttng_ust_elf *lttng_ust_elf_create(const char *path)
      if (!elf) {
          goto error;
      }
 -
 +    elf->fd = -1;

      elf->path = strdup(path);
      if (!elf->path) {
#6

Updated by Jonathan Rajotte Julien 5 months ago

  • Status changed from Needs feedback to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF