Skip to content

fs: non-bigint stat can give 0.20566138856% bigger results #58726

Description

@LiviaMedeiros

Version

v24.2.0, v25.0.0-pre

Platform

Linux tumba 6.14.8-gentoo-yuran #2 SMP Tue May 27 17:51:23 +08 2025 x86_64 Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz GenuineIntel GNU/Linux

Subsystem

fs

What steps will reproduce the bug?

import fs from 'node:fs/promises';
const f = '/tmp/deleteme-utimes-issue-file';
await fs.writeFile(f, '');

console.log('|', 'set', '|', 'got', '|', 'got/set', '|');
console.log('|', '---', '|', '---', '|', '---', '|');

for (let i = 1; i < Number.MAX_SAFE_INTEGER; i *= 3) {
await fs.utimes(f, i, i);
const { mtimeMs } = await fs.stat(f);
console.log('|', i, '|', mtimeMs, '|', mtimeMs / i, '|');
}

await fs.rm(f);

How often does it reproduce? Is there a required condition?

Reproduces on one specific PC all the time. Couldn't reproduce on any other machine so far.

What is the expected behavior? Why is that the expected behavior?

setgotgot/set
110001000
330001000
990001000
27270001000
81810001000
2432430001000
7297290001000
218721870001000
656165610001000
19683196830001000
59049590490001000
1771471771470001000
5314415314410001000
159432315943230001000
478296947829690001000
14348907143489070001000
43046721430467210001000
1291401631291401630001000
3874204893874204890001000
116226146711622614670001000
348678440134867844010001000
10460353203104603532030001000
3138105960915032385535000479.0273407685939
9414317882715032385535000159.67578025619795
2824295364811503238553500053.22526008539932
8472886094431503238553500017.741753361799773
2541865828329150323855350005.913917787266591
7625597484987150323855350001.9713059290888637
22876792454961150323855350000.6571019763629545
68630377364883150323855350000.21903399212098484
205891132094649150323855350000.07301133070699495
617673396283947150323855350000.024337110235664983
1853020188851841150323855350000.008112370078554995
5559060566555523150323855350000.0027041233595183315

Expected because 1 second is 1000 milliseconds

What do you see instead?

setgotgot/set
11002.05661388564541002.0566138856454
33006.1698416569361002.0566138856453
99018.5095249708081002.0566138856453
2727055.5285749124271002.0566138856454
8181166.585724737281002.0566138856454
243243499.757174211851002.0566138856454
729730499.27152263551002.0566138856453
21872191497.8145679071002.0566138856456
65616574493.4437037191002.0566138856454
1968319723480.331111161002.0566138856454
5904959170440.993333481002.0566138856454
177147177511322.980000441002.0566138856454
531441532533968.94000131002.0566138856454
15943231597601906.8200041002.0566138856454
47829694792805720.46001151002.0566138856454
1434890714378417161.3800351002.0566138856454
4304672143135251484.140111002.0566138856454
129140163129405754452.420321002.0566138856454
387420489388217263357.26091002.0566138856453
11622614671164651790071.7831002.0566138856456
34867844013493955370215.34861002.0566138856454
1046035320310481866110646.0451002.0566138856453
3138105960915063301347825.656480.0125150492224
9414317882715063301347825.656160.0041716830741
28242953648115063301347825.65653.33472389435804
84728860944315063301347825.65617.778241298119347
254186582832915063301347825.6565.926080432706449
762559748498715063301347825.6561.975360144235483
2287679245496115063301347825.6560.6584533814118276
6863037736488315063301347825.6560.2194844604706092
20589113209464915063301347825.6560.0731614868235364
61767339628394715063301347825.6560.024387162274512136
185302018885184115063301347825.6560.008129054091504046
555906056655552315063301347825.6560.002709684697168015

Additional information

This issue causes test/parallel/test-fs-cp.mjs, test/parallel/test-fs-promises.js, test/parallel/test-fs-stat-bigint.js, and test/parallel/test-fs-utimes-y2K38.js fail for me locally every time. 😧

This issue persists for statSync(), too.
This issue persists between different filesystems.

This issue does not appear when using bigint option.
This issue does not appear when using touch/stat, or similar functions in other languages.

I suspect some weird bug with floating point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions