Open Blacksmoke16 opened 3 years ago
This still seems to be happening after #11390 on 1.2.2
. See https://github.com/athena-framework/console/runs/4185063820?check_suite_focus=true.
I don't think this should compile. Suppose that Style
has a substruct T
. Then OutputInterface
's binary representation would be the same as the mixed union IOOutput | T
; the type ID of the active union member, followed by the representation of that member. Since T
contains @output : OutputInterface
, this means T
must be large enough to contain IOOutput | T
, thus a recursive struct is formed. The reason it doesn't reproduce consistently is that LLVM might have been built with assertions disabled.
In fact, weird things happen if you try to subclass Style
nonetheless:
module OutputInterface
end
abstract struct Style
include OutputInterface
@output : OutputInterface
def initialize(@output : OutputInterface); end
end
struct Foo < Style
end
sizeof(OutputInterface) # Stack overflow
module OutputInterface
end
class IOOutput
include OutputInterface
end
abstract struct Style
include OutputInterface
@output : OutputInterface
def initialize(@output : OutputInterface); end
end
struct Foo < Style
end
Foo.new(Foo.new(IOOutput.new)) # Segmentation fault
These crashes are reproducible on 1.0.0 too.
Yeah, this is essentially a recursive struct.
Was able to produce this error when using universal darwin release asset for
1.2.1
:Discovered via https://github.com/athena-framework/console/runs/4042123231?check_suite_focus=true. Reproduces on both MacOS 10 and 11. Does NOT reproduce on Brew installation, or when building this release/master locally. Possibly could just be an LLVM 10 bug that has since been fixed?
Minimal example:
Results in:
No
LLVM-IR
is emitted either.