Skip to content

getaddrinfo is thread-safe on NetBSD and OpenBSD #70594

Closed

Description

@ajdavis
BPO 26406
Nosy @gvanrossum, @ronaldoussoren, @ned-deily, @vadmium, @1st1, @ajdavis
Files
  • 26406-getaddrinfo-netbsd-openbsd.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-02-23.11:15:30.882>
    created_at = <Date 2016-02-22.03:33:13.111>
    labels = []
    title = 'getaddrinfo is thread-safe on NetBSD and OpenBSD'
    updated_at = <Date 2016-02-23.13:27:11.007>
    user = 'https://github.com/ajdavis'

    bugs.python.org fields:

    activity = <Date 2016-02-23.13:27:11.007>
    actor = 'emptysquare'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-02-23.11:15:30.882>
    closer = 'ned.deily'
    components = []
    creation = <Date 2016-02-22.03:33:13.111>
    creator = 'emptysquare'
    dependencies = []
    files = ['41998']
    hgrepos = []
    issue_num = 26406
    keywords = ['patch']
    message_count = 5.0
    messages = ['260655', '260657', '260726', '260727', '260730']
    nosy_count = 7.0
    nosy_names = ['gvanrossum', 'ronaldoussoren', 'ned.deily', 'python-dev', 'martin.panter', 'yselivanov', 'emptysquare']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue26406'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    Activity

    1. ajdavis commented on Feb 22, 2016

      @ajdavis
      ContributorAuthor

      In socketmodule.c we lock around getaddrinfo calls on platforms where getaddrinfo is believed not to be thread-safe. We've verified that it *is* thread-safe, and therefore stopped locking around it, on FreeBSD 5.3+ (bpo-1288833) and Mac OS X 10.5+ (bpo-25924). This ticket intends to do the same for OpenBSD and NetBSD.

      OpenBSD 5.4 fixed getaddrinfo's thread safety and announced it 2013-11-01, "getaddrinfo(3) is now thread-safe":

      http://www.openbsd.org/plus54.html

      NetBSD's fix is older and less publicized. Since ancient times NetBSD's getaddrinfo.c included a comment, "Thread safe-ness must be checked", and the getaddrinfo(3) man page had the same warning as other BSDs, "The implementation of getaddrinfo is not thread-safe." On 2004-05-27 Christos Zoulas committed with the comment "make yp stuff re-entrant", fixing obvious problems like static variables in getaddrinfo:

      http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.c.diff?r1=1.71&r2=1.72&only_with_tag=MAIN

      That change was released with NetBSD 3.0, and that alone might convince us to stop locking around getaddrinfo. Later, on 2006-07-18, between NetBSD 3 and 4, Zoulas deleted the comment "Thread safe-ness must be checked" from the source, with the message "Remove comments that do not reflect reality anymore":

      http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.c.diff?r1=1.82&r2=1.83&only_with_tag=MAIN

      The same day, he removed the man page warning:

      http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.3.diff?r1=1.43&r2=1.44&only_with_tag=MAIN

      NetBSD 4.0 was released 2007-12-19.

    2. ajdavis commented on Feb 22, 2016

      @ajdavis
      ContributorAuthor

      Patch uploaded.

      I've copied the "nosy" list from bpo-25924, if that was bad etiquette please forgive me.

    3. python-dev commented on Feb 23, 2016

      python-devmannequin
      Mannequin

      New changeset 52a8c1965750 by Ned Deily in branch '2.7':
      Issue bpo-26406: Avoid unnecessary serialization of getaddrinfo(3) calls on
      https://hg.python.org/cpython/rev/52a8c1965750

      New changeset 419d20551d26 by Ned Deily in branch '3.5':
      Issue bpo-26406: Avoid unnecessary serialization of getaddrinfo(3) calls on
      https://hg.python.org/cpython/rev/419d20551d26

      New changeset 5ffebeb3e91d by Ned Deily in branch 'default':
      Issue bpo-26406: merge from 3.5
      https://hg.python.org/cpython/rev/5ffebeb3e91d

    4. ned-deily commented on Feb 23, 2016

      @ned-deily
      Member

      Thanks for the additional patch, Jesse. Since we don't have a NetBSD buildbot and I don't have any NetBSD or OpenBSD systems at hand to do any testing, I'll take your word for the version checks. If anyone runs into any problems because of these changes, feel free to re-open this issue. Pushed for release in 2.7.12, 3.5.2, and 3.6.0.

    5. ajdavis commented on Feb 23, 2016

      @ajdavis
      ContributorAuthor

      Thank you!

    6. transferred this issue fromon Apr 10, 2022
    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

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions