Stream: beginners

Topic: File example crashes


view this post on Zulip Fyzics (Nov 20 2023 at 21:17):

Re: https://www.reddit.com/r/ProgrammingLanguages/comments/17zp4m7/comment/ka23kwi/
@Richard Feldman

OS: Linux
Kernel: 6.6.1-arch1-1
Roc version: nightly pre-release, built from commit 48e9b53 on So 19 Nov 2023 09:07:19 UTC

Steps:

git clone https://github.com/roc-lang/roc.git
cd roc/examples/cli
roc build file.roc
./file

Error:

#FISH
cwd: /home/dev/programs/rocgit/examples/cli
Dir.list...
munmap_chunk(): invalid pointer
fish: Job 1, './file' terminated by signal SIGABRT (Abort)

#BASH
cwd: /home/dev/programs/rocgit/examples/cli
Dir.list...
munmap_chunk(): invalid pointer
Aborted (core dumped)

view this post on Zulip Richard Feldman (Nov 20 2023 at 21:52):

thanks for reporting this! Would you mind sharing what Linux distro this was?

view this post on Zulip Richard Feldman (Nov 20 2023 at 21:52):

might help us reproduce

view this post on Zulip Brendan Hansknecht (Nov 20 2023 at 21:59):

I'm pretty sure this is an old issue that I have looked at a few times and am still confused by.

view this post on Zulip Richard Feldman (Nov 20 2023 at 22:01):

interesting - when I dbg the error, it's showing NotSeekable - @Luke Boswell any ideas on why basic-cli would be giving a NotSeekable error there? Maybe a glue issue, and the value is coming across wrong?

view this post on Zulip Fyzics (Nov 20 2023 at 22:06):

Richard Feldman said:

thanks for reporting this! Would you mind sharing what Linux distro this was?

EndeavourOS Linux x86_64

view this post on Zulip Richard Feldman (Nov 20 2023 at 22:07):

thanks!

view this post on Zulip Richard Feldman (Nov 20 2023 at 22:08):

@Brendan Hansknecht any chance your recent glue updates would fix this in basic-cli 0.6, or at least change the error in a way that gives a clue what the problem is?

view this post on Zulip Brendan Hansknecht (Nov 20 2023 at 22:18):

not that I know of. But maybe changing to passing pointers for glue functions might fix this.

view this post on Zulip Brendan Hansknecht (Nov 20 2023 at 22:18):

In general I think Dir.list has been broken for a long while due to some strange memory bug. It may also be what is breaking #beginners > listing files in a directory

view this post on Zulip Brendan Hansknecht (Nov 20 2023 at 22:19):

Been a while since I looked at any of this, so would have to refresh myself

view this post on Zulip Luke Boswell (Nov 20 2023 at 22:25):

Dir.list is definitely broken on basic cli. I just fixed it for basic webserver yesterday. We can copy-paste that implementation and it should be identical. (on my phone rn)

view this post on Zulip Luke Boswell (Nov 20 2023 at 22:26):

I was thinking this morning before work I should make a PR for that before someone runs into that issue. :upside_down:

view this post on Zulip Jakub (Nov 20 2023 at 22:28):

@Brendan Hansknecht @Luke Boswell how difficult is fixing this type of bug for a person who only has a vague of how Rust and how compilers work? is it more like:

view this post on Zulip Luke Boswell (Nov 20 2023 at 22:28):

Im not sure about the NotSeekable error specifically, I can look into it but I'm pretty sure the current implementation just returns a hardcoded Error tag.

view this post on Zulip Luke Boswell (Nov 20 2023 at 22:30):

This is super easy really. There is an identical implementation working in basic-webserver that can be copied into basic-cli. Its in the platform/src/lib.rs file. Both called dirList. Acutally I think roc_fx_dirList and dir_list.

view this post on Zulip Jakub (Nov 20 2023 at 22:36):

found it, todo!("handle Dir.list error"); might be the reason ;)

view this post on Zulip Brendan Hansknecht (Nov 20 2023 at 22:40):

Oh, I just realized that this is using the file.roc from the roc repo, which uses the super old fork of basic cli. I think that we should really remove that old fork of basic cli and make these either:

  1. depend on the package url
  2. use git submodules to import the real basic cli.

As it stands, we are just asking for extra bugs and confusion.

view this post on Zulip Luke Boswell (Nov 20 2023 at 22:41):

We wanted to keep some examples in the repository for testing reasons. Maybe these should be moved out of the examples folder and deeper into a testing crate?

view this post on Zulip Luke Boswell (Nov 20 2023 at 22:42):

A lot of people click on the examples folder in the top level of the repository

view this post on Zulip Brendan Hansknecht (Nov 20 2023 at 22:44):

I know, I strongly think we should re-evaluate that for anything basic-cli, basic-cli lives elsewhere now. Also, yeah, anything depending on a local basic-cli should move to cli testing examples. We can still have examples that use the proper distribution of basic cli

view this post on Zulip Brendan Hansknecht (Nov 20 2023 at 22:48):

Also, NotSeekable and Other are 1 away from each other in the enum. Maybe something is off by one or glue needs to be regenerated? Not fully sure, but it should be returning Other according to the current source code. Some reason, that is just becoming a NotSeekable I guess it is also possible that it is a dbg bug.

view this post on Zulip Roberto Rodriguez Jr (Nov 20 2023 at 23:22):

cwd: /home/bob/roc/examples/cli
Dir.list...
fish: Job 1, 'roc run file.roc' terminated by signal SIGSEGV (Address boundary error)

roc build file.roc
:hammer: Rebuilding platform...
0 errors and 0 warnings found in 590 ms while successfully building:
file

./file echo.roc
cwd: /home/bob/roc/examples/cli
Dir.list...
fish: Job 1, './file echo.roc' terminated by signal SIGSEGV (Address boundary error)

./file
cwd: /home/bob/roc/examples/cli
Dir.list...
fish: Job 1, './file' terminated by signal SIGSEGV (Address boundary error)

Just wanted to update that it still fails? Im a n00b.


Last updated: Jul 05 2025 at 12:14 UTC