fasterthanlime , Englisch
@fasterthanlime@hachyderm.io avatar

Good, uhhh.. good morning

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

oooh, tokio does fun things (like automatically boxing your future if it's big and you're in debug mode)

omni ,
@omni@elekk.xyz avatar

@fasterthanlime wow 🥺 thank you tokio

18+ k0nserv ,
@k0nserv@infosec.exchange avatar

@fasterthanlime Why does it stack overflow in debug mode, but not release? Is it just that the futures the compiler generates are much larger in debug?

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@k0nserv I would assume so!

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

I'm learning lldb against my will, send help

dysfun ,
@dysfun@treehouse.systems avatar

@fasterthanlime gotta say i was fairly impressed when i had to do this a couple of years ago. it's not ideal, but it's about as much as you can hope for.

but i was also debugging inline assembly, so maybe my expectations were lowered.

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@dysfun it's not as bad in my 30s, now that I'm no longer fighting it

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

Ah, I see

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

I'm at a loss re: how to make tokio happy across shared object boundaries. Yes there's N copies of tokio's code, now I can't share them because different monomorphizations = missing symbols (the cargo-add-dynamic trick doesn't work with my "cdylib plugins" approach).

Handle::enter across SOs panics. Handle::spawn panics. I thought "mostly" tokio::spawn needed a "current runtime", but "Sleep::new" does too, duh.

I foresee lots of debugging in my future.. god that's a lot of debugging.

dysfun ,
@dysfun@treehouse.systems avatar

@fasterthanlime sorry, not terribly helpful but i never did catch why you were putting async executors into a loadable module?

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@dysfun the module uses a crate that calls tokio::spawn, tokio::time::Sleep::new, etc.

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@dysfun but yeah, maybe the solution is to patch all those crates to allow passing in an executor instead...

dysfun ,
@dysfun@treehouse.systems avatar

@fasterthanlime yeah i don't like when things are running their own executors behind my back

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@dysfun me neither but that would be fine — hickory-resolver has a "Sync" interface which is #[tokio::main] in a trench coat and that works great! It's getting it to use the tokio executor I already have which is a hassle.

cr1901 ,
@cr1901@mastodon.social avatar

@fasterthanlime

>different monomorphizations = missing symbols

Can you elaborate? Why would you get missing symbols?

(Come to think of it, how do you store Rust monomorphizations in a shared object without it being inlined into a fn without generics?)

kinnison ,
@kinnison@fosstodon.org avatar

@fasterthanlime It's a long-shot but would something akin to the rustc shared object work (ie. put tokio et al. into an SO which you link from both your app and your plugin?)

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@kinnison that doesn't work (it's the monomorphization thing): both my app and my plug-in invoke tokio functions with different generic types (often, async blocks which are opaque types) — if you use the libtokio.so from the app with the lib, it has missing symbols. if you use the other, same.

kinnison ,
@kinnison@fosstodon.org avatar

@fasterthanlime Aah bugger :( I admit I've never been brave enough to try and do rust-plugins-to-rust-apps so I'm very interested in your experience. Good luck.

tedmielczarek ,
@tedmielczarek@mastodon.social avatar

@fasterthanlime @kinnison one can read about Swift's implementation of ABI stability for insight into how complex these issues are to solve: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0260-library-evolution.md (I've been really impressed with how the Swift folks have tackled these thorny problems!)

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

OH LORDY LORD I solved it.

The outer and inner "tokio"s had different cfgs, so the layout of tokio::runtime::Handle were different, hence, mutex::lock was falling on some other fields, oh god.

mikaeleiman ,
@mikaeleiman@mastodon.sdf.org avatar

@fasterthanlime Ouch! That could have taken a month or two to figure out…

Alonely0 ,
@Alonely0@mastodon.social avatar

@fasterthanlime lordy lord, indeed.

ivan ,
@ivan@hachyderm.io avatar

@fasterthanlime on one hand, cargo features are a petard we can use to hoist ourselves, on the other hand they let people get their work done on time, so impossible to say if they are bad or not

noah ,
@noah@mastodon.despise.computer avatar

@fasterthanlime wait, does it work now?

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar
fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@noah I mean it's not ideal. very easy to accidentally use the wrong thread-local (but tokio::spawn, Sleep::new, etc. will yell at you that there's no reactor running)

..and the whole tokio code is duplicated in all shared objects but... I actually do not mind in this case, since no code changes required = happy me.

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@noah more importantly, SUPER easy to accidentally enable a different set of tokio features and land on different internal layouts, which uhhh isn't great

noah ,
@noah@mastodon.despise.computer avatar

@fasterthanlime unfortunately that part has no nice solution in rustland

noah ,
@noah@mastodon.despise.computer avatar

@fasterthanlime still the fact that this works at all is amazing

fasterthanlime OP ,
@fasterthanlime@hachyderm.io avatar

@noah yeah! I'm very VERY happy with it — this new structure makes build times & deploy times ridiculously fast for me: I can have a new version of my site up and running around the world in ~2 minutes

nrab ,
@nrab@hachyderm.io avatar

@fasterthanlime i want to learn lldb and it can do some neat stuff but every time I’m reminded how inferior it is to gdb and then I stop learning it

PierreLebeaupin ,
@PierreLebeaupin@mastodon.gougere.fr avatar

@fasterthanlime has it gained support for variants in Dwarf, which is what Rust justifiably uses to provide debug info for enums? Last time I tried this was such a huge hole in my ability to debug Rust that I ended up installing FSF GDB, complete with manual signing step because debuggers need to be code signed these days…

whitequark ,
@whitequark@mastodon.social avatar

@fasterthanlime KITTY EARS

  • Alle
  • Abonniert
  • Moderiert
  • Favoriten
  • random
  • haupteingang
  • Alle Magazine