- Notifications
You must be signed in to change notification settings - Fork4.4k
Use parseUnsignedLong for getNetIoCountersLinux#27966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Use parseUnsignedLong for getNetIoCountersLinux#27966
Conversation
We had some users have this logic fail because of huge values in`/proc/net/dev` like 10586847412485054478.```FATAL: bazel crashed due to an internal error. Printing stack trace:java.lang.NumberFormatException: For input string: "10586847412485054478"at java.base/java.lang.NumberFormatException.forInputString(Unknown Source)at java.base/java.lang.Long.parseLong(Unknown Source)at java.base/java.lang.Long.parseLong(Unknown Source)at java.base/java.util.stream.ReferencePipeline$5$1.accept(Unknown Source)at java.base/java.util.Iterator.forEachRemaining(Unknown Source)at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(Unknown Source)at java.base/java.util.stream.LongPipeline.toArray(Unknown Source)at com.google.devtools.build.lib.profiler.SystemNetworkStatsServiceImpl.getNetIoCountersLinux(SystemNetworkStatsServiceImpl.java:64)at com.google.devtools.build.lib.profiler.SystemNetworkStatsServiceImpl.getNetIoCounters(SystemNetworkStatsServiceImpl.java:43)at com.google.devtools.build.lib.profiler.NetworkMetricsCollector.collectSystemNetworkUsages(NetworkMetricsCollector.java:66)at com.google.devtools.build.lib.profiler.CollectLocalResourceUsage$SystemNetworkUsageCollector.collect(CollectLocalResourceUsage.java:489)at com.google.devtools.build.lib.profiler.CollectLocalResourceUsage$Collector.run(CollectLocalResourceUsage.java:200)```This is likely because we're using [RDMA over ConvergedEthernet](https://en.wikipedia.org/wiki/RDMA_over_Converged_Ethernet)which massively inflates the transfer stats.These values are u64s in the kernel so we should respect thathttps://github.com/torvalds/linux/blob/187d0801404f415f22c0b31531982c7ea97fa341/include/uapi/linux/if_link.h#L219-L228
keith commentedDec 12, 2025
cc@coeuvre |
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.
Code Review
This pull request addresses aNumberFormatException caused by parsing large unsigned 64-bit integer values from/proc/net/dev. The fix, which involves switching fromLong.parseLong toLong.parseUnsignedLong, is correct and effectively resolves the crash. The change is well-contained and directly targets the root cause of the issue.
keith commentedDec 12, 2025
was able to workaround with |
fmeum commentedDec 12, 2025
@bazel-io fork 9.0.0 |
tjgq left a comment
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 think you also need to fixNetworkMetricsCollector.calcDelta to work correctly with negative values.
We had some users have this logic fail because of huge values in
/proc/net/devlike 10586847412485054478.This is likely because we're usingRDMA over Converged
Ethernet
which massively inflates the transfer stats.
These values are u64s in the kernel so we should respect that
https://github.com/torvalds/linux/blob/187d0801404f415f22c0b31531982c7ea97fa341/include/uapi/linux/if_link.h#L219-L228