GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — zlib: fix pointer alignment by jhofstee · Pull Request #57727 · nodejs/node

Conversation

@jhofstee

@jhofstee jhofstee commented Apr 2, 2025

Copy link
Copy Markdown
Contributor

The function AllocForBrotli prefixes the allocated memory with its size, and returns a pointer to the region after it. This pointer can however no longer be suitably aligned. Correct this by allocating the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for some NEON instructions. When Brotli is compiled with optimizations enabled newer GCC versions will use the NEON instructions and trigger a bus error killing node.

see google/brotli#1159

I don't think there is any additional test needed, since existing test will crash node already.
Not sure about the notable-change label.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@jhofstee
zlib: fix pointer alignment
152058a
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.

see google/brotli#1159
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib module and its compression dependencies. labels Apr 2, 2025
@targos

targos commented Apr 2, 2025

Copy link
Copy Markdown
Member

/cc @nodejs/cpp-reviewers

I can't review this, but I'm very interested as it might fix crashes that we have with the latest V8 update: https://ci.nodejs.org/job/node-test-commit-arm/57862/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos targos mentioned this pull request Apr 2, 2025
[help wanted] deps: update V8 to 13.4 #57114
Closed
3 of 6 tasks
codebytere
codebytere approved these changes Apr 2, 2025
View reviewed changes
@codebytere codebytere mentioned this pull request Apr 2, 2025
fix: zlib pointer alignment electron/electron#46435
Merged
3 tasks done
@codecov

codecov Bot commented Apr 2, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.24%. Comparing base (1c2d98d) to head (152058a).
Report is 85 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57727      +/-   ##
==========================================
+ Coverage   90.22%   90.24%   +0.01%     
==========================================
  Files         630      630              
  Lines      185073   185075       +2     
  Branches    36222    36222              
==========================================
+ Hits       166990   167017      +27     
+ Misses      11044    11034      -10     
+ Partials     7039     7024      -15     
Files with missing lines Coverage Δ
src/node_zlib.cc 78.80% <100.00%> (+0.43%) ⬆️

... and 24 files with indirect coverage changes

🚀 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tniessen
tniessen approved these changes Apr 2, 2025
View reviewed changes
lemire
lemire approved these changes Apr 2, 2025
View reviewed changes

@lemire lemire left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I believe that alignof(std::max_align_t)should always be as large assizeof(size_t)` so the code might be unnecessarily complicated, but it has the benefit of being clear, so I recommend merging as-is.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jhofstee

jhofstee commented Apr 3, 2025

Copy link
Copy Markdown
Contributor Author

I believe that alignof(std::max_align_t)should always be as large assizeof(size_t)` so the code might be unnecessarily complicated, but it has the benefit of being clear, so I recommend merging as-is.

Actually I initially wrote that, only using alignof(std::max_align_t), but that might be confusing to read, since it is casted to a <size_t*> thereafter and a reader might be led to believe it is wrong and put a size_t back. In practice the alignment is often, if not always, twice the sizeof(size_t) and guaranteed by the standard not to be less if I am not mistaken. But like this, the code clearly states it intend, make room for a size_t, while keeping the data after it suitable aligned. So it is clearer like this if you ask me and the compiler will remove the Max for us.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Flarna
Flarna reviewed Apr 4, 2025
View reviewed changes
Comment thread src/node_zlib.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

Flarna
Flarna approved these changes Apr 9, 2025
View reviewed changes
@Flarna Flarna added the commit-queue PRs queued for automated landing through the Commit Queue. label Apr 9, 2025
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Apr 9, 2025
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
@Flarna Flarna added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Apr 9, 2025
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Apr 9, 2025
@nodejs-github-bot

nodejs-github-bot commented Apr 9, 2025

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/66155/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardlau richardlau added commit-queue PRs queued for automated landing through the Commit Queue. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. labels Apr 9, 2025
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Apr 9, 2025
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
@richardlau richardlau added commit-queue PRs queued for automated landing through the Commit Queue. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. labels Apr 9, 2025
@richardlau

This comment was marked as outdated.

