00:44 < bridge> are github/gitlab written in ruby? 00:45 < bridge> same as the C libraries — using asm. there's no other way, neither for C nor for Rust as far as I'm aware 01:12 < bridge> (yes, both. GitLab: https://gitlab.com/gitlab-org/gitlab shows `Ruby: 69.2%`; for GitHub the percentage is lower but still) 01:50 < bridge> modern amd boards can have usb4 which is pretty much on par 01:58 < bridge> it’s 5th gen 02:01 < bridge> usb 4 seems cool 02:01 < bridge> never used it 04:42 < bridge> gm bois 04:44 < bridge> gm teero 04:44 < bridge> why up so early? 09:27 < bridge> ill 09:27 < bridge> I asked how I should do some thing at work, and here's the answer: 09:27 < bridge> > Think for yourself and face the consequences of your decisions. 😛 12:08 < bridge> https://docs.rs/splitbits/0.1.2/splitbits/ 12:08 < bridge> interesting crate, you can use `splitbits!(0b11110000, "aaabbbbb");` to parse a byte into two bit fields 12:34 < bridge> https://docs.rs/bitmatch/0.1.1/bitmatch/ even more interesting 😄 12:34 < bridge> I should write a CPU emulator now using this ^^ 13:22 < bridge> looks nice 13:22 < bridge> it wouyld be nice to tell docs.rs to regenerate docs using latest rustdocs 13:22 < bridge> the page doesnt even support dark theme 13:23 < bridge> 4 year ago last update 14:30 < bridge> This might be the coolest macro I've seen yet 14:32 < bridge> actually this might help my riscv emu 14:33 < bridge> https://shafik.github.io/c++/llvm/2024/10/17/triaging-clang-fronend-bugs.html 15:08 < bridge> hey are the skin proportions and stuff available somewhere? 15:08 < bridge> $wiki skin render 15:08 < bridge> $skin 15:08 < bridge> This command was not found. 15:08 < bridge> $wiki skin 15:08 < bridge> C'mon 15:08 < bridge> We had them saved somewhere 15:08 < bridge> $wiki pleas help 15:14 < bridge> $wiki skin rendering 15:14 < bridge> weird, shouldn't this find https://wiki.ddnet.org/wiki/Development#About_Tee_Skin_Rendering ? 15:18 < bridge> @teero777 there you have it 15:18 < bridge> You can continue writing your OpenGL 4.6 x OpenGL 2.1 mix renderer 15:25 < bridge> thanks 16:49 < bridge> i wanna buy a flipper zero 17:00 < bridge> yea 17:00 < bridge> they look fun 17:02 < bridge> I was right about to buy one, then I thought, what would I really do with one 17:04 < bridge> If you want a software defined radio to mess with something like a hackrf one is much more capable 17:05 < bridge> I (permanently? lol) borrowed a hackrf but haven't done a lot with it yet 17:05 < bridge> I tried to clone some gate remote with it 17:06 < bridge> but I'm bad at signal processing, it turns out 17:06 < bridge> should learn more about that… 17:08 < bridge> Well a lot of things now are immune to simple replay attacks 17:12 < bridge> well, it's one-way communication and not time-based 17:12 < bridge> so if the gate does not receive any signal from the remote and I record one "open" signal, the gate should open when I play it back near the gate 17:13 < bridge> but I didn't even manage to do that 17:14 < bridge> Not time based as in it doesn't contain an RTC or as in the signal never changes no matter how many times you press the button? Because rolling codes are a thing 17:15 < bridge> does not contain an RTC 17:15 < bridge> it's a rolling code 17:15 < bridge> but my proposed setup should work for a rolling code 17:15 < bridge> did you make sure you record the signal where the receiver didn't get it? 17:15 < bridge> yes 17:16 < bridge> Then yeah, it's a signalling issue, I've never been great with signals either 😄 18:19 < bridge> 🤑 18:29 < bridge> https://cdn.discordapp.com/attachments/293493549758939136/1298684830480863314/20241023_182857.jpg?ex=671a75ff&is=6719247f&hm=52729cbb295d0f1eaa2ec335273819a941102a211d804dedc4112f11040936ef& 18:30 < bridge> dreams are powerful 18:32 < bridge> This man was truly special, It's such a loss that he died so young 18:43 < bridge> yeah, respect 18:44 < bridge> > Imagine that you are on a street with houses marked 1 through n. There is a house in between (x) such that the sum of the house numbers to the left of it equals the sum of the house numbers to its right. If n is between 50 and 500, what are n and x?' This is a bivariate problem with multiple solutions. Ramanujan thought about it and gave the answer with a twist: He gave a continued fraction. The unusual part was that it was the solution to the w 18:46 < bridge> man got actual hax 18:47 < bridge> Divine inspiration, he seemed to have a direct line to god 18:57 < bridge> the same god that let him die young? 18:57 < bridge> Perhaps he insulted god through the direct line, we'll never know 🙃 19:33 < bridge> Rust pros, why isn't it possible to drop variable here https://github.com/alumina-lang/alumina/blob/d37bba06ce8882820731cef103cd9c7d77bc547a/src/alumina-boot/src/compiler.rs#L263 19:47 < bridge> why does github recognize my c as c++?? 19:47 < bridge> https://cdn.discordapp.com/attachments/293493549758939136/1298704324615995393/image.png?ex=671a8827&is=671936a7&hm=fbd5c884678d518c114a6d7ffca1482d9a981aa94261666dc074bf2895c94390& 19:49 < bridge> real c code uses underscores everywhere 19:49 < bridge> 😬 19:51 < bridge> god 19:52 < bridge> i think it recognizes .h files as c++ 19:52 < bridge> The compiler should be telling you why 19:54 < bridge> my reptile brain no understand 19:54 < bridge> https://cdn.discordapp.com/attachments/293493549758939136/1298706219653005434/image.png?ex=671a89eb&is=6719386b&hm=6e48807ed03c182720d3cd41ad7b2137ab4048ae888a2db1907c3bdfe84ca01c& 19:54 < bridge> BUT 19:55 < bridge> if i remove lifetime from self on method 19:55 < bridge> it doesn't show the error 19:55 < bridge> :thonk: 19:56 < bridge> @milkeeycat ur holding c which borrows ast 19:56 < bridge> and trying to drop ast while borrowed 19:56 < bridge> what is c value? 19:56 < bridge> is it a ref? 19:56 < bridge> can u clone() c? 19:58 < bridge> Guys i just got 1.43T score in osu thats like top 5 world 19:59 < bridge> Perhaps `parse_path` could return a `PathBuf` instead 20:00 < bridge> ok 20:02 < bridge> Shouldn't it work if I drop c before ast? 20:03 < bridge> Just show the new compiler error 😄 20:04 < bridge> ye 20:04 < bridge> I've found the best way to figure out what's going on with Rust is to just try it and let borrowck point out the issue. Trying to understand anything more than the basics of the rules of borrows is beyond the capabilities of my human brain 20:04 < bridge> but u have to imagine c is dropped at the } bracket 20:05 < bridge> well thats the purpose of borrow checker 20:05 < bridge> Might not work with an explicit drop, I remember borrowck having an issue with those combined with explicit lifetimes 20:05 < bridge> it may invalidate some valid code but it makes all invalid code non compile 20:06 < bridge> the explicit drop is nothing fancy, it just takes the value by value 20:06 < bridge> which is like taking ownership 20:06 < bridge> drop is implemented like fn drop(x: T) {} literally 20:06 < bridge> it's the same .__. 20:06 < bridge> https://cdn.discordapp.com/attachments/293493549758939136/1298709140654522368/image.png?ex=671a8ca3&is=67193b23&hm=3ab080654c69f08ff15315d8074f29c88a8803397234ea74505a21c217a42a6a& 20:06 < bridge> can u show me parse_path fn? 20:06 < bridge> Yeah, see, it's not the smartest 😄 20:06 < bridge> pls 20:06 < bridge> `pub fn parse_path(&'ast self, path: &'_ str) -> Path<'ast>` 20:07 < bridge> @milkeeycat what if u put the 20:07 < bridge> 20:07 < bridge> ```rust 20:07 < bridge> 20:07 < bridge> { 20:07 < bridge> let c = asdsadsa 20:07 < bridge> } 20:07 < bridge> drop 20:07 < bridge> ``` 20:07 < bridge> do it like this 20:07 < bridge> i always prefer using brackets for specifing lifetimes 20:07 < bridge> before drops 20:07 < bridge> blocks* 20:08 < bridge> Yeah, the block might work, I vaguely remember blocks working better 20:08 < bridge> why does it take 'ast lifetime? shouldnt it take the str lifetime?¿ 20:09 < bridge> whats going on 20:09 < bridge> idk, not my code https://github.com/alumina-lang/alumina/blob/master/src/alumina-boot/src/ast/mod.rs#L145 20:09 < bridge> hmmm i don't think there is a way to fix that righht? 20:09 < bridge> there is 20:09 < bridge> find .gitattributes file format on github 20:10 < bridge> ye its wrong 20:10 < bridge> ah i found it thx 20:10 < bridge> ah no 20:10 < bridge> idk 20:10 < bridge> @milkeeycat if having c inside a block works try with `-Zpolonius` on nightly, I'm just curious 20:11 < bridge> cmon cat 20:11 < bridge> answer! 20:11 < bridge> no purrs 20:11 < bridge> btw it allocates the path on a arena 20:11 < bridge> but it doesnt do any interning 20:11 < bridge> I think the lifetimes look sane for that method btw, it borrows from the ast, if you want to keep it longer than the ast you need an owned pathbuf instead 20:12 < bridge> tell them they can optimize it 20:12 < bridge> yeah, the Path is not the std path, its their own struct 20:12 < bridge> Oh, that's interesting 20:12 < bridge> ```rust 20:12 < bridge> pub fn parse_path(&'ast self, path: &'_ str) -> Path<'ast> { 20:12 < bridge> let (path, absolute) = if path.starts_with("::") { 20:12 < bridge> (path.strip_prefix("::").unwrap(), true) 20:12 < bridge> } else { 20:12 < bridge> (path, false) 20:12 < bridge> }; 20:12 < bridge> 20:13 < bridge> let segments: Vec<_> = path 20:13 < bridge> .split("::") 20:13 < bridge> .filter_map(|s| { 20:13 < bridge> if s.is_empty() { 20:13 < bridge> None 20:13 < bridge> } else { 20:13 < bridge> Some(PathSegment(s.alloc_on(self))) 20:13 < bridge> } 20:13 < bridge> }) 20:13 < bridge> .collect(); 20:13 < bridge> 20:13 < bridge> Path { absolute, segments } 20:13 < bridge> } 20:13 < bridge> } 20:13 < bridge> ``` 20:13 < bridge> `Some(PathSegment(s.alloc_on(self)))` 20:13 < bridge> is the key 20:13 < bridge> anyway im 99% sure a block works 20:14 < bridge> looks better thx 20:14 < bridge> https://cdn.discordapp.com/attachments/293493549758939136/1298711071795839106/image.png?ex=671a8e70&is=67193cf0&hm=954f45ed74333ab010edf4c1951da653a1cf6d96392a0bb15de934294dfa4dd8& 20:14 < bridge> ```rust 20:14 < bridge> pub struct PathSegment<'ast>(pub &'ast str); 20:14 < bridge> pub struct Path<'ast> { 20:14 < bridge> pub absolute: bool, 20:14 < bridge> pub segments: Vec>, 20:14 < bridge> } 20:14 < bridge> ``` 20:14 < bridge> Does seem it behaves similarly though, it is not an owned type, it just refers to the ast 20:14 < bridge> it calls this 20:14 < bridge> ```rust 20:14 < bridge> 20:14 < bridge> impl<'gcx, T: Allocatable> ArenaAllocatable<'gcx, AstCtx<'gcx>> for T 20:14 < bridge> where 20:14 < bridge> T: 'gcx, 20:14 < bridge> { 20:14 < bridge> type ReturnType = &'gcx T; 20:14 < bridge> 20:14 < bridge> fn alloc_on(self, ctx: &'gcx AstCtx<'gcx>) -> Self::ReturnType { 20:14 < bridge> ctx.arena.alloc(self) 20:14 < bridge> } 20:14 < bridge> } 20:14 < bridge> ``` 20:14 < bridge> Me too, I don't remember exactly why though, something something non lexical lifetime something something? 20:16 < bridge> i guess with blocks it can make sense of lifetimes easier 20:16 < bridge> but because its aided by thje block scope 20:16 < bridge> Actually doesn't feel like a non-lexical-lifetime thing, there is no control flow here changing the length of borrows 20:17 < bridge> btw the other day i learnt smth 20:17 < bridge> I should one day sit down and actually learn all the semantics of rust borrows, the implicit lifetimes hide so much from you that you can kinda get away with learning it extremely half-assedly and still write code 20:17 < bridge> ```rust 20:17 < bridge> let _ = (); 20:17 < bridge> _ = (); 20:17 < bridge> ``` 20:17 < bridge> iirc both work fine 20:17 < bridge> i need to confirm this again 20:17 < bridge> but _ doesnt need let 20:18 < bridge> I wonder if there is something like a flag to disable all lifetime elision 20:18 < bridge> Compiling playground v0.0.1 (/playground) 20:18 < bridge> Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.56s 20:18 < bridge> Running `target/debug/playground` 20:18 < bridge> yep 20:18 < bridge> What is this even supposed to do? This is too advanced 5 me 20:18 < bridge> you use _ when u want to discard a value 20:18 < bridge> but u can avoid the let 20:18 < bridge> i guess its because its not rly a binding 20:18 < bridge> Ah, interesting, never seen it before 20:20 < bridge> Apparently not, a shame, it'd be a great learning tool 20:30 < bridge> @heinrich5991 you awake? 20:37 < bridge> idk wat that does but at least it decreases compile time 10x 😬 20:37 < bridge> idk wat that does but at least it increases compile time 10x 😬 20:38 < bridge> maybe someone else can give some rough pointers. 20:38 < bridge> upon map change, the CClients seems to loose its state. 20:39 < bridge> How does a map change work on a protocol level, dunno myself what I'm asking for 😄 20:41 < bridge> Hey I have this problem when players shoot with all weapons without gun The shot is where the cursor is pointed, but its eyes are looking up or down can someone help me fix it 20:41 < bridge> https://cdn.discordapp.com/attachments/293493549758939136/1298717930338652181/image.png?ex=671a94d3&is=67194353&hm=143bada66b839c83a582894cd1290949dc77a248c32841901c1e0fceaa2b1beb& 20:45 < bridge> Polonius is the "experimental" borrow checker, it has much more advanced lifetime analysis allowing more code to be accepted (like evaluating non-lexical lifetimes) 20:45 < bridge> then it's still not smart enough 20:45 < bridge> Such advanced analysis comes at the cost of time 😄 20:45 < bridge> Did the block work? 20:45 < bridge> no 20:46 < bridge> :suizid: 20:46 < bridge> Well if the block didn't work I didn't think Polonius would help either 20:47 < bridge> should've written my compiler in C :feelsbadman: 20:47 < bridge> so what can i finally do with it 20:48 < bridge> @milkeeycat what did you mean by this? Which method were you talking about? 20:48 < bridge> i think #developer is the wrong channel to ask, you're better of in # 20:48 < bridge> i think #developer is the wrong channel to ask, you're better of in #bugs or #questions 20:49 < bridge> does anyone know how to save chat logs in the game as a txt file 20:49 < bridge> i broke a lot of other stuff but if I changed 20:49 < bridge> ```rust 20:49 < bridge> pub fn parse_path(&'ast self, path: &'_ str) -> Path<'ast> { 20:49 < bridge> ``` 20:49 < bridge> to 20:49 < bridge> ```rust 20:49 < bridge> pub fn parse_path(&self, path: &'_ str) -> Path<'ast> { 20:49 < bridge> ``` 20:49 < bridge> error wasn't shown 20:50 < bridge> They are supposed to lose most state 20:50 < bridge> found OnClientDataPersist 20:51 < bridge> might help with I'm trying to achieve 20:51 < bridge> Yes, that's what we use for persisting stuff past a map reload 20:51 < bridge> might help with what I'm trying to achieve 20:58 < bridge> That is most curious, I'd thinkg the elision rules would just make all those lifetimes `'ast` anyway. This is where my Rust lifetime knowledge ends, you'll have to ask @ryozuki or @heinrich5991 20:58 < bridge> That is most curious, I'd think the elision rules would just make all those lifetimes `'ast` anyway. This is where my Rust lifetime knowledge ends, you'll have to ask @ryozuki or @heinrich5991 20:59 < bridge> C is the savior 20:59 < bridge> no lifetimes, no problems 20:59 < bridge> Exactly, come back to the light side, no more of this "safe coding" 21:00 < bridge> What is the point of the language being safe if the compiler won't allow you to code the thing you want? 21:00 < bridge> it's time to write the compiler in meraki, so I can do watever I want 21:00 < bridge> :thisemoji: 21:01 < bridge> but why does this code work -.- 21:01 < bridge> ```rust 21:01 < bridge> use std::collections::HashSet; 21:01 < bridge> 21:01 < bridge> struct Foo<'a> { 21:01 < bridge> bar: HashSet<&'a str>, 21:01 < bridge> } 21:01 < bridge> 21:01 < bridge> impl<'a> Foo<'a> { 21:01 < bridge> fn new() -> Self { 21:01 < bridge> Self { 21:01 < bridge> bar: HashSet::new(), 21:01 < bridge> } 21:01 < bridge> } 21:01 < bridge> 21:01 < bridge> fn test(&'a self) -> &'a str { 21:01 < bridge> todo!(); 21:01 < bridge> } 21:01 < bridge> } 21:01 < bridge> 21:01 < bridge> fn main() { 21:01 < bridge> let foo = Foo::new(); 21:01 < bridge> 21:02 < bridge> let c = foo.test(); 21:02 < bridge> 21:02 < bridge> std::mem::drop(foo); 21:02 < bridge> } 21:02 < bridge> ``` 21:02 < bridge> Only Allah and the 4 people on the rust core team know why that works and the other doesn't 21:02 < bridge> Try to use c after the drop 21:03 < bridge> Perhaps there is an early bail inside borrowck 21:03 < bridge> Ye, I can't use it after the drop 21:03 < bridge> But in that compiler code it doesn't work even if when it's before 21:04 < bridge> Perhaps the todo you have right after? Idk how todo is implemented 21:05 < bridge> I changed to `self.bar.get("").unwrap()` and nothing changed 22:00 < bridge> &'ast self and &self is completly different 22:00 < bridge> the first asks for a borrow that lasts atleast 'ast 22:01 < bridge> @milkeeycat where is the parse_ast method? 22:02 < bridge> idk :justatest: 22:02 < bridge> oh parse_path sry i misread 22:02 < bridge> tbh idk if i had the project at hand it would be easier 22:02 < bridge> i sent the link xd 22:05 < bridge> thats the project that fails? 22:05 < bridge> or you changed something? 22:05 < bridge> uncomment the line and you have the problem 22:05 < bridge> what line 22:05 < bridge> i git cloned git@github.com:alumina-lang/alumina.git 22:06 < bridge> `src/alumina-boot/src/compiler.r:263` 22:06 < bridge> `src/alumina-boot/src/compiler.rs:263` 22:07 < bridge> I love c++, changed stuff around OnClientDataPersist, application crashes somewhere in db pool 22:08 < bridge> ``` 22:08 < bridge> error[E0505]: cannot move out of `ast` because it is borrowed 22:08 < bridge> --> src/alumina-boot/src/compiler.rs:263:14 22:08 < bridge> | 22:08 < bridge> 102 | .map(|source_file| { 22:08 < bridge> | ------------- borrow of `ast` occurs here 22:08 < bridge> ... 22:09 < bridge> 112 | Ok((parse_tree, ast.parse_path(&source_file.path))) 22:09 < bridge> | --- borrow occurs due to use in closure 22:09 < bridge> ... 22:09 < bridge> 263 | drop(ast); 22:09 < bridge> | ^^^ 22:09 < bridge> | | 22:09 < bridge> | move out of `ast` occurs here 22:09 < bridge> | borrow later used here 22:09 < bridge> 22:09 < bridge> For more information about this error, try `rustc --explain E0505`. 22:09 < bridge> error: could not compile `alumina-boot` (bin "alumina-boot") due to 1 previous error 22:09 < bridge> ``` 22:10 < bridge> Really even in that context? I'd have thought elision rules would make `pub fn parse_path(&self, path: &'_ str) -> Path<'ast>` into `pub fn parse_path(&'ast self, path: &'_ str) -> Path<'ast>` anyway 22:10 < bridge> replace `compile` function body with 22:10 < bridge> ``` 22:10 < bridge> let ast = AstCtx::new(); 22:10 < bridge> 22:10 < bridge> ast.parse_path(&source_files[0].path); 22:10 < bridge> 22:10 < bridge> drop(ast); 22:10 < bridge> 22:10 < bridge> todo!(); 22:10 < bridge> ``` 22:11 < bridge> you know i think the problem is 22:11 < bridge> ```rust 22:11 < bridge> pub struct AstCtx<'ast> { 22:11 < bridge> pub arena: Bump, 22:11 < bridge> pub counter: Cell, 22:11 < bridge> types: RefCell>>, 22:11 < bridge> strings: RefCell>, 22:11 < bridge> lang_items: RefCell>>, 22:12 < bridge> local_names: RefCell>, 22:12 < bridge> metadata: RefCell, Metadatum<'ast>>>, 22:12 < bridge> } 22:12 < bridge> ``` 22:12 < bridge> Ah, I'm wrong, I think that would become `pub fn parse_path(&'a self, path: &'b str) -> Path<'ast>` 22:12 < bridge> RefCell 22:12 < bridge> so here 'ast is a lifetime used for items allocated in the arena it has 22:12 < bridge> which is odd 22:12 < bridge> tbh 22:13 < bridge> im trying to think this 22:13 < bridge> ```rust 22:13 < bridge> use std::cell::RefCell; 22:13 < bridge> 22:13 < bridge> struct Foo<'a> { 22:13 < bridge> bar: RefCell<&'a str>, 22:13 < bridge> } 22:13 < bridge> 22:13 < bridge> impl<'a> Foo<'a> { 22:13 < bridge> fn new() -> Self { 22:13 < bridge> Self { 22:13 < bridge> bar: RefCell::new("foo"), 22:13 < bridge> } 22:13 < bridge> } 22:13 < bridge> 22:13 < bridge> fn test(&'a self) -> &'a str { 22:13 < bridge> &self.bar.borrow() 22:13 < bridge> } 22:13 < bridge> } 22:13 < bridge> 22:13 < bridge> fn main() { 22:13 < bridge> let foo = Foo::new(); 22:13 < bridge> 22:13 < bridge> let c = foo.test(); 22:13 < bridge> 22:13 < bridge> std::mem::drop(foo); 22:13 < bridge> } 22:13 < bridge> ``` 22:14 < bridge> this code doesn't compile 22:14 < bridge> i think u dont need &'ast self 22:14 < bridge> The fact that you are an expert at this and it's not obvious to you is why I'm not the biggest fan of Rust 😄 22:14 < bridge> xd 22:14 < bridge> well the code in the repo is more complex 22:14 < bridge> than the examples here 22:14 < bridge> but i think its mostly trying to store the stuff in the same struct that "allocates" it 22:14 < bridge> ``` 22:14 < bridge> sixup: couldn't load map maps7/ctf5.map 22:14 < bridge> 2024-10-23 21:59:19 I sixup: disabling 0.7 compatibility 22:14 < bridge> 2024-10-23 21:59:19 I ddnet-insta: cleaning up database connection ... 22:14 < bridge> 2024-10-23 21:59:19 I ddnet-insta: connecting to database ... 22:14 < bridge> DDNet-Server(35680,0x16ff13000) malloc: Corruption of tiny freelist 0x107b05370: size too small (0/7) 22:14 < bridge> DDNet-Server(35680,0x16ff13000) malloc: *** set a breakpoint in malloc_error_break to debug 22:14 < bridge> ``` 22:14 < bridge> might also be related to metrying to change my map to one map that has no 0.7 version 22:14 < bridge> ddnet-insta codebase 22:14 < bridge> ``` 22:14 < bridge> sixup: couldn't load map maps7/ctf5.map 22:14 < bridge> 2024-10-23 21:59:19 I sixup: disabling 0.7 compatibility 22:14 < bridge> 2024-10-23 21:59:19 I ddnet-insta: cleaning up database connection ... 22:14 < bridge> 2024-10-23 21:59:19 I ddnet-insta: connecting to database ... 22:14 < bridge> DDNet-Server(35680,0x16ff13000) malloc: Corruption of tiny freelist 0x107b05370: size too small (0/7) 22:14 < bridge> DDNet-Server(35680,0x16ff13000) malloc: *** set a breakpoint in malloc_error_break to debug 22:14 < bridge> ``` 22:14 < bridge> might also be related to me trying to change my map to one map that has no 0.7 version 22:14 < bridge> ddnet-insta codebase 22:14 < bridge> which is problematic in rust 22:14 < bridge> Borrow checking and lifetimes feel like they are impossible to master 22:15 < bridge> Unless you are dtolnay that is 22:15 < bridge> ASan should instantly figure this out I guess 22:15 < bridge> me too dumb for that ._. 22:15 < bridge> please teach 22:15 < bridge> got lldb to work 22:15 < bridge> I think we have something you can copy paste in the README 22:15 < bridge> get asan 22:15 < bridge> get pc 22:15 < bridge> boot up chatgpt 22:15 < bridge> say you have problem 22:15 < bridge> let computer fix computer 22:15 < bridge> 22:15 < bridge> ... 22:15 < bridge> profit 22:15 < bridge> https://github.com/ddnet/ddnet?tab=readme-ov-file#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck 22:16 < bridge> found a line 22:16 < bridge> of coke 22:16 < bridge> :kek: 22:16 < bridge> to copy* 22:17 < bridge> That gives you ubsan too, which is fine, even better 22:17 < bridge> though ubsan does add a bit of slowdown 22:18 < bridge> @learath2 i found something 22:18 < bridge> https://users.rust-lang.org/t/lifetime-problem-and-cannot-move-out-of/99674 22:18 < bridge> > foo is not trivially droppable, because foo.guard implements Drop which can have observable side effect, so the compiler will not end foo's lifetime early. your Foo wrapper type is a red herring. you get the same error if you use the MutexGuard directly: let guard = bar.mutex.lock().unwrap(); … 22:19 < bridge> i guess that ast is not trivially droppable (in fact it has many things non trivially in it 22:19 < bridge> ok 22:19 < bridge> nvm 22:19 < bridge> its not this problem 22:19 < bridge> xdd 22:20 < bridge> is it supposed to create some dump or more output in case of a crash? 22:20 < bridge> > all their RefCell<'ast> types inside AstCtx are basically this 22:20 < bridge> > Basically, while you can make things with &'a T<'a> compile, it's not interoperable with many core rust features. 22:20 < bridge> > Theirs only works because the AstCtx is never moved to another function (either up or down the stack), which is what drop is supposed to do. 22:20 < bridge> Other rustacean's opition 22:21 < bridge> > all their RefCell<'ast> types inside AstCtx are basically this 22:21 < bridge> > Basically, while you can make things with &'a T<'a> compile, it's not interoperable with many core rust features. 22:21 < bridge> > Theirs only works because the AstCtx is never moved to another function (either up or down the stack), which is what drop is supposed to do. 22:21 < bridge> Other rustacean's opinion 22:21 < bridge> yeah thats what i kind of guessed 22:21 < bridge> . 22:22 < bridge> . 22:22 < bridge> i would refactor this in a more rusty way 22:22 < bridge> imho the easy way would be to just not have the arena: Bump in the struct 22:26 < bridge> now I can finally check da stuff I was looking for in the first place xd 22:29 < bridge> hm, san files 22:52 < bridge> ```cpp 22:52 < bridge> void CSnapshotStorage::PurgeAll() 22:52 < bridge> { 22:52 < bridge> while(m_pFirst) 22:52 < bridge> { 22:52 < bridge> CHolder *pNext = m_pFirst->m_pNext; 22:52 < bridge> free(m_pFirst->m_pSnap); 22:52 < bridge> free(m_pFirst->m_pAltSnap); 22:52 < bridge> free(m_pFirst); 22:52 < bridge> m_pFirst = pNext; 22:52 < bridge> } 22:52 < bridge> m_pLast = nullptr; 22:52 < bridge> } 22:52 < bridge> ``` 22:52 < bridge> does m_pFirst also need to be reset to null after the loop? 22:53 < bridge> ``` 22:53 < bridge> ================================================================= 22:53 < bridge> ==43980==ERROR: AddressSanitizer: heap-use-after-free on address 0x606000018208 at pc 0x0001057de03c bp 0x00016b373320 sp 0x00016b373318 22:54 < bridge> READ of size 8 at 0x606000018208 thread T0 22:54 < bridge> #0 0x1057de038 in CSnapshotStorage::PurgeAll() snapshot.cpp:624 22:54 < bridge> #1 0x104b3e03c in CServer::CClient::Reset() server.cpp:214 22:54 < bridge> #2 0x104badcc0 in CServer::Run() server.cpp:2897 22:54 < bridge> #3 0x104ad90e4 in main main.cpp:198 22:54 < bridge> #4 0x196a68270 () 22:54 < bridge> 22:54 < bridge> 0x606000018208 is located 8 bytes inside of 56-byte region [0x606000018200,0x606000018238) 22:54 < bridge> freed by thread T0 here: 22:54 < bridge> #0 0x10735cd40 in free+0x98 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x54d40) 22:54 < bridge> #1 0x1057de28c in CSnapshotStorage::PurgeAll() snapshot.cpp:627 22:54 < bridge> #2 0x104beff24 in CSnapshotStorage::~CSnapshotStorage() snapshot.h:137 22:54 < bridge> #3 0x104befeac in CSnapshotStorage::~CSnapshotStorage() snapshot.h:137 22:54 < bridge> #4 0x104befe34 in CServer::CClient::~CClient() server.h:109 22:54 < bridge> #5 0x104b42ff4 in CServer::CClient::~CClient() server.h:109 22:54 < bridge> #6 0x104b51690 in CServer::gCTFState(int) const server.cpp:670 22:54 < bridge> #7 0x104e9b4e8 in CGameContext::OnClientDataPersist(int, void*) gamecontext.cpp:1681 22:54 < bridge> #8 0x104bace14 in CServer::Run() server.cpp:2878 22:54 < bridge> #9 0x104ad90e4 in main main.cpp:198 22:54 < bridge> #10 0x196a68270 () 22:54 < bridge> 22:54 < bridge> previously allocated by thread T0 here: 22:54 < bridge> #0 0x10735cc04 in malloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x54c04) 22:54 < bridge> #1 0x1057dea3c in CSnapshotStorage::Add(int, long long, unsigned long, void const*, unsigned long, void const*) snapshot.cpp:665 22:54 < bridge> #2 0x104b5b630 in CServer::DoSnapshot() server.cpp:956 22:54 < bridge> #3 0x104bb1bcc in CServer::Run() server.cpp:2989 22:54 < bridge> #4 0x104ad90e4 in main main.cpp:198 22:54 < bridge> #5 0x196a68270 () 22:55 < bridge> hm #7 0x104e9b4e8 in CGameContext::OnClientDataPersist(int, void*) gamecontext.cpp:1681 22:56 < bridge> I recognize stuff that I broke, lol 22:56 < bridge> :kek: 23:26 < bridge> try asking the compiler instead of the language server 23:26 < bridge> the compiler might give better errors 23:27 < bridge> `drop` doesn't get rid of the variable, just of its value. the type is still there 23:28 < bridge> calling it discard is dangerous. `let _ = a;` is a no-op, it doesn't move out of `a` 23:29 < bridge> remove the `'a` from `self` 23:29 < bridge> `todo!()` is irrelevant 23:29 < bridge> Can you help me understand why the `'a` changes things there? 23:30 < bridge> note that the lifetime parameter isn't declared at the function, it might also appears elsewhere 23:30 < bridge> its a struct that owns and has reference to data it owns 23:30 < bridge> so it gives problems with drop 23:30 < bridge> nah, I think I mostly understand them 23:31 < bridge> Ok, so it's dtolnay, you and the rest of the core team 😛 23:32 < bridge> the explicit drop is a move 23:32 < bridge> so thats why u cant with it 23:34 < bridge> the function signature is 23:34 < bridge> ```rs 23:34 < bridge> fn test<'a>(self: &'a Foo<'a>) -> &'a str; 23:34 < bridge> // vs 23:34 < bridge> fn test<'a, 'b>(self: &'b Foo<'a>) -> &'a str 23:34 < bridge> ``` 23:34 < bridge> in the former case, the returned lifetime depends on the lifetime of the `self` reference and the inner lifetime of `Foo` 23:34 < bridge> in the latter case, it only depends on the inner lifetime of `Foo` 23:34 < bridge> Ah the lifetime of the reference vs the inner lifetime, yeah that makes sense 23:35 < bridge> there's a bit magic involved there, too 23:35 < bridge> the rust compiler knows that it can change the inner `Foo` lifetime to shorter ones 23:36 < bridge> So by adding the 'a there you are "accidentally" forcing the borrow to exist as long as `Foo` exists? 23:36 < bridge> because it looks into the `struct` and sees that the lifetime is used in a reference there 23:36 < bridge> you are forcing the compiler to select a shorter lifetime 23:36 < bridge> for the function 23:36 < bridge> namely the shorter one of the inner lifetime and the `self` reference 23:36 < bridge> which is always going to be the lifetime of the `self` reference 23:37 < bridge> :poggers2: 23:37 < bridge> so now the returned string has the lifetime of the `self` reference 23:38 < bridge> i guess im no expert 23:38 < bridge> im a rust nobo 23:38 < bridge> So you can't drop the reference, since the returned strings lifetime would have to end there but it doesn't 23:38 < bridge> i wonder if its that, or that u simply cant move the object 23:39 < bridge> because of the reference lifetimes 23:39 < bridge> drop needs a move but the implicit drop doesnt i think 23:39 < bridge> I still maintain my position that Rust (especially the borrow checker) is very resistant to mastery. Lifetime elision makes things sooo opaque that most people just never have to understand it at all, then they suddenly hit a brick wall 23:39 < bridge> so its more a question of being able to "move" it or not 23:39 < bridge> not about dropping 23:39 < bridge> yes 23:40 < bridge> Well a drop is a move, no? 23:40 < bridge> the explicit drop call is 23:40 < bridge> drop() 23:40 < bridge> a implicit drop doesnt need to move it just deallocs in place no? 23:40 < bridge> thats my understanding 23:40 < bridge> idk 23:40 < bridge> the problem is AFAIK that the variable exists beyond the drop 23:40 < bridge> after the block ends, the variable is no longer there 23:41 < bridge> it's just the instance that you `drop` 23:41 < bridge> well, u mostly hit this stuff with self referential stuff 23:42 < bridge> If you were forced to write the lifetimes all the time you'd have a better understanding of them by the time you get to the weird stuff 😄 23:42 < bridge> idk, i code rust daily at work and i rarely hit issues like this 23:42 < bridge> and i dont do simple stuff 23:42 < bridge> idk it would be lot of work 23:43 < bridge> I guess I was forced to learn with a stricter borrow checker 23:43 < bridge> You were there before 1.0? 23:43 < bridge> people say it's become more complicated to teach the borrow checker since it got relaxed. because the easy examples simply compile nowadays 23:44 < bridge> yes, but the borrow checker also got laxer after 1.0 23:44 < bridge> I meant as like an option to disable it completely 23:44 < bridge> I would totally disable it for a couple months to learn better 23:44 < bridge> https://doc.rust-lang.org/nomicon/dropck.html 23:45 < bridge> I recently noticed that I can claim 10 years of rust experience 😄 23:45 < bridge> damn 23:45 < bridge> i started on 2018 23:45 < bridge> 4 years i guess 23:46 < bridge> matricks was at least among the people who got me into rust 23:48 < bridge> I have still yet to convince myself to start trying to use Rust 23:48 < bridge> it's a damn cult I tell ya 23:48 < bridge> something fishy about those guys 23:48 < bridge> just do it 23:48 < bridge> u will learn something 23:48 < bridge> even if u dont like it or use it 23:49 < bridge> and nothing bad comes from leanring more languages 23:49 < bridge> We should write more Haskell 23:49 < bridge> im learning ocaml now 23:49 < bridge> and nothing bad comes from learning more languages 23:49 < bridge> The functional people are the real cult 😄 23:49 < bridge> @learath2 honestly, functiona llangs have nice stuff 23:49 < bridge> like partial application 23:49 < bridge> God forbid I mutate a variable 23:50 < bridge> https://en.wikipedia.org/wiki/Partial_application 23:50 < bridge> did you see that rust is making the libcs make `exit` thread-safe? ^^ 23:50 < bridge> How can exit become thread-safe even? 23:51 < bridge> epic win 23:51 < bridge> I enjoy writing pointless code 23:51 < bridge> did you know that calling `exit` on two different threads is instant UB in C? ^^ 23:51 < bridge> point free programming my beloved 23:51 < bridge> I did 23:52 < bridge> I did not and found it insane. but that's probably changing in the future 23:52 < bridge> i.e. `exit` will likely become threadsafe in the future 23:52 < bridge> I also thought it was unfixable though 23:52 < bridge> Isn't it only natural that you can't exit more than once? 23:52 < bridge> just take a lock at the start of the `exit` impl 23:53 < bridge> and never drop it 23:53 < bridge> Oh, just bolting on a lock, yeah I guess you can make it thread-safe like that 23:53 < bridge> did you know ocaml functions only take 1 argument 23:53 < bridge> hm, seemingly when switching from a 0.6 only map to a map that has a 0.6 and 0.7 version, sixup is not enabled again 23:54 < bridge> (in fact, glibc is taking a lock at the start of the `exit` impl, but dropping it under certain circumstances later on. meaning that `exit` was usually threadsafe in glibc, but not always) 23:55 < bridge> if you want to be more performant, you can do an atomic compare-and-exchange 23:55 < bridge> ChillerDragon 😮 23:55 < bridge> Hm, if the solution is holding a lock, can't rust provide it's own exit that does it properly? Why is libc changing it? 23:55 < bridge> See #7669 23:55 < bridge> https://github.com/ddnet/ddnet/issues/7669 23:55 < bridge> (I mean, it's fine, should be nice that libc also fixes it, just wondering why it's being done on that side) 23:56 < bridge> because rust tries to interoperate with the world. you can't make it safe to `exit` if not everyone takes the same lock 23:56 < bridge> As in the ffi case or if someone bypasses the rust wrapper? 23:56 < bridge> e.g. python calling `sys.exit` concurrently with a rust library calling `std::process::exit` should ideally not be UB 23:57 < bridge> if a rust library is called from python, for example