Skip to content

config_gnome3: support glib 2.78+ g_free_sized - #133

Merged
nmoinvaz merged 2 commits into
masterfrom
sergio-nsk/u26/1
Jul 15, 2026
Merged

config_gnome3: support glib 2.78+ g_free_sized#133
nmoinvaz merged 2 commits into
masterfrom
sergio-nsk/u26/1

Conversation

@sergio-nsk

@sergio-nsk sergio-nsk commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Improved memory cleanup on supported systems by using size-aware freeing (when available), reducing the risk of memory-management issues.
  • Chores

    • Expanded CI build coverage with additional Ubuntu 26.04 (clang) configurations, including curl and duktape variants.
    • Updated Codecov reporting flags to match the new build variants.

@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4e175833-6775-4342-af4b-dcf75c301d61

📥 Commits

Reviewing files that changed from the base of the PR and between 357e5d7 and de7ec2d.

📒 Files selected for processing (2)
  • .github/workflows/ubuntu.yaml
  • config_gnome3.c

📝 Walkthrough

Walkthrough

The Ubuntu workflow adds three Ubuntu 26.04 Clang build variants. GNOME 3 configuration conditionally resolves and uses GLib’s size-aware freeing function for allocated strings.

Changes

Ubuntu 26.04 build matrix

Layer / File(s) Summary
Ubuntu 26.04 Clang matrix entries
.github/workflows/ubuntu.yaml
Adds standard, curl-enabled, and Duktape-enabled Ubuntu 26.04 builds using LLVM 21 and separate Codecov flags.

GNOME 3 size-aware freeing

Layer / File(s) Summary
Conditional sized-free contract
config_gnome3.c
Adds the conditional g_free_sized function pointer and guarded size-aware g_free macro.
Sized-free initialization and call sites
config_gnome3.c
Resolves g_free_sized during initialization and routes system mode, URL, and host string cleanup through the macro.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: nmoinvaz

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding GLib 2.78+ g_free_sized support in config_gnome3.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sergio-nsk/u26/1

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

codecov-commenter commented Apr 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.91%. Comparing base (df114f1) to head (de7ec2d).
⚠️ Report is 14 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #133      +/-   ##
==========================================
+ Coverage   58.57%   63.91%   +5.34%     
==========================================
  Files          32       34       +2     
  Lines        2607     2918     +311     
  Branches      526      546      +20     
