https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120464

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:dc887145c0e9ae44e939dab3e0198346fe660793

commit r16-950-gdc887145c0e9ae44e939dab3e0198346fe660793
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Thu May 29 09:58:30 2025 +0200

    ggc-page: Fix up build on non-USING_MMAP hosts [PR120464]

    The r16-852 "Use optimize free lists for alloc_pages" change broke build
    on non-USING_MMAP hosts.
    I don't have access to one, so I've just added #undef USING_MMAP
    before first use of that macro after the definitions.

    There were 2 problems.  One was one missed G.free_pages
    to free_list->free_pages replacement in #ifdef USING_MALLOC_PAGE_GROUPS
    guarded code which resulted in obvious compile error.

    Once fixed, there was an ICE during self-test and without self-test pretty
    much on any garbage collection.
    The problem is that the patch moved all of release_pages into new
    do_release_pages and runs it for each freelist from the new release_pages
    wrapper.  The #ifdef USING_MALLOC_PAGE_GROUPS code had two loops, one
    which walked the entries in the freelist and freed the ones which had
    unused group there and another which walked all the groups (regardless of
    which freelist they belong to) and freed the unused ones.
    With the change the first call to do_release_pages would free freelist
    entries from the first freelist with unused groups, then free all unused
    groups and then second and following would access already freed groups,
    crashing there, and then walk again all groups looking for unused ones (but
    there are guaranteed to be none).

    So, this patch fixes it by moving the unused group freeing to the caller,
    release_pages after all freelists are freed, and while at it, moves there
    the statistics printout as well, we don't need to print separate info
    for each of the freelist, previously we were emitting just one.

    2025-05-29  Jakub Jelinek  <ja...@redhat.com>

            PR bootstrap/120464
            * ggc-page.cc (struct ggc_globals): Fix up comment formatting.
            (find_free_list): Likewise.
            (alloc_page): For defined(USING_MALLOC_PAGE_GROUPS) use
            free_list->free_pages instead of G.free_pages.
            (do_release_pages): Add n1 and n2 arguments, make them used.
            Move defined(USING_MALLOC_PAGE_GROUPS) page group freeing to
            release_pages and dumping of statistics as well.  Formatting fixes.
            (release_pages): Adjust do_release_pages caller, move here
            defined(USING_MALLOC_PAGE_GROUPS) page group freeing and dumping
            of statistics.
            (ggc_handle_finalizers): Fix up comment formatting and typo.

Reply via email to