:) I'm trying to port some legacy code (large program) to CentOS 7 but I'm hitting a snag. The core of the code is a rather awkard structure built around using mmap to allocate a hard-coded address and map a file to it. The file acts like a database (and is built by one) and includes hard-coded pointers to different sections of the mapped memory. Very ugly, but it is what it is. The entire program is built around this structure, and nobody is going to fund a rewrite.
The problem comes on the mmap line. This worked before, but no longer on CentOS 7:
mmapAddr = mmap ((void *) SMAddr, SMA_WINDOW_SIZE, PROT_READ | (readOnly ? 0 : PROT_WRITE),MAP_FILE | MAP_FIXED | MAP_SHARED, SMFileDesc, 0);
... where SMAddr
is 0x8000000
, SMA_WINDOW_SIZE
is 127926272
, and readOnly
is false. So basically it's trying to map a file to the address 0x8000000
with size 122MB.
What might have changed between versions, I have no clue. But I do note that the file it's mapping is only 1,5MB. I'm not sure exactly why it needs to map so much more than the file size, but I know it's needed, and I know that a lot of nuance has gone into picking the size "122MB" for some reason.
Could a mismatch between actual file size and allocated size have been fine in the past but not any more? I know that SIGBUS
means an attempt to access an invalid memory region. Given that mmap doesn't take any sort of allocated pointer, this has to be something it's doing internally.
I tried catching and blocking SIGBUS
(thinking that maybe it'd be ignorable?), but the program still crashed with a SIGBUS
at the same spot. Maybe I did that wrong.
Thoughts?