==========================================
+ Hits         1527     1865     +338     
+ Misses        745      707      -38     
- Partials      335      346      +11     
Flag Coverage Δ
macos 61.00% <ø> (+5.92%) ⬆️
macos_duktape 66.16% <ø> (+6.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sergio-nsk

sergio-nsk commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased for re-running the checks: ubuntu-26.04 is available now.

@sergio-nsk
sergio-nsk marked this pull request as ready for review July 13, 2026 04:43
@sergio-nsk
sergio-nsk requested review from Copilot and nmoinvaz and removed request for Copilot July 13, 2026 04:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@config_gnome3.c`:
- Around line 37-48: The fallback branch must define g_free, not gfree, and the
wrapper must be installed regardless of whether GLib already defines g_free as a
macro. Update the preprocessor structure around the g_free wrapper so any
existing definition is removed when present, then define g_free to call
g_proxy_config_gnome3.g_free in builds without sized-free support.
- Around line 183-188: Update the g_free_sized resolution in the GNOME3
initialization flow to be optional: when dlsym cannot resolve it, assign the
already-resolved g_free function instead of jumping to gnome3_init_error.
Preserve the existing g_free_sized lookup and conditional compilation while
allowing backend initialization to continue on older GLib runtimes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6cdbebd9-2164-4f6f-a149-e14e5a0c7d9a

📥 Commits

Reviewing files that changed from the base of the PR and between 01ffd87 and 6db4285.

📒 Files selected for processing (2)
  • .github/workflows/ubuntu.yaml
  • config_gnome3.c

Comment thread config_gnome3.c
Comment on lines +37 to +48
#ifdef g_free
# undef g_free
# if G_GNUC_CHECK_VERSION(4, 1) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED)
# define g_free(mem) \
(__builtin_object_size((mem), 0) != ((size_t)-1)) \
? (g_proxy_config_gnome3.g_free_sized)(mem, __builtin_object_size((mem), 0)) \
: (g_proxy_config_gnome3.g_free)(mem)
# else
# define gfree(mem) (g_proxy_config_gnome3.g_free)(mem)
# endif
#endif

@coderabbitai coderabbitai Bot Jul 13, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== config_gnome3.c relevant lines ==\n'
nl -ba config_gnome3.c | sed -n '1,220p'

printf '\n== search for gfree / g_free references ==\n'
rg -n '\bgfree\b|\bg_free\b|G_HAVE_FREE_SIZED|GLIB_VERSION_MAX_ALLOWED' config_gnome3.c

Repository: snxd/proxyres

Length of output: 229


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== surrounding context for call sites ==\n'
nl -ba config_gnome3.c | sed -n '48,170p'

Repository: snxd/proxyres

Length of output: 233


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# If the file exists elsewhere, locate it and inspect exact sections.
file="$(git ls-files '*config_gnome3.c' | head -n 1)"
printf 'file=%s\n' "$file"
nl -ba "$file" | sed -n '1,220p'

Repository: snxd/proxyres

Length of output: 212


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== config_gnome3.c relevant lines ==\n'
sed -n '1,220p' config_gnome3.c

printf '\n== search for gfree / g_free references ==\n'
grep -nE '\bgfree\b|\bg_free\b|G_HAVE_FREE_SIZED|GLIB_VERSION_MAX_ALLOWED' config_gnome3.c

Repository: snxd/proxyres

Length of output: 9392


Fix the g_free fallback macro The #else branch currently defines gfree, so g_free(...) falls back to the GLib symbol instead of g_proxy_config_gnome3.g_free on builds without sized-free support. The outer #ifdef g_free also skips the wrapper entirely unless GLib exposes g_free as a macro.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config_gnome3.c` around lines 37 - 48, The fallback branch must define
g_free, not gfree, and the wrapper must be installed regardless of whether GLib
already defines g_free as a macro. Update the preprocessor structure around the
g_free wrapper so any existing definition is removed when present, then define
g_free to call g_proxy_config_gnome3.g_free in builds without sized-free
support.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what do you propose?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmoinvaz, here's the concrete fix — the wrapper should always be installed (not just when glib already defines g_free as a macro), and the fallback branch should define g_free, not gfree:

`#ifdef` g_free
#  undef g_free
`#endif`
`#if` G_GNUC_CHECK_VERSION(4, 1) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED)
#  define g_free(mem)                                                                  \
    (__builtin_object_size((mem), 0) != ((size_t)-1))                                  \
        ? (g_proxy_config_gnome3.g_free_sized)(mem, __builtin_object_size((mem), 0))   \
        : (g_proxy_config_gnome3.g_free)(mem)
`#else`
#  define g_free(mem) (g_proxy_config_gnome3.g_free)(mem)
`#endif`

Two changes from the current code:

  1. Removed the outer #ifdef g_free gate around the whole block. In most glib builds, g_free is declared as a plain function (not a macro), so the current #ifdef g_free check is false and the wrapper never activates — meaning sized-free is silently skipped even on systems that support it, and the wrapper is generally moot. #undef is a safe no-op if g_free isn't currently a macro, so it's fine to always attempt it before defining our own macro.
  2. Fixed the typo in the fallback branch: #define gfree(mem) ...#define g_free(mem) ..., since the misspelled name meant that on builds without sized-free support, calls to g_free(...) in this file wouldn't route through g_proxy_config_gnome3.g_free at all (they'd resolve to the real GLib g_free, which wasn't loaded via dlsym/is separately linked, potentially bypassing the dlopen'd module design).

Let me know if you'd like me to open a PR-scoped follow-up or if you want to apply this directly.

Comment thread config_gnome3.c
Copilot AI review requested due to automatic review settings July 13, 2026 04:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
config_gnome3.c (1)

