bug fix unbreak build on glibc >= 2.28#2743
Open
Juraci wants to merge 1 commit into
Open
Conversation
… >= 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.
Contributor
There was a problem hiding this comment.
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_INITaliases from vendoredtinycthread.h. - Removes the POSIX
call_oncealias 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.
Contributor
|
Hi @Juraci, Thanks for raising this PR. Our engineers will take a look, and any comments or updates will be posted here accordingly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
@bugsnag/plugin-electron-client-state-persistencefails to compile on any system with glibc ≥ 2.28 (Ubuntu 18.10+, Debian 10+, Fedora 29+, Arch, etc.). The vendoredtinycthreadredefinesonce_flagandcall_onceagainst names that glibc now exposes through<stdlib.h>, producingconflicting types for 'pthread_once_t'andconflicting types for 'pthread_once'errors duringnode-gyp rebuild. This breaksnpm installfor any consumer of@bugsnag/electronon 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, andmtx_plainfrom tinycthread (seesrc/bugsnag_electron_client_state_persistence.c).once_flag,ONCE_FLAG_INIT, andcall_onceare never referenced on POSIX — the onlycall_oncedefinition intinycthread.cis gated behind#if defined(_TTHREAD_WIN32_).Since the colliding code is dead on POSIX, the smallest and safest fix is to drop the POSIX
#elsebranches entirely. The Win32typedef struct once_flagandvoid 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#elsebranches (5 lines total) that redefineonce_flag/ONCE_FLAG_INIT/call_once. No other files modified.Testing
Manual:
npm install && npx node-gyp rebuildinpackages/plugin-electron-client-state-persistencesucceeds on Arch Linux (glibc 2.43); producesbuild/Release/bugsnag_pecsp_bindings.node. Without this patch, the same command fails withconflicting types for 'pthread_once_t'.Automated: