Skip to content

lsof 4.99.7 aborts with a double free during a TCP port lookup on Linux #413

Open

Description

@e1i3or-commits

On Arch Linux x86_64, lsof -ti tcp:4193,4194 exited with SIGABRT. The installed packages were lsof 4.99.7-1 and glibc 2.44+r50+g1848099f063e-1.

The core recorded free(): double free detected in tcache 2. The first lsof frame was lsof+0x11b7a, immediately after a call to free(). The executable’s build ID was 84ad5d98579940acdcbf405b24c7841953eb805e.

I observed the crash once. Querying the two ports individually afterward returned no matches and exited normally. I haven’t confirmed whether the combined port filter triggers it consistently.

Activity

  1. hja-oss commented on Nov 22, 2026

    @hja-oss
    Contributor

    As information, in 4.99.7, the two port selections share the same "tcp" protocol string, but cleanup frees that string once for each selection. PR #371 gives each selection its own copy, so cleanup no longer frees the same allocation twice.

    This way, seems this double free was fixed by PR #371, which is included in master but not in 4.99.7.

    I have verified it with a regression test hja-oss@0839f3e for lsof -ti tcp:4193,4194: 4.99.7 aborts with an AddressSanitizer double free in lsof_destroy(), while current master passes.

    Please try building from master, or backport #371.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions