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

            Bug ID: 128694
           Summary: libgomp testsuite: alloc-pinned-{1,2,5}.c fail when
                    RLIMIT_MEMLOCK is too small
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yansendao at 126 dot com
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

alloc-pinned-{1,2,5}.c call

  SIZE = sysconf (_SC_PAGESIZE) - 128;
  CHECK_SIZE (SIZE * 5);

and CHECK_SIZE aborts when RLIMIT_MEMLOCK is not larger than that.  Five
pages is a reasonable minimum for the test, but it collides with the
default lockable-memory limit on hosts with large pages: with 64 KiB pages
five pages are ~320 KiB, while RLIMIT_MEMLOCK defaults to 64 KiB on several
distributions, so the tests abort with

  insufficient lockable memory; please increase ulimit

and are reported as FAIL although nothing is wrong with libgomp.  Nothing
in the testsuite lets them be marked unsupported instead, so every build on
such a host carries three spurious failures.

How reproducible: always on a host whose RLIMIT_MEMLOCK is below five pages.

Steps to reproduce on x86_64-pc-linux-gnu (4 KiB pages, so the threshold is
~19 KiB and can be forced with ulimit):

  $ ulimit -l 16
  $ make -C x86_64-pc-linux-gnu/libgomp check \
      RUNTESTFLAGS="c.exp=alloc-pinned-1.c"
  ...
  insufficient lockable memory; please increase ulimit
  FAIL: libgomp.c/alloc-pinned-1.c execution test

alloc-pinned-3.c/-4.c/-6.c are not affected: they lower the limit with
setrlimit() themselves instead of requiring a large one, and they still
pass with the same ulimit.

Fix: add an effective-target check that compiles and runs a small program
comparing RLIMIT_MEMLOCK against five pages, and require it in the three
tests.  Under a cross compiler the check is skipped (return 1), since the
build machine cannot say anything about the test machine, so cross testing
behaves as before.  With the patch:

  $ ulimit -l 16; make ... check RUNTESTFLAGS="c.exp=alloc-pinned-*"
  UNSUPPORTED: libgomp.c/alloc-pinned-1.c
  UNSUPPORTED: libgomp.c/alloc-pinned-2.c
  PASS: libgomp.c/alloc-pinned-3.c / -4 / -6 / -8
  UNSUPPORTED: libgomp.c/alloc-pinned-5.c

and with the default limit on the same machine alloc-pinned-1/-2/-5 still
pass, so the new check does not skip them where they can run.

Reply via email to