18511, "twesterhout", "Internal compiler error because of _wide_make", "2021-10-02T14:07:45Z"
opened 02:07PM - 02 Oct 21 UTC
<!--
If you are filing an issue that is not a bug report, please feel free to e… rase
this template and describe the issue as clearly as possible.
-->
### Summary of Problem
<!--
What behavior did you observe when encountering this issue?
What behavior did you expect to observe?
Is this a blocking issue with no known work-arounds?
-->
Trying to use `_wide_make` results in internal error.
### Steps to Reproduce
**Source Code:**
```chapel
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](https://matrix.to/#/!PBYDSerrfYujeStENM:gitter.im/$9oAZwRdLpdDTUgGvPUzqqnJmAZD80T2vJoH3-ZKHk5o?via=gitter.im&via=matrix.org) on Gitter is that I'm storing both pointer and locale id in a struct, rather than storing locale id in a global variable.
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.