Skip to content

Commit 19e3dc4

Browse files
committed
[minicern] Move address computation to 64 bit.
kernlib was using the LOCF function to compute distances between common blocks. It shifts the numbers, but in 32 bits. On 64 bit architectures, this can lead to unreasonable values, and when taking the difference, it's either correct or wraps around to very large numbers. Due to aslr, the common blocks move around, which can crash the program at init time when the blocks are on different sides of the "wrap around" addresss. Here, the LOCF function is changed to use 64 bit integers for the address, which makes the distance computation independent of where the kernel places the common blocks.
1 parent 40ae624 commit 19e3dc4

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

misc/minicern/src/kernlib.f

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ SUBROUTINE UBUNCH (MS,MT,NCHP)
8787
*-------------------------------------------------------------------------------
8888

8989
FUNCTION LOCF (IVAR)
90+
IMPLICIT NONE
91+
INTEGER :: IVAR, NADUPW, LADUPW
92+
INTEGER*8 :: J, LOCF
9093
DIMENSION IVAR(9)
9194
PARAMETER (NADUPW=4, LADUPW=2)
9295
J = LOC(IVAR)

0 commit comments

Comments
 (0)