Provide public sdb_ref sdb_unref

Open
#199 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
c
Domain
database

Research direction

Start by tracing Sdb reference ownership and the RBinFile->sdb field, especially the cleanup path in r_bin_file_free. Define how public sdb_ref and sdb_unref should be used for shared Sdb values, then verify that the ownership behavior no longer permits the described leaks.

Written by the indexing model from the issue text.

Description

I think we should introduce new APIs to increment/decrement the ref value of a Sdb. This can be very useful in radare2 where sdb are passed around and sometimes it's not clear which component will be the first to release a given Sdb.

This seems the case with RBinFile, which has a ->sdb field which is not freed in r_bin_file_free because it is already freed by someone else. This leads to memory leaks in some cases and in general I think it is not good practice to have some fields of a data structure owned by something else.

Dominant language
C
Stars
235
Forks
69
Avg merge
1m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from radareorg/sdb

All issues in radareorg/sdb

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.