How much guarantee is there that glibc math functions are consistent across versions?
3
votes
3
answers
867
views
I am working with a Monte-Carlo based simulation program for particle physics and I am trying to understand some of the randomness I observe. The principle of this program is that it injects a particle into some medium and then it uses a random number generator to decide what type of interactions it has. This allows it to create multiple possible paths for the particle to take. As a user, I can specify the seed values used to initiate the RNG, to ensure reproducibility later on.
Now, I recently came across something weird. The computing cluster I am working on did an **OS upgrade**. All the files were preserved, as well as the binary of the simulation program. However, **the simulation no longer produces the same results** given the identical seed values as before. So somehow the same binary, on the same hardware, but with a different Linux version, is producing a different sequence of interactions.
Looking at the documentation of the simulation framework, I found that the RNG used internally is the RANMAR generator (https://paulbourke.net/miscellaneous/random/) . This is supposed to be a completely portable RNG, thus not dependent on the system you use. Hence this should not be the source of the different output. After talking to the developers, they concluded that the difference would probably be in how some mathematical manipulations are done (for example trigonometric functions). After all, the binary is dynamically linked to the standard library and this was indeed changed during the OS upgrade. **Specifically, the glibc version was upgraded from 2.17 to 2.34**.
I have tried to look online whether this _can_ make a difference for functions included in
libc
and libm
, but I have not been able to find any conclusive answer. I found [some](https://access.redhat.com/solutions/7032163) mention of differences in newer versions, but this sounds more like a bug that was later on patched.
Therefore, my question: Is there a guarantee that mathematical functions in newer versions of glibc
will produce the exact same results? And maybe related, is there any easy way to check what changed between two versions of the library?
Asked by Satjaiga
(49 rep)
Feb 12, 2025, 08:49 AM
Last activity: Feb 13, 2025, 03:53 PM
Last activity: Feb 13, 2025, 03:53 PM