Metrics: one transient allocation failure disables the registry forever

Open Beginner friendly
#1,069 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
observability

Research direction

Locate the metrics registry implementation containing cwist_metrics_registry_init() and cwist_metrics_registry(), and trace how the pthread_once wrapper prevents retries after allocation failure. Rework initialization to use a mutex plus an initialized flag, or a statically allocated registry, then add a test that forces the first allocation to fail and confirms a later call succeeds. Done means repeated calls recover from a transient allocation failure and the new fail-then-succeed test passes.

Written by the indexing model from the issue text.

Description

bug

cwist_metrics_registry_init() leaves g_reg NULL on allocation failure, but cwist_metrics_registry() wraps it in pthread_once. Later calls never retry initialization even after memory becomes available, permanently disabling metrics for the process. Make initialization retryable with a mutex and an initialized flag, or use a statically allocated registry, and add a fail-then-succeed test.

Dominant language
C
Stars
16
Forks
7
Avg merge
4h 17m
Merged PRs (30d)
198

Getting set up

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 c4punks/CWIST

All issues in c4punks/CWIST

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.