PGI 20.1+ crash on test/future and when_all(one_fut).wait()

Issue #334 resolved
Dan Bonachea created an issue

Moved from pull request #181:

Recently released PGI 20.1 gets an internal compiler error (ICE) when building test/future.cpp. The failure mode looks like this:

"/usr/local/pkg/gcc/8.3.0/include/c++/8.3.0/tuple", line 640: internal error:
assertion failed: missing default rescan info (exprutil.c, line 4731
in get_expr_rescan_info)

  _TMC<_UElements...>::template
  ^

This appears to be independent of which libstdc++ version is backing PGI (seen with all of GCC 7, 8 and 9), but appears to be specific to PGI v20.1. On our side, the problem affects versions back to at least 2019.9.0 and up through the current tip of develop @ 95500de. It may or may not be specific to x86_64. Although it involves the same header, this appears to be a distinct issue from issue #290 (although it might involve a flawed workaround recently deployed by PGI to address that problem).

Here is a minimal program that reproduces the compiler crash back to at least UPC++ 2019.9.0:

#include <upcxx/future.hpp>

using namespace upcxx;

future<int> fib(int i) {
  return make_future(i+7);
}


int main() {
  future<int> ans0 = fib(5);

  //int x = ans0.wait(); // works
  int x = when_all(ans0).wait(); // crash

  return 0;
}

Demonstration on dirac:

$ module switch upcxx upcxx/2019.9.0/gcc-9.2.0
$ upcxx -g -c future-crash.cpp 
$ module switch pgi pgi/19.10
$ module switch upcxx upcxx/2019.9.0/pgi-19.10
$ upcxx -g -c future-crash.cpp
$ module switch pgi pgi/20.1
$ module switch upcxx upcxx/2019.9.0/pgi-20.1
$ upcxx -g -c future-crash.cpp               
"/usr/local/pkg/gcc/8.3.0/include/c++/8.3.0/tuple", line 640: internal error:
          assertion failed: missing default rescan info (exprutil.c, line 4731
          in get_expr_rescan_info)

                  _TMC<_UElements...>::template
                  ^

1 catastrophic error detected in the compilation of "future-crash.cpp".
Compilation aborted.
pgc++-Fatal-/usr/local/pkg/pgi/linux86-64-llvm/20.1/bin/pggpp1 TERMINATED by signal 6
Arguments to /usr/local/pkg/pgi/linux86-64-llvm/20.1/bin/pggpp1
/usr/local/pkg/pgi/linux86-64-llvm/20.1/bin/pggpp1 --llalign --no_warnings -Dunix -D__unix -D__unix__ -Dlinux -D__linux -D__linux__ -D__NO_MATH_INLINES -D__LP64__ -D__x86_64 -D__x86_64__ -D__LONG_MAX__=9223372036854775807L '-D__SIZE_TYPE__=unsigned long int' '-D__PTRDIFF_TYPE__=long int' -D__amd64 -D__amd64__ -D__k8 -D__k8__ -D__MMX__ -D__SSE__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__POPCNT__ -D__FXSR__ -D__PGI -D_GNU_SOURCE -D_PGCG_SOURCE -I/usr/local/pkg/upcxx-dirac/pgi-20.1/stable-2019.9.0/gasnet.debug/include -I/usr/local/pkg/upcxx-dirac/pgi-20.1/stable-2019.9.0/gasnet.debug/include/ibv-conduit -I/usr/local/pkg/upcxx-dirac/pgi-20.1/stable-2019.9.0/upcxx.debug.gasnet_seq.ibv/include -I/usr/local/pkg/openmpi-4.0.2/pgi-20.1/include -I- -I/usr/local/pkg/pgi/linux86-64-llvm/20.1/include-gcc70 -I/usr/local/pkg/pgi/linux86-64-llvm/20.1/include/nvomp -I/usr/local/pkg/pgi/linux86-64-llvm/20.1/include -I/usr/local/pkg/gcc/8.3.0/include/c++/8.3.0 -I/usr/local/pkg/gcc/8.3.0/include/c++/8.3.0/x86_64-pc-linux-gnu -I/usr/local/pkg/gcc/8.3.0/include/c++/8.3.0/backward -I/usr/local/pkg/gcc/8.3.0/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include -I/usr/local/include -I/usr/local/pkg/gcc/8.3.0/include -I/usr/local/pkg/gcc/8.3.0/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed -I/usr/include -I/usr/local/pkg/pgi/linux86-64-llvm/20.1/include/nvomp -I/usr/local/pkg/pgi/linux86-64-llvm/20.1/include-gcc70 -I/usr/local/pkg/pgi/linux86-64-llvm/20.1/include -I/usr/local/pkg/gcc/8.3.0/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include -I/usr/local/include -I/usr/local/pkg/gcc/8.3.0/include -I/usr/local/pkg/gcc/8.3.0/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include-fixed -I/usr/include -D__PGLLVM__ -D__extension__= -DUPCXX_ASSERT_ENABLED=1 -DUPCXX_BACKEND=1 -DUPCXX_BACKEND_GASNET_SEQ=1 -DUPCXX_MPSC_QUEUE_ATOMIC=1 -D_GNU_SOURCE=1 -DGASNET_SEQ -D_REENTRANT --preinclude _cplus_preinclude.h --preinclude_macros _cplus_macros.h --gnu_version=80300 -D__pgnu_vsn=80300 --c++11 -g --dwarf2 -g --dwarf2 -q -o /tmp/pgc++6PNcUA7zlAI9.il future-crash.cpp

The problem appears specific to the construct upcxx::when_all(one_future).wait() or upcxx::when_all(one_future).result(). This luckily would be a silly thing to write directly (but might be less silly in a generic programming situation).

The problem also manifests if the when_all and wait are separated with an auto temporary:

 auto x = when_all(ans0); 
 int y = x.wait(); // crash

but NOT if the second line is omitted, nor if the temporary is given a specific type:

 future<int> x = when_all(ans0);
 int y = x.wait(); // ok

so I'm guessing the crash is happening in the type inference for the expression `upcxx::when_all(one_future) and its subsequent application to wait or result.

As an ICE this is very clearly an external bug, but it's our responsibility to at least report it and possibly seek a workaround.

Comments (6)

  1. Paul Hargrove

    It may or may not be specific to x86_64

    My private install on Summit (Linux/ppc64le) reproduces the ICE as well.

  2. Paul Hargrove

    Recent test results on both Dirac and Summit show this test has ceased crashing the PGI compiler.

    On Dirac this testing is with 20.4, but the Summit testing is still 20.1.
    The change in behavior on Summit in particular, suggests that some change in UPC++ between July 14 and 17 has "resolved" this issue. The only likely candidate is pull request #226, but PGI 20.4 seems to pass even before that. So, there may be multiple changes (ours and PGI's) at play here. I will look deeper as time allows.

    This new information came out of an attempt to see if PGI 20.4 suffers from the original issue.
    Retesting commit 95500de from the original report, shows 20.4 DOES suffer from this issue (thus the update to Title)

  3. Paul Hargrove

    I've retested the 2021.3.0 release building both future.cpp and the minimal reproducer, with -g and with -O, with all seven supported PGI compiler versions on Dirac. Not a single case ICEd.

  4. Log in to comment