Stream: advent of code

Topic: 2024 AoC Template - bug roc_fx_stdinReadToEnd


view this post on Zulip Scally (Nov 17 2024 at 21:04):

FYI I tried it today pretty much with the code you've provided and some simple returns in part1 and part2 and it crashed with

thread '<unnamed>' panicked at crates/compiler/mono/src/ir.rs:6162:56:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x619d6db6a8ab - <unknown>
   1:     0x619d6ce2c1e0 - <unknown>
   2:     0x619d6db66113 - <unknown>
   3:     0x619d6db6a644 - <unknown>
   4:     0x619d6db6c1a0 - <unknown>
   5:     0x619d6db6bebf - <unknown>
   6:     0x619d6db6c6be - <unknown>
   7:     0x619d6db6c589 - <unknown>
   8:     0x619d6db6ada6 - <unknown>
   9:     0x619d6db6c324 - <unknown>
  10:     0x619d6cd21e75 - <unknown>
  11:     0x619d6cd21f33 - <unknown>
  12:     0x619d6cd21dc6 - <unknown>
  13:     0x619d6d699d75 - <unknown>
  14:     0x619d6d68ce14 - <unknown>
  15:     0x619d6d67b442 - <unknown>
  16:     0x619d6d6a8339 - <unknown>
  17:     0x619d6d68a44e - <unknown>
  18:     0x619d6d6b8330 - <unknown>
  19:     0x619d6d68f6cf - <unknown>
  20:     0x619d6d6b5ac2 - <unknown>
  21:     0x619d6d6b6306 - <unknown>
  22:     0x619d6d6b94f7 - <unknown>
  23:     0x619d6d6b8661 - <unknown>
  24:     0x619d6d68f6cf - <unknown>
  25:     0x619d6d6a85de - <unknown>
  26:     0x619d6d68a44e - <unknown>
  27:     0x619d6d6832fa - <unknown>
  28:     0x619d6d6809b7 - <unknown>
  29:     0x619d6d585444 - <unknown>
  30:     0x619d6d50e2c6 - <unknown>
  31:     0x619d6d503c0e - <unknown>
  32:     0x619d6d50f535 - <unknown>
  33:     0x619d6db71f05 - <unknown>
  34:     0x782ff1ea339d - <unknown>
  35:     0x782ff1f2849c - <unknown>
  36:                0x0 - <unknown>

When not calling AoC.solve it works just fine

view this post on Zulip Luke Boswell (Nov 18 2024 at 00:18):

Can you share the code you used? I'd like to repro if I can

view this post on Zulip Luke Boswell (Nov 18 2024 at 00:19):

It'd be nice to give a better error message than a rust panic

view this post on Zulip Scally (Nov 18 2024 at 00:28):

Running the exact code you've sent results in

An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
Undefined Symbol in relocation, (+e2a2, Relocation { kind: PltRelative, encoding: Generic, size: +20, target: Symbol(SymbolIndex(+e5)), addend: +fffffffffffffffc, implicit_addend: false }): Ok(Symbol { name: "roc_fx_stdinReadToEnd", address: +0, size: +0, kind: Unknown, section: Undefined, scope: Unknown, weak: false, flags: Elf { st_info: +10, st_other: +0 } })
Location: crates/linker/src/elf.rs:1452:25

Changing the bottom lines to

part1 : Str -> Result Str _
part1 = \_ -> Ok "Foo"

part2 : Str -> Result Str _
part2 = \_ -> Ok "Bar"

Results in the error provided above.

I didn't share code because it's pretty much exactly the code you've sent :sweat_smile:

view this post on Zulip Luke Boswell (Nov 18 2024 at 00:29):

Ok, this looks like an issue with the new roc_fx_stdinReadToEnd I just added.

view this post on Zulip Luke Boswell (Nov 18 2024 at 00:30):

I think I know what it is...

view this post on Zulip Luke Boswell (Nov 18 2024 at 00:32):

I didn't add roc_fx_stdinReadToEnd to our pub fn init() { thing which protects the vicious rust GC from removing what it thinks is dead code. That must only be relevant for Linux, and doesn't materialise as an issue on Macos. I didn't add an integration test for it, so we didn't pick it up in CI :man_facepalming:.

view this post on Zulip Luke Boswell (Nov 18 2024 at 00:33):

Would you be interested in trying a fix for me? if you add roc_fx_stdinReadToEnd and then build basic-cli locally, does it still give you this error?

view this post on Zulip Scally (Nov 18 2024 at 00:33):

:salute: :sweat_smile: always happy to dig up bugs :laughter_tears:

view this post on Zulip Luke Boswell (Nov 18 2024 at 00:33):

You can build basic-cli using roc build.roc... but then you will need to use a relative path to platform/main.roc instead of a URL for the platform.

view this post on Zulip Notification Bot (Nov 18 2024 at 00:37):

10 messages were moved here from #advent of code > 2024 AoC Template by Luke Boswell.

view this post on Zulip Scally (Nov 18 2024 at 00:51):

I'll try in a bit or tomorrow

view this post on Zulip Anton (Nov 19 2024 at 16:14):

I plan to do a new basic-cli release this week, so I've gone ahead and put up a fix in https://github.com/roc-lang/basic-cli/pull/268,


Last updated: Jul 06 2025 at 12:14 UTC