chapel-lang / chapel

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

Internal Compiler Error with 'channel' type #12242

Closed tmacd8 closed 3 years ago

tmacd8 commented 5 years ago

The enclosed z.chpl program generates an internal compiler error.

Source Code

module m {
  class C {

   var nl: int;
   var C_chnl: channel;

   proc init() {
     nl = 0;
     nl = 0;
   }
 };

 proc main() {
   var b = new owned C();
// writeln("HERE");
 }
}

$ chpl z.chpl z.chpl:7: In initializer: z.chpl:9: internal error: CAL0124 chpl version 1.18.0

Internal errors indicate a bug in the Chapel compiler ("It's us, not you"), and we're sorry for the hassle. We would appreciate your reporting this bug -- please see https://chapel-lang.org/bugs.html for instructions. In the meantime, the filename + line number above may be useful in working around the issue.

Environment info

$ $CHPL_HOME/util/printchplenv --anonymize CHPL_TARGET_PLATFORM: linux64 CHPL_TARGET_COMPILER: gnu CHPL_TARGET_ARCH: native CHPL_LOCALE_MODEL: flat CHPL_COMM: none CHPL_TASKS: qthreads CHPL_LAUNCHER: none CHPL_TIMERS: generic CHPL_UNWIND: none CHPL_MEM: jemalloc CHPL_ATOMICS: intrinsics CHPL_GMP: gmp CHPL_HWLOC: hwloc CHPL_REGEXP: re2 CHPL_AUX_FILESYS: none

Configuration

$ gcc --version gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

bradcray commented 5 years ago

@tmacd8: Thanks for filing this. If this is preventing you from making progress, I believe the fix is to insert an initialization of the C_chnl field after the initialization of nl (the first assignment to it). For example, the following works for me:

   proc init() {
     nl = 0;
     C_chnl = stdout;
     nl = 0;
   }

I believe the problem is that since channel is a generic type, the compiler can't figure out how to default initialize that field on its own. But of course, a useful error message should be generated rather than an internal error.

@benharsh: This seems vaguely related to the internal error you fixed the other week since the second initialization is an assignment, and seems to be failing because it doesn't have a concrete type for this. I also tried putting a this.complete(); between the two assignments to nl which generated the more helpful error message:

testit.chpl:7: In initializer:
testit.chpl:9: error: Cannot default-initialize a variable with generic type
testit.chpl:9: note: 'not-fully-instantiated' has generic type 'channel'

It seems to me that we should get this same (or a similar) error from the original program.

tmacd8 commented 5 years ago

I've already worked around this, so it's not holding me up at all. No hurry on a fix for my sake.

-- TMacD

Why does 0.9999999999..... (forever) equal 1.0? 10n = 9.99999999999999999....

On Mon, Feb 4, 2019 at 11:15 AM Brad Chamberlain notifications@github.com wrote:

@tmacd8 https://github.com/tmacd8: Thanks for filing this. If this is preventing you from making progress, I believe the fix is to insert an initialization of the C_chnl field after the initialization of nl (the first assignment to it). For example, the following works for me:

proc init() { nl = 0; C_chnl = stdout; nl = 0; }

I believe the problem is that since channel is a generic type, the compiler can't figure out how to default initialize that field on its own. But of course, a useful error message should be generated rather than an internal error.

@benharsh https://github.com/benharsh: This seems vaguely related to the internal error you fixed the other week since the second initialization is an assignment, and seems to be failing because it doesn't have a concrete type for this. I also tried putting a this.complete(); between the two assignments to nl which generated the more helpful error message:

testit.chpl:7: In initializer: testit.chpl:9: error: Cannot default-initialize a variable with generic type testit.chpl:9: note: 'not-fully-instantiated' has generic type 'channel'

It seems to me that we should get this same (or a similar) error from the original program.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chapel-lang/chapel/issues/12242#issuecomment-460332125, or mute the thread https://github.com/notifications/unsubscribe-auth/Aswjc5twPM3SZ8nPeizjhAMPtJcycwO2ks5vKGrFgaJpZM4afpXO .

cassella commented 4 years ago

On master today, (after adding use IO; in the module m), I get

foo.chpl:8: In initializer:
foo.chpl:10: error: the type of the actual argument 'this' is generic
note: generic actual arguments are not currently supported

line 10 is now the second nl = 0 line.

daviditen commented 3 years ago

Thanks @tmacd8 and @cassella! I've added two versions of this code to our test system that demonstrate that we now get reasonable errors for this case instead of internal compiler errors in #18573.