def check_for_slurm_error(slurm_log):
    """
    Returns a tuple of flags indicating whether SLURM reached the time limit or
    encountered a bus error.
    """
    time_limit = bus_error = False

    with open(slurm_log) as f:
        for line in reversed(f.readlines()):
            if 'TIME LIMIT' in line:
                time_limit = True
            elif 'Bus error' in line:
                bus_error = True

    return time_limit, bus_error