HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.11k stars 648 forks source link

Compiler crash using Hxb writer config #11512

Closed PXshadow closed 7 months ago

PXshadow commented 7 months ago

Trying to test the branch of Hxb writer config #11507 using go2hx's codebase.

Steps to reproduce:

git clone https://github.com/go2hx/go2hx
cd go2hx
haxelib dev go2hx .
haxelib run go2hx build
haxelib run go2hx hxb
 haxe tests/tests.hxml -D unit -D hxb -D count=1

Output:

tests/Tests.hx:101: [./tests/unit/a26.go]
tests/Tests.hx:102: 1
tests/Tests.hx:103: 0
listening on local port: 6269
nodejs server started
accepted connection
accepted connection
Generated: golibs//A26.hx - 0.445kb
Generated: golibs/unit_a26.hxml - 0.028kb
tests: 0 tasks: 0 running: 0 []
hl|a26|false|0.564552025985904
Error: Compiler failure: typedef stdgo._internal.reflect.Kind is already initialized to TAbstract(Int, []), but new init to TType(stdgo.GoUInt, []) was attempted
Please submit an issue at https://github.com/HaxeFoundation/haxe/issues/new
Attach the following information:
Haxe: 5.0.0-alpha.1+26f763a; OS type: unix;
File "src/compiler/hxb/hxbReader.ml", line 1571, characters 170-177
Called from file "src/compiler/hxb/hxbReader.ml", line 1761, characters 3-20
Called from file "src/compiler/hxb/hxbReader.ml", line 1964, characters 2-23
Called from file "src/compiler/hxb/hxbReader.ml", line 1994, characters 4-24
Called from file "src/compiler/hxb/hxbReader.ml", line 1999, characters 3-9
Called from file "src/typing/typeloadModule.ml", line 823, characters 10-20
Called from file "src/context/typecore.ml", line 440, characters 4-7
Called from file "src/typing/typeloadModule.ml", line 891, characters 31-91
Called from file "src/typing/typeload.ml", line 194, characters 2-33
Called from file "src/typing/typeload.ml" (inlined), line 203, characters 9-39
Called from file "src/typing/typeload.ml", line 210, characters 2-48
Called from file "src/typing/typeload.ml", line 415, characters 11-96
Called from file "src/typing/typeload.ml", line 449, characters 10-43
Called from file "src/typing/typeload.ml", line 640, characters 2-45
Called from file "src/typing/typer.ml", line 2002, characters 10-47
Called from file "src/typing/typer.ml", line 1890, characters 10-35
Called from file "src/std.ml", line 26, characters 6-9
Called from file "src/typing/typer.ml", line 718, characters 13-104
Called from file "list.ml", line 92, characters 20-23
Called from file "src/typing/typer.ml", line 707, characters 10-1023
Called from file "src/typing/typer.ml", line 770, characters 27-94
Called from file "src/typing/typer.ml", line 773, characters 9-19

Error: Compiler failure: typedef stdgo._internal.reflect.Kind is already initialized to TAbstract(Int, []), but new init to TType(stdgo.GoUInt, []) was attempted
Please submit an issue at https://github.com/HaxeFoundation/haxe/issues/new
Attach the following information:
Haxe: 5.0.0-alpha.1+26f763a; OS type: unix;
File "src/compiler/hxb/hxbReader.ml", line 1571, characters 170-177
Called from file "src/compiler/hxb/hxbReader.ml", line 1761, characters 3-20
Called from file "src/compiler/hxb/hxbReader.ml", line 1964, characters 2-23
Called from file "src/compiler/hxb/hxbReader.ml", line 1994, characters 4-24
Called from file "src/compiler/hxb/hxbReader.ml", line 1999, characters 3-9
Called from file "src/typing/typeloadModule.ml", line 823, characters 10-20
Called from file "src/context/typecore.ml", line 440, characters 4-7
Called from file "src/typing/typeloadModule.ml", line 891, characters 31-91
Called from file "src/typing/typeload.ml", line 194, characters 2-33
Called from file "src/typing/typeload.ml" (inlined), line 203, characters 9-39
Called from file "src/typing/typeload.ml", line 210, characters 2-48
Called from file "src/typing/typeload.ml", line 415, characters 11-96
Called from file "src/typing/typeload.ml", line 449, characters 10-43
Called from file "src/typing/typeload.ml", line 640, characters 2-45
Called from file "src/typing/typer.ml", line 2002, characters 10-47
Called from file "src/typing/typer.ml", line 1890, characters 10-35
Called from file "src/std.ml", line 26, characters 6-9
Called from file "src/typing/typer.ml", line 718, characters 13-104
Called from file "list.ml", line 92, characters 20-23
Called from file "src/typing/typer.ml", line 707, characters 10-1023
Called from file "src/typing/typer.ml", line 770, characters 27-94
Called from file "src/typing/typer.ml", line 773, characters 9-19

