External Issue: Internal compiler error because of _wide_make

18511, "twesterhout", "Internal compiler error because of _wide_make", "2021-10-02T14:07:45Z"

Summary of Problem

Trying to use _wide_make results in internal error.

Steps to Reproduce

Source Code:

use CPtr;
use SysCTypes;

export record WidePtr {
  var ptr: c_void_ptr;
  var loc: chpl_localeID_t;
}

class Foo {
  var bar: int;
}

export proc create(ref widePtr: WidePtr, bar: int) {
  var foo = new unmanaged Foo(bar);
  widePtr.ptr = __primitive("_wide_get_addr", foo);
  widePtr.loc = __primitive("_wide_get_locale", foo);
}

proc toFoo(ref widePtr: WidePtr) {
  return __primitive("_wide_make", unmanaged Foo, widePtr.loc, widePtr.ptr);
}

export proc destroy(ref widePtr: WidePtr) {
  var foo = toFoo(widePtr);
  delete foo;
}

Compile command: chpl -o error error.chpl

Configuration Information

  • Output of chpl --version: 1.24.1
  • Output of $CHPL_HOME/util/printchplenv --anonymize:
CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: gnu
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: unknown
CHPL_LOCALE_MODEL: flat
CHPL_COMM: gasnet *
  CHPL_COMM_SUBSTRATE: smp *
  CHPL_GASNET_SEGMENT: fast
CHPL_TASKS: qthreads
CHPL_LAUNCHER: smp
CHPL_TIMERS: generic
CHPL_UNWIND: none
CHPL_MEM: jemalloc
CHPL_ATOMICS: cstdlib
  CHPL_NETWORK_ATOMICS: none
CHPL_GMP: bundled
CHPL_HWLOC: bundled
CHPL_REGEXP: re2
CHPL_LLVM: none
CHPL_AUX_FILESYS: none
  • Back-end compiler and version, e.g. gcc --version or clang --version: gcc 10.3.0

The idea of this whole procedure is to be able to export Foo to C as an opaque struct (in the simple example above this could've been achieved with extern record, but I'm interested in a more general case which (currently) cannot be handled by extern record).

Pinging @bradcray, because this issue was discovered after our conversation on Gitter. The only difference with the code you provided on Gitter is that I'm storing both pointer and locale id in a struct, rather than storing locale id in a global variable.