Stream: contributing

Topic: basic-webserver release


view this post on Zulip Anton (Nov 19 2023 at 13:37):

When trying to build the basic-webserver platform I'm hitting Undefined Symbol in relocation like in #3609 when on linux x86-64. I can build with the legacy linker and builds for all other OS' and architectures passed. Should we still do a release of basic-webserver if it does not work on linux x86-64 with the surgical linker @Richard Feldman?

view this post on Zulip Richard Feldman (Nov 19 2023 at 13:43):

I'd say yes :+1:

view this post on Zulip Richard Feldman (Nov 19 2023 at 13:44):

it's worth it to get something all the new beginners will be able to try with a URL tomorrow

view this post on Zulip Richard Feldman (Nov 19 2023 at 13:44):

we can tell people to work around it with --linker=legacy for now

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 16:46):

Assuming my code works correctly, roc should automatically use the legacy linker when it realizes there is no surgical linker file

view this post on Zulip Anton (Nov 19 2023 at 16:58):

Awesome, I'll try that out

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 17:01):

Also, I think this may be a bug caused by rust dead code elimination, I'll take a look. Oh, maybe I can also make rust glue for functions generate the special code to avoid garbage collection of our effect functions....

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 17:11):

Is this on main?

view this post on Zulip Anton (Nov 19 2023 at 17:17):

I got the undefined symbol in relocation while using the more-features of basic-webserver, I was also using export CARGO_BUILD_TARGET=x86_64-unknown-linux-musl

view this post on Zulip Anton (Nov 19 2023 at 17:18):

roc should automatically use the legacy linker when it realizes there is no surgical linker file

That worked, I did end up getting a segfault when running the example on NixOS, going to try out macos aarch64 now.

view this post on Zulip Anton (Nov 19 2023 at 18:00):

macos aarch64 test succeeded

view this post on Zulip Anton (Nov 19 2023 at 18:00):

going to try out ubuntu now

view this post on Zulip Anton (Nov 19 2023 at 18:19):

segfault on Ubuntu too when running the todos example.
To prevent setting a large share of users up for disappointment I think we should not make an official release of the basic-webserver platform right now. What do you think @Richard Feldman?

It's still an amazing feat we got the webserver this far though :heart:

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 18:28):

Interesting. I wonder why it segfaults for you. gotta love works on my machine.

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 18:28):

I'll do more testing later

view this post on Zulip Luke Boswell (Nov 19 2023 at 18:30):

Is it just todos that is segfaulting?

view this post on Zulip Luke Boswell (Nov 19 2023 at 18:33):

I wonder if the sqlite db I created on arm64 isn't ok when used on linux-x64, I assumed it would be identical because it's the sqlite format but maybe not. I did a quick search and that was inconclusive

view this post on Zulip Luke Boswell (Nov 19 2023 at 18:37):

Oh, are you testing using current main or that PR branch? Current main will be broken on all other systems except macos arm64 because glue generates invalid rust code and you have to fix manually. On the PR branch I went through and fixed for all architectures so that should be ok.

view this post on Zulip Anton (Nov 19 2023 at 18:56):

I should be using the more-features branch everywhere. The Linux .o is also built for musl, so the segfault may only replicate with that target. I ran without DB_PATH on Linux so it should not be the sqlite3 file that causes the segfault. I did not test the other examples but the todos is the most important one.

view this post on Zulip Anton (Nov 19 2023 at 19:00):

This is the pre-release url btw:
https://github.com/roc-lang/basic-webserver/releases/download/temp-test-0-1/znf7xalzBi9Wn8vSrgw1YIEd2XcqAvgg8EDZiH4lPGs.tar.gz

view this post on Zulip Luke Boswell (Nov 19 2023 at 19:36):

I can reproduce the segfaults on my linux machine :cry:

view this post on Zulip Luke Boswell (Nov 19 2023 at 19:51):