Sign in to view
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Apr 9, 2025
aduh95 pushed a commit that referenced this pull request May 17, 2025
@jhofstee @aduh95
zlib: fix pointer alignment
dacde5f
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.

see google/brotli#1159

PR-URL: #57727
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
@github-actions github-actions Bot mentioned this pull request May 19, 2025
2025-05-21, Version 22.16.0 'Jod' (LTS) #58388
Merged
aduh95 pushed a commit that referenced this pull request May 19, 2025
@jhofstee @aduh95
zlib: fix pointer alignment
f2159f2
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.

see google/brotli#1159

PR-URL: #57727
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
codebytere added a commit to electron/electron that referenced this pull request May 23, 2025
@codebytere
zlib: fix pointer alignment
a9c2fbd
nodejs/node#57727
codebytere added a commit to electron/electron that referenced this pull request May 26, 2025
@codebytere
zlib: fix pointer alignment
6ebf0fd
nodejs/node#57727
codebytere added a commit to electron/electron that referenced this pull request May 29, 2025
@codebytere
zlib: fix pointer alignment
dec054d
nodejs/node#57727
codebytere added a commit to electron/electron that referenced this pull request Jun 2, 2025
@codebytere
zlib: fix pointer alignment
7194316
nodejs/node#57727
jkleinsc pushed a commit to electron/electron that referenced this pull request Jun 2, 2025
@electron-roller @codebytere
chore: bump node to v22.16.0 (main) (#47217)
82a59d9
* chore: bump node in DEPS to v22.16.0

* crypto: remove BoringSSL dh-primes addition

nodejs/node#57023

* tools: enable linter in test/fixtures/test\-runner/output

nodejs/node#57698

* src: improve thread safety of TaskQueue

nodejs/node#57910

* buffer: define global v8::CFunction objects as const

nodejs/node#57676

* src: disable abseil deadlock detection

nodejs/node#57582

* zlib: fix pointer alignment

nodejs/node#57727

* chore: fixup patch indices

* src: set default config as node.config.json

nodejs/node#57171

* src: update std::vector<v8::Local<T>> to use v8::LocalVector<T>

nodejs/node#57578

* test: disable chmod tests failing in Docker

nodejs/node#58326

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
@codebytere
zlib: fix pointer alignment
b8658b5
nodejs/node#57727
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
@codebytere
zlib: fix pointer alignment
baae849
nodejs/node#57727
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
@codebytere
zlib: fix pointer alignment
47a2d57
nodejs/node#57727
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
@codebytere
zlib: fix pointer alignment
80dbeac
nodejs/node#57727
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
@codebytere
zlib: fix pointer alignment
fcb237a
nodejs/node#57727
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
@codebytere
zlib: fix pointer alignment
65d61aa
nodejs/node#57727
codebytere added a commit to electron/electron that referenced this pull request Jun 4, 2025
@electron-roller @codebytere
chore: bump node to v22.16.0 (36-x-y) (#47214)
63c7215
* chore: bump node in DEPS to v22.16.0

* crypto: remove BoringSSL dh-primes addition

nodejs/node#57023

* tools: enable linter in test/fixtures/test\-runner/output

nodejs/node#57698

* src: improve thread safety of TaskQueue

nodejs/node#57910

* buffer: define global v8::CFunction objects as const

nodejs/node#57676

* src: disable abseil deadlock detection

nodejs/node#57582

* zlib: fix pointer alignment

nodejs/node#57727

* chore: fixup patch indices

* src: set default config as node.config.json

nodejs/node#57171

* src: update std::vector<v8::Local<T>> to use v8::LocalVector<T>

nodejs/node#57578

* test: disable chmod tests failing in Docker

nodejs/node#58326

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
codebytere added a commit to electron/electron that referenced this pull request Jun 6, 2025
@codebytere
zlib: fix pointer alignment
9b97d16
nodejs/node#57727
@ghost ghost mentioned this pull request Jun 8, 2025
### Notable Changes autofix-ci/action#28
Closed
codebytere added a commit to electron/electron that referenced this pull request Jun 18, 2025
@codebytere
zlib: fix pointer alignment
d82a8d2
nodejs/node#57727
codebytere added a commit to electron/electron that referenced this pull request Jun 30, 2025
@electron-roller @codebytere
chore: bump node to v22.16.0 (35-x-y) (#47213)
1ae9a36
* chore: bump node in DEPS to v22.16.0

* crypto: remove BoringSSL dh-primes addition

nodejs/node#57023

* tools: enable linter in test/fixtures/test\-runner/output

nodejs/node#57698

* src: improve thread safety of TaskQueue

nodejs/node#57910

* buffer: define global v8::CFunction objects as const

nodejs/node#57676

* zlib: fix pointer alignment

nodejs/node#57727

* chore: fixup patch indices

* src: set default config as node.config.json

nodejs/node#57171

* src: update std::vector<v8::Local<T>> to use v8::LocalVector<T>

nodejs/node#57578

* test: disable chmod tests failing in Docker

nodejs/node#58326

* chore: fix out of date patch

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
marco-ippolito pushed a commit that referenced this pull request Aug 18, 2025
@jhofstee @marco-ippolito
zlib: fix pointer alignment
de7aa2f
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.

see google/brotli#1159

PR-URL: #57727
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
@marco-ippolito marco-ippolito mentioned this pull request Aug 20, 2025
2025-09-03, Version 20.19.5 'Iron' (LTS) #59551
Merged
marco-ippolito pushed a commit that referenced this pull request Aug 20, 2025
@jhofstee @marco-ippolito
zlib: fix pointer alignment
8f8b8ce
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.

see google/brotli#1159

PR-URL: #57727
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
marco-ippolito pushed a commit that referenced this pull request Aug 23, 2025
@jhofstee @marco-ippolito
zlib: fix pointer alignment
d6b8ddc
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.

see google/brotli#1159

PR-URL: #57727
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
marco-ippolito pushed a commit that referenced this pull request Aug 25, 2025
@jhofstee @marco-ippolito
zlib: fix pointer alignment
f7efccf
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.

see google/brotli#1159

PR-URL: #57727
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
marco-ippolito pushed a commit that referenced this pull request Aug 25, 2025
@jhofstee @marco-ippolito
zlib: fix pointer alignment
b5441a8
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.

see google/brotli#1159

PR-URL: #57727
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
marco-ippolito pushed a commit that referenced this pull request Aug 25, 2025
@jhofstee @marco-ippolito
zlib: fix pointer alignment
9766899
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.

see google/brotli#1159

PR-URL: #57727
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
marco-ippolito pushed a commit that referenced this pull request Aug 27, 2025
@jhofstee @marco-ippolito
zlib: fix pointer alignment
9dc9604
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.

On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.

see google/brotli#1159

PR-URL: #57727
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
kigh-ota pushed a commit to kigh-ota/electron that referenced this pull request Sep 30, 2025
@electron-roller @codebytere @kigh-ota
chore: bump node to v22.16.0 (main) (electron#47217)
23b1c57
* chore: bump node in DEPS to v22.16.0

* crypto: remove BoringSSL dh-primes addition

nodejs/node#57023

* tools: enable linter in test/fixtures/test\-runner/output

nodejs/node#57698

* src: improve thread safety of TaskQueue

nodejs/node#57910

* buffer: define global v8::CFunction objects as const

nodejs/node#57676

* src: disable abseil deadlock detection

nodejs/node#57582

* zlib: fix pointer alignment

nodejs/node#57727

* chore: fixup patch indices

* src: set default config as node.config.json

nodejs/node#57171

* src: update std::vector<v8::Local<T>> to use v8::LocalVector<T>

nodejs/node#57578

* test: disable chmod tests failing in Docker

nodejs/node#58326

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Flarna Flarna Flarna approved these changes
@lemire lemire lemire approved these changes
@codebytere codebytere codebytere approved these changes
@tniessen tniessen tniessen approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib module and its compression dependencies.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@jhofstee @targos @nodejs-github-bot @richardlau @lemire @codebytere @tniessen @Flarna
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.