37-47: 🎯 Functional Correctness | 🟠 Major

Still remove the outer #ifdef g_free guard.

GLib declares g_free as a function and only conditionally defines the macro. When that macro is absent, this block is skipped entirely, so the new call sites bypass the dlsym-resolved function and may reintroduce a direct link dependency. (docs.gtk.org)

Move the #ifdef around only #undef g_free, then define the fallback wrapper unconditionally.

Proposed fix
-#ifdef g_free
-#  undef g_free
-#  if ...
+#ifdef g_free
+#  undef g_free
+#endif
+#if ...
 ...
-#  endif
 `#endif`
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config_gnome3.c` around lines 37 - 47, Update the g_free compatibility block
so the outer `#ifdef` g_free guards only `#undef` g_free, then define the
replacement g_free wrapper unconditionally using the existing version check and
dlsym-resolved proxy functions. Ensure call sites use
g_proxy_config_gnome3.g_free or g_free_sized even when GLib did not originally
define a g_free macro.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@config_gnome3.c`:
- Around line 37-47: Update the g_free compatibility block so the outer `#ifdef`
g_free guards only `#undef` g_free, then define the replacement g_free wrapper
unconditionally using the existing version check and dlsym-resolved proxy
functions. Ensure call sites use g_proxy_config_gnome3.g_free or g_free_sized
even when GLib did not originally define a g_free macro.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 04261c87-c26f-4125-8d73-1edf9953666c

📥 Commits

Reviewing files that changed from the base of the PR and between 6db4285 and cc1eccd.

📒 Files selected for processing (2)
  • .github/workflows/ubuntu.yaml
  • config_gnome3.c

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the GNOME3 configuration backend to cope with newer GLib memory-free APIs/macros, and expands CI to validate builds on Ubuntu 26.04 across multiple feature configurations.

Changes:

  • Add a g_free wrapper strategy in config_gnome3.c to handle environments where GLib provides g_free as a macro and may use g_free_sized.
  • Extend the Ubuntu GitHub Actions workflow matrix with Ubuntu 26.04 variants (default, curl, duktape) and corresponding llvm-cov settings.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
config_gnome3.c Adds support for GLib g_free_sized / g_free macro interactions by routing frees through dynamically resolved symbols.
.github/workflows/ubuntu.yaml Adds Ubuntu 26.04 build+test+coverage jobs for multiple configurations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread config_gnome3.c
Comment thread config_gnome3.c
@nmoinvaz nmoinvaz changed the title build: fix: Ubuntu 26.04 LTS config_gnome3: support glib 2.78+ g_free_sized; add Ubuntu 26.04 CI Jul 15, 2026
@nmoinvaz nmoinvaz changed the title config_gnome3: support glib 2.78+ g_free_sized; add Ubuntu 26.04 CI config_gnome3: support glib 2.78+ g_free_sized Jul 15, 2026
@nmoinvaz

Copy link
Copy Markdown
Collaborator

@sergio-nsk I cleaned up the PR title and commit message and also split it into 2 commits.

@nmoinvaz
nmoinvaz enabled auto-merge (rebase) July 15, 2026 23:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@config_gnome3.c`:
- Around line 37-47: Update the g_free wrapper near g_proxy_config_gnome3 so
`#undef` g_free is guarded independently, then define the custom g_free macro
unconditionally. Preserve the existing conditional sized-free dispatch when its
guard is true, and otherwise route all calls through
g_proxy_config_gnome3.g_free rather than requiring a direct GLib symbol.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b79e7f21-08b8-4595-ac07-a37c4b89f4cd

📥 Commits

Reviewing files that changed from the base of the PR and between cc1eccd and 357e5d7.

📒 Files selected for processing (2)
  • .github/workflows/ubuntu.yaml
  • config_gnome3.c

Comment thread config_gnome3.c
@nmoinvaz
nmoinvaz merged commit bbd0cb2 into master Jul 15, 2026
19 checks passed
@nmoinvaz
nmoinvaz deleted the sergio-nsk/u26/1 branch July 15, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants