Skip to content

bug fix unbreak build on glibc >= 2.28#2743

Open
Juraci wants to merge 1 commit into
bugsnag:nextfrom
Juraci:fix/tinycthread-glibc-2.28
Open

bug fix unbreak build on glibc >= 2.28#2743
Juraci wants to merge 1 commit into
bugsnag:nextfrom
Juraci:fix/tinycthread-glibc-2.28

Conversation

@Juraci

@Juraci Juraci commented May 4, 2026

Copy link
Copy Markdown

Goal

@bugsnag/plugin-electron-client-state-persistence fails to compile on any system with glibc ≥ 2.28 (Ubuntu 18.10+, Debian 10+, Fedora 29+, Arch, etc.). The vendored tinycthread redefines once_flag and call_once against names that glibc now exposes through <stdlib.h>, producing conflicting types for 'pthread_once_t' and conflicting types for 'pthread_once' errors during node-gyp rebuild. This breaks npm install for any consumer of @bugsnag/electron on a current Linux distro that doesn't have a prebuilt binding cached.

Design

The plugin uses only mtx_t, mtx_init, mtx_lock, mtx_unlock, and mtx_plain from tinycthread (see src/bugsnag_electron_client_state_persistence.c). once_flag, ONCE_FLAG_INIT, and call_once are never referenced on POSIX — the only call_once definition in tinycthread.c is gated behind #if defined(_TTHREAD_WIN32_).

Since the colliding code is dead on POSIX, the smallest and safest fix is to drop the POSIX #else branches entirely. The Win32 typedef struct once_flag and void call_once(...) declarations are untouched, preserving Windows behaviour.

A more durable fix would be to drop the vendored tinycthread on platforms that ship C11 <threads.h> and use the system header. That's a larger change; happy to do it as a follow-up if reviewers prefer.

Changeset

packages/plugin-electron-client-state-persistence/src/deps/tinycthread/tinycthread.h: deletes the two POSIX #else branches (5 lines total) that redefine once_flag / ONCE_FLAG_INIT / call_once. No other files modified.

@@ -456,9 +456,6 @@ int tss_set(tss_t key, void *val);
     CRITICAL_SECTION lock;
   } once_flag;
   #define ONCE_FLAG_INIT {0,}
-#else
-  #define once_flag pthread_once_t
-  #define ONCE_FLAG_INIT PTHREAD_ONCE_INIT
 #endif

 /** Invoke a callback exactly once
@@ -468,8 +465,6 @@ int tss_set(tss_t key, void *val);
  */
 #if defined(_TTHREAD_WIN32_)
   void call_once(once_flag *flag, void (*func)(void));
-#else
-  #define call_once(flag,func) pthread_once(flag,func)
 #endif

Testing

Manual:

  • npm install && npx node-gyp rebuild in packages/plugin-electron-client-state-persistence succeeds on Arch Linux (glibc 2.43); produces build/Release/bugsnag_pecsp_bindings.node. Without this patch, the same command fails with conflicting types for 'pthread_once_t'.
  • CI to confirm Linux / macOS / Windows builds remain green (Win32 branch is untouched; POSIX-side macros were dead code, so no behavioural change is expected).

Automated:

  • No new tests added — the change deletes dead-code macro definitions on POSIX. Existing CI build steps for the plugin exercise the regression surface.
Platform Before After
Linux glibc ≥ 2.28 build fails builds
Linux glibc < 2.28 builds builds (macros removed but unused)
macOS builds builds (macros removed but unused)
Windows builds builds (Win32 branch untouched)

… >= 2.28

Vendored tinycthread redefined once_flag and call_once on POSIX, which
collides with the C11 once_flag glibc 2.28+ exposes through <stdlib.h>.
The plugin only uses mtx_* primitives; once_flag/call_once are unused on
POSIX. Drop the colliding #else branches; Win32 path is untouched.
@Juraci Juraci changed the title fix(plugin-electron-client-state-persistence): unbreak build on glibc… bug fix unbreak build on glibc >= 2.28 May 4, 2026
@SB-priyankap SB-priyankap requested a review from Copilot May 5, 2026 06:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes a Linux build regression in the native @bugsnag/plugin-electron-client-state-persistence addon by removing POSIX once_flag/call_once shims from the vendored tinycthread header, avoiding symbol collisions with newer glibc headers. I verified the package’s native code only uses mtx_* from tinycthread, so the removed POSIX once-only API is not used by this addon.

Changes:

  • Removes the POSIX once_flag/ONCE_FLAG_INIT aliases from vendored tinycthread.h.
  • Removes the POSIX call_once alias while leaving the Win32 declaration/implementation path intact.
  • Keeps the Electron client-state persistence package buildable on current Linux distributions without changing the addon’s runtime behavior.

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

@hannah-smartbear

Copy link
Copy Markdown
Contributor

Hi @Juraci,

Thanks for raising this PR. Our engineers will take a look, and any comments or updates will be posted here accordingly.

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.

3 participants