Skip to content

internal/beater/config: fix 32-bit arch overflow#15216

Merged
axw merged 3 commits intoelastic:mainfrom
axw:beaterconfig-agentconfig-cachexpiration
Jan 14, 2025
Merged

internal/beater/config: fix 32-bit arch overflow#15216
axw merged 3 commits intoelastic:mainfrom
axw:beaterconfig-agentconfig-cachexpiration

Conversation

@axw
Copy link
Member

@axw axw commented Jan 13, 2025

Motivation/summary

Rather than converting from float64 to int and back, which may overflow on 32-bit architectures, check if the duration has a sub-second component through an integer modulo operation.

Checklist

How to test these changes

Run apm-server with the largest possible whole second duration for apm-server.agent.config.cache.expiration: 2562047h47m16s. Prior to this PR, that should fail on 32-bit architectures.

Related issues

None

Rather than converting from float64 to int and back,
which may overflow on 32-bit architectures, check if
the duration has a sub-second component through an
integer modulo operation.
@axw axw requested a review from a team as a code owner January 13, 2025 02:52
@mergify
Copy link
Contributor

mergify bot commented Jan 13, 2025

This pull request does not have a backport label. Could you fix it @axw? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-7.17 is the label to automatically backport to the 7.17 branch.
  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • backport-8.x is the label to automatically backport to the 8.x branch.
@mergify
Copy link
Contributor

mergify bot commented Jan 13, 2025

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Jan 13, 2025
@marclop marclop added backport-8.16 Automated backport with mergify and removed backport-8.16 Automated backport with mergify labels Jan 13, 2025
@axw axw enabled auto-merge (squash) January 13, 2025 03:03
@axw axw merged commit 53bbcaf into elastic:main Jan 14, 2025
13 checks passed
mergify bot pushed a commit that referenced this pull request Jan 14, 2025
* internal/beater/config: fix 32-bit arch overflow

Rather than converting from float64 to int and back,
which may overflow on 32-bit architectures, check if
the duration has a sub-second component through an
integer modulo operation.

* Add changelog

(cherry picked from commit 53bbcaf)
mergify bot added a commit that referenced this pull request Jan 14, 2025
* internal/beater/config: fix 32-bit arch overflow

Rather than converting from float64 to int and back,
which may overflow on 32-bit architectures, check if
the duration has a sub-second component through an
integer modulo operation.

* Add changelog

(cherry picked from commit 53bbcaf)

Co-authored-by: Andrew Wilkins <axw@elastic.co>
@axw axw deleted the beaterconfig-agentconfig-cachexpiration branch January 15, 2025 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.x Automated backport to the 8.x branch with mergify

3 participants