Skip to content

ares_gethostbyname Appears to Leak from an 'ares_strdup' at the Conclusion of a Successful Query #439

@gerickson

Description

@gerickson

When invoking ares_gethostbyname for a forward DNS name-to-address lookup, there seems to be a leak from ares_strdup, as reported by the clang/LLVM address sanitizer:

Making check in examples
Making check in CFHost
make  CFHostExample
  CCLD     CFHostExample
/bin/bash ../../libtool --mode execute ./CFHostExample
Asynchronous lookups...
By name 'localhost' (Forward DNS)...
    Resolved names:
        0: localhost
    Resolved addresses:
        0: ::1
        1: 127.0.0.1

=================================================================
==1551143==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0x7fac81a14bc8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x7fac81325487 in ares_strdup (/usr/local/lib/libcares.so.2+0x10487)

This was/is demonstrated against c-ares-1.18.1 using https://github.com/gerickson/opencfnetwork/blob/user/gerickson/github-issue-8-forward-dns-deadlock/third_party/CFNetwork/repo/Host/CFHost.c#L2770 along with the example application https://github.com/gerickson/opencfnetwork/blob/user/gerickson/github-issue-8-forward-dns-deadlock/examples/CFHost/CFHostExample.c.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions