asoffer / Icarus

An experimental general-purpose programming language
Apache License 2.0
9 stars 2 forks source link

stdlib/string/split.ic Split2 scope is broken #102

Closed perimosocordiae closed 2 years ago

perimosocordiae commented 2 years ago

Repro:

str ::= import "string/split.ic"
io ::= import "io.ic"

str.Split2("foo::bar::baz", "::") do [s: []char] {
  io.Print(s, !\n)
}

Result with some stack frames elided:

*** SIGSEGV received at time=1640833027 on cpu 1 ***
PC: @          0x2fb22b8  (unknown)  (unknown)
    @          0x18fd5f0         64  absl::WriteFailureInfo()
    @          0x18fd2d4        224  absl::AbslFailureSignalHandler()
    @     0x7f6fc719d520  280785504  (unknown)
    @          0x1359d80        928  compiler::(anonymous namespace)::VerifyArithmeticOperator<>()
    @          0x189f8be         48  ast::BinaryOperator::Accept()
    @          0x189fe0e         48  ast::Cast::Accept()
    @          0x13d6098        928  _ZN8compiler15VerifyArgumentsB5cxx11ERNS_8CompilerEN4absl4SpanIKN3ast4Call8ArgumentEEERN2ir20CompleteResultBufferE
    @          0x189fd4e         48  ast::Call::Accept()
    @          0x189f73e         48  ast::Assignment::Accept()
    @ ... and at least 27 more frames
Segmentation fault (core dumped)
asoffer commented 2 years ago

There's a bug in Split as well. It's a miscompile I haven't fully diagnosed yet. Either we're using a stale load/store-cache or returning non-register-sized values has a bug.