@Brendan Hansknecht I am highly suspicious of the glue issues (https://github.com/roc-lang/roc/issues/6012) though I don't think this is likely the cause of this issue.

I don't think we ever tested previous versions on linux so it could be a more fundamental issue with the implementation of the server.

I don't think it is hyper as it boots up the server and binds to localhost, and looks like it accepts a connection. Maybe it fails as soon as it calls into Roc (the force_thunk method on RocFunction_86 closure related or something)?

view this post on Zulip Richard Feldman (Nov 19 2023 at 19:55):

so it segfaults even when using the legacy linker?

view this post on Zulip Richard Feldman (Nov 19 2023 at 20:03):

to answer the question directly: if we can't get it working, I actually still think we should release 0.1 (with a prominent note that Linux isn't supported yet) just so some beginners can try it easily.

Regardless of whether there's a release, Linux users won't be able to use it at all. At least if there's a release, people on other operating systems can try it without needing Rust installed etc.

view this post on Zulip Richard Feldman (Nov 19 2023 at 20:04):

in fact I'd be fine with saying just go ahead and release 0.1 right now, add prominent notes that it won't work on Linux, and then we can plan to do an 0.1.1 release that fixes Linux as soon as we can figure out a fix! :smiley:

view this post on Zulip Richard Feldman (Nov 19 2023 at 20:10):

@Brendan Hansknecht you mentioned it works on your machine - is that an x64 Linux machine?

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

Ok yeah, I see the segfault. Probably tested something local before

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

Not yet sure what is going on, but it seems that the string being passed to stdout.line does not make sense (maybe it is a seemless slice or small string being handled incorrectly). Commenting out the logging in the todo.roc fixes the issue.

So maybe a bug in RocStr, maybe a bug in roc code gen.

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 21:00):

hmm, may also be some sort of pointer passing related change. I think some reason roc stdoutline expects a return value now? @Folkert de Vries maybe a bug in your resent changes around cabi always using pointers?

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 21:01):

oh wait, actually, it is supposed to return a result with error.

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 21:14):

Oh, so this is just a simply function glue mismatch. I think roc_fn needs to be regenerated

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 21:16):

Claims to return nothing:
https://github.com/roc-lang/basic-webserver/blob/a9b32ff9425095d51d08928c433bf064176cbd11/platform/src/roc_fn/src/lib.rs#L63-L66

Claims to return an error:
https://github.com/roc-lang/basic-webserver/blob/a9b32ff9425095d51d08928c433bf064176cbd11/platform/Effect.roc#L47

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 21:17):

so we should just need to make those match. Either drop the return type from the roc side or regenerate the function glue and change the rust type to return an error.

view this post on Zulip Richard Feldman (Nov 19 2023 at 21:18):

oh I definitely think those shouldn't return an error

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 21:18):

This probably also effects flush

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

(we can have a more advanced version that returns an error, but the 99% use case is to assume writing to stdout will succeed)

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

Yeah, in that case, we should just need to update the roc side to fix the segfault

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

nice! Can you make a PR for that?

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

Should flush return an error? I assume not as well?

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

let's have it not for now, can revisit in the future if necessary

view this post on Zulip Brendan Hansknecht (Nov 19 2023 at 21:29):

https://github.com/roc-lang/basic-webserver/pull/10

view this post on Zulip Richard Feldman (Nov 19 2023 at 21:38):

@Anton I assume you're done for the day, but if you can verify that it works on x64 Linux for you and cut a release tomorrow, that would be fantastic! :smiley:

view this post on Zulip Richard Feldman (Nov 19 2023 at 21:39):

given time zones, I think the math works out that we could have that on the site in time for the release :big_smile:

view this post on Zulip Luke Boswell (Nov 19 2023 at 21:42):

Thank you @Brendan Hansknecht so glad you found that!! Sorry for breaking it :smiling_face_with_tear: . I was part way through changing them all over to return errors, and then aborted the change and didnt undo it properly as it had the flush addition.

view this post on Zulip Anton (Nov 20 2023 at 09:57):

Awesome work @Brendan Hansknecht! A new release is building

view this post on Zulip Anton (Nov 20 2023 at 11:01):

:tada: release is up

view this post on Zulip Agus Zubiaga (Nov 20 2023 at 12:58):

Release is working well! I already used it in the new roc-pg example: https://github.com/agu-z/roc-pg/tree/main/examples/store


Last updated: Jul 06 2025 at 12:14 UTC