chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.76k stars 413 forks source link

Internal error with extern linked-list-like data structure relying on a type alias #18183

Open bmcdonald3 opened 2 years ago

bmcdonald3 commented 2 years ago

Summary of Problem

While working to get the Apache Arrow header files working with c2chapel, I was hitting an internal error with the below snippet of code. I explored the error a bit with @bradcray, and we observed that it seemed to be happening due to a AST node being replaced, but we were unable to figure out if that should be happening/what was causing the error.

Steps to Reproduce

Source Code:

use SysCTypes;
use CPtr;

extern record _GHook {
  var next : c_ptr(GHook);
}

extern type GHook = _GHook;

Compiling this program (using CHPL_LLVM=none) with chpl ghook.chpl ghook.chpl:8: internal error: assertion error [resolution/postFold.cpp:105]`

[edit: to someone compiling in non-developer mode, this error shows up as: internal error: RES-POS-OLD-0105 chpl version 1.25.0 pre-release (3df047aa28)

Commenting out line 5 resolves the error.

Configuration Information

bradcray commented 2 years ago

Interesting note: If I add --ignore-errors to the chpl command-line, I get all the way through to the C compilation step. Given the nature of the assertion ("Is this thing still in the AST?"), I was not expecting this.

bradcray commented 2 years ago

Some other interesting observations:

@bmcdonald3 : Based on this, I'd try using the workaround in the first bullet for your 20,000 line file and see if that gets you through compilation as a workaround. We should still understand/fix this issue (internal errors are bad), but if that gets you unblocked, I'd run with it.

[edit: I renamed the issue to be a bit more precise as a result of these observations]

bmcdonald3 commented 2 years ago

@bradcray Great, thanks for digging into this, glad to have the Arrow headers (hopefully) working fully now!

edit: there are quite a few instances of this in the generated code, so while I was eventually able to sort through all of them, there are a bunch of these in the arrow code.