Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
BIND
BIND
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 629
    • Issues 629
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 112
    • Merge Requests 112
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ISC Open Source Projects
  • BINDBIND
  • Issues
  • #1156

Closed
Open
Created Jul 23, 2019 by Ondřej Surý@ondrejOwner

isc_refcount_increment0 is wrong, the code using it needs refactoring

The isc_refcount_increment0() does two things and that's wrong.

  1. The first purpose is to bump the value from 0 -> 1 making the object referenced.

  2. The second purpose is to increment the reference counter.

This has several problems:

  1. You can't check whether the previous value really was 0.
  2. When object becomes dereferenced with isc_refcount_decrement() == 1, the isc_refcount_increment0() can make it referenced again while destroying the object.

There are two things that we could do about it:

  1. Don't use isc_refcount API when it's not reference counting, prepare similar API for object counting (isc_objcount?)
  2. Use isc_refcount_init() when initializing object for the first time (note that isc_refcount_init() is not atomic)
  3. Always initialize the value to 1 and adjust the code that destroys the object
  4. Split isc_refcount_increment0() to isc_refcount_incfirst() and existing isc_refcount_increment()

Nevertheless, the overloading of the API for <1, MAX> and <0, MAX> reference counting is wrong.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None