tests/Tests.hx:250: build error: haxe [golibs/unit_a26.hxml,--hl,golibs/unit_a26.hl,--hxb-lib,go2hx.zip]
Simn commented 7 months ago

Did you change some node.js thing? I'm getting this again:

C:\git\go2hx>haxe tests/tests.hxml -D unit -D hxb -D count=1
tests/Tests.hx:101: [./tests/unit/a26.go]
tests/Tests.hx:102: 1
tests/Tests.hx:103: 0
listening on local port: 6220
nodejs server started
child process exited: 1
null
null
child process exited: 1
null
null
child process exited: 1
null
null
child process exited: 1
null
null
child process exited: 1
null
null
child process exited: 1
null
null
Error: Command failed with error 1
PXshadow commented 7 months ago

Sorry my bad for the complications, it's an issue with nodejs running an executable (don't know how to make it cross platform and unrelated).

So for the last step instead run:

haxe rnd/rnd.hxml -D hxb
Simn commented 7 months ago
C:\git\go2hx>haxelib run go2hx build
C:/git/go2hx/stdgo/_internal/internal/Macro.macro.hx:43: non hxb types:,0
Already up to date.
build go part of the compiler

C:\git\go2hx>haxelib run go2hx hxb
C:/git/go2hx/stdgo/_internal/internal/Macro.macro.hx:43: non hxb types:,0
setting up Hxb
Generate Go
Run Compiler
C:/git/go2hx/stdgo/_internal/internal/Macro.macro.hx:43: non hxb types:,0
Already up to date.
build go part of the compiler
Interp compiler version
Golang compiler instance
listening on local port: 6140
accepted connection
Generated: golibs/_internal/github_com/go2hx/go4hx/scripts/hxb/Hxb.hx - 0.742kb
stdgo/_internal/internal/Macro.macro.hx:21: hxb types:,286
(unknown) : Warning : (WUnboundTypeParameter) Unbound type parameter stdgo.Slice.T
(unknown) : Warning : (WUnboundTypeParameter) Unbound type parameter stdgo._internal.sync.atomic_.Pointer_.T_

C:\git\go2hx>haxe rnd/rnd.hxml -D hxb
Golang compiler instance
listening on local port: 6294
accepted connection
Generated: golibs/_internal/github_com/go2hx/go4hx/rnd/Rnd.hx - 0.203kb
haxe -cp golibs extraParams.hxml -main _internal.github_com.go2hx.go4hx.rnd.Rnd -hl runrnd.hl
stdgo/_internal/internal/Macro.macro.hx:43: non hxb types:,224
hl runrnd.hl

~~~~~~~~~~~~expected~~~~~~~~~~~~
hello world

C:\git\go2hx>

Edit: --times suggests that hxb is not being used at all:

name          | time(s) |   % |  p% |      # | info
----------------------------------------------
command       |   7.397 |  73 |  73 |      3 |
  hl          |   6.276 |  62 |  85 |      1 | haxe -cp golibs extraParams.hxml -main _internal.github_com.go2hx.go4hx.rnd.Rnd -hl runrnd
  hl          |   0.685 |   7 |   9 |      1 | hl runrnd
  /rnd        |   0.435 |   4 |   6 |      1 | go run
interp        |   1.367 |  13 |  13 |    592 |
  jit         |   0.066 |   1 |   5 |    589 |
  add_types   |   0.012 |   0 |   1 |      1 |
typing        |   0.372 |   4 |   4 |      1 |
analyzer      |   0.326 |   3 |   3 | 159553 |
filters       |   0.283 |   3 |   3 |  27783 |
parsing       |   0.225 |   2 |   2 |    352 |
macro         |   0.166 |   2 |   2 |    759 |
  jit         |   0.011 |   0 |   7 |    745 |
----------------------------------------------
total         |  10.143 | 100 | 100 | 189046 |
PXshadow commented 7 months ago

I added the -D hxb to rnd, in the last commit, perhaps pull and see if that does it?

Simn commented 7 months ago

Ah yeah, that does it. Thanks!

Simn commented 7 months ago

This is very fun to investigate... question: Is there an enum abstract over (something resolving to) that Kind type somewhere?

Edit: Found it: enum abstract KindType(stdgo._internal.reflect.Reflect.Kind)

The problem is that the compiler tries to figure out what kind of enum abstract we have, and in doing so unifies the underlying type against Int. That underlying type is still a monomorph though, so it ends up becoming Int. This means that there's essentially a race condition between the abstract and the typedef, and it only works if the latter comes in first. Notably, this is not about chunk order within a given hxb module - the problem is that we handle an abstract from (non-hxb) module A before reading the TDD chunk from (hxb) module B.

Simn commented 7 months ago

The linked commit makes this work for now. I'm not sure if this is the correct thing to do here, but at least it should allow you to continue testing.

Simn commented 7 months ago

Closed by #11507