• S
    Replace mmap with xmmap, better handling MAP_FAILED. · c4712e45
    Shawn O. Pearce 提交于
    In some cases we did not even bother to check the return value of
    mmap() and just assume it worked.  This is bad, because if we are
    out of virtual address space the kernel returned MAP_FAILED and we
    would attempt to dereference that address, segfaulting without any
    real error output to the user.
    
    We are replacing all calls to mmap() with xmmap() and moving all
    MAP_FAILED checking into that single location.  If a mmap call
    fails we try to release enough least-recently-used pack windows
    to possibly succeed, then retry the mmap() attempt.  If we cannot
    mmap even after releasing pack memory then we die() as none of our
    callers have any reasonable recovery strategy for a failed mmap.
    Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
    Signed-off-by: NJunio C Hamano <junkio@cox.net>
    c4712e45
config.c 17.8 KB