Guild icon
DDraceNetwork
Development / developer
Development discussion. Logged to https://ddnet.org/irclogs/ Connected with DDNet's IRC channel, Matrix room and GitHub repositories — IRC: #ddnet on Quakenet | Matrix: #ddnet-developer:matrix.org GitHub: https://github.com/ddnet
Between 2024-10-23 00:00 and 2024-10-24 00:00
Avatar
usb 4 seems cool
00:01
never used it
Avatar
gm bois
Avatar
gm teero
02:44
why up so early?
Avatar
ill
Avatar
MilkeeyCat 2024-10-23 07:27
I asked how I should do some thing at work, and here's the answer:
Think for yourself and face the consequences of your decisions. 😛
10:08
interesting crate, you can use splitbits!(0b11110000, "aaabbbbb"); to parse a byte into two bit fields
Avatar
heinrich5991 2024-10-23 10:34
API documentation for the Rust bitmatch crate.
10:34
I should write a CPU emulator now using this ^^
Avatar
looks nice
11:22
it wouyld be nice to tell docs.rs to regenerate docs using latest rustdocs
11:22
the page doesnt even support dark theme
11:23
4 year ago last update
Avatar
This might be the coolest macro I've seen yet
Avatar
actually this might help my riscv emu
Avatar
hey are the skin proportions and stuff available somewhere?
Avatar
Jupstar ✪ 2024-10-23 13:08
$wiki skin render
Avatar
Avatar
Jupstar ✪
$wiki skin render
No articles found.
Avatar
Jupstar ✪ 2024-10-23 13:08
$skin
Avatar
This command was not found.
Avatar
Jupstar ✪ 2024-10-23 13:08
$wiki skin
Avatar
Avatar
Jupstar ✪
$wiki skin
No articles found.
Avatar
Jupstar ✪ 2024-10-23 13:08
C'mon
13:08
We had them saved somewhere
Avatar
$wiki pleas help
Avatar
Avatar
Teero
$wiki pleas help
No articles found.
Avatar
$wiki skin rendering
Avatar
Avatar
Robyt3
$wiki skin rendering
No articles found.
Avatar
This article aims to introduce you into DDNet development, since it's an open-source game, it relies on random people kind enough to contribute to it on their free time.
Avatar
Jupstar ✪ 2024-10-23 13:18
@Teero there you have it
13:18
You can continue writing your OpenGL 4.6 x OpenGL 2.1 mix renderer
Avatar
thanks
Avatar
i wanna buy a flipper zero
15:00
they look fun
Avatar
Avatar
Ryozuki
i wanna buy a flipper zero
I was right about to buy one, then I thought, what would I really do with one
15:04
If you want a software defined radio to mess with something like a hackrf one is much more capable
Avatar
heinrich5991 2024-10-23 15:05
I (permanently? lol) borrowed a hackrf but haven't done a lot with it yet
15:05
I tried to clone some gate remote with it
15:06
but I'm bad at signal processing, it turns out
15:06
should learn more about that…
Avatar
Well a lot of things now are immune to simple replay attacks
Avatar
heinrich5991 2024-10-23 15:12
well, it's one-way communication and not time-based
15:12
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
15:13
but I didn't even manage to do that
Avatar
Avatar
heinrich5991
well, it's one-way communication and not time-based
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
Avatar
heinrich5991 2024-10-23 15:15
does not contain an RTC
15:15
it's a rolling code
15:15
but my proposed setup should work for a rolling code
Avatar
did you make sure you record the signal where the receiver didn't get it?
Avatar
heinrich5991 2024-10-23 15:15
yes
Avatar
Then yeah, it's a signalling issue, I've never been great with signals either 😄
Avatar
Avatar
Ryozuki
i wanna buy a flipper zero
🤑
Avatar
Jupstar ✪ 2024-10-23 16:30
dreams are powerful
Avatar
Avatar
Ryozuki
Click to see attachment 🖼️
This man was truly special, It's such a loss that he died so young
Avatar
yeah, respect
Avatar
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 whole class of problems. Mahalanobis was astounded and asked how he did it. 'It is simple. The minute I heard the problem, I knew that the answer was a continued fraction. Which continued fraction, I asked myself. Then the answer came to my mind', Ramanujan replied."
Avatar
man got actual hax
Avatar
Divine inspiration, he seemed to have a direct line to god
Avatar
Jupstar ✪ 2024-10-23 16:57
the same god that let him die young?
Avatar
Avatar
Jupstar ✪
the same god that let him die young?
Perhaps he insulted god through the direct line, we'll never know 🙃
😬 1
Avatar
why does github recognize my c as c++??
Avatar
Jupstar ✪ 2024-10-23 17:49
real c code uses underscores everywhere
17:49
😬
Avatar
Avatar
Learath2
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 whole class of problems. Mahalanobis was astounded and asked how he did it. 'It is simple. The minute I heard the problem, I knew that the answer was a continued fraction. Which continued fraction, I asked myself. Then the answer came to my mind', Ramanujan replied."
god
Avatar
Avatar
Teero
why does github recognize my c as c++??
i think it recognizes .h files as c++
Avatar
The compiler should be telling you why
Avatar
Avatar
Learath2
The compiler should be telling you why
MilkeeyCat 2024-10-23 17:54
my reptile brain no understand
17:54
BUT
17:55
if i remove lifetime from self on method
17:55
it doesn't show the error
17:55
thonk
Avatar
@MilkeeyCat ur holding c which borrows ast
this 1
17:56
and trying to drop ast while borrowed
17:56
what is c value?
17:56
is it a ref?
17:56
can u clone() c?
Avatar
Guys i just got 1.43T score in osu thats like top 5 world
Avatar
Perhaps parse_path could return a PathBuf instead
Avatar
Avatar
🙂
Guys i just got 1.43T score in osu thats like top 5 world
ok
Avatar
Avatar
Ryozuki
@MilkeeyCat ur holding c which borrows ast
MilkeeyCat 2024-10-23 18:02
Shouldn't it work if I drop c before ast?
Avatar
Avatar
MilkeeyCat
Shouldn't it work if I drop c before ast?
Just show the new compiler error 😄
Avatar
Avatar
MilkeeyCat
Shouldn't it work if I drop c before ast?
ye
Avatar
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
Avatar
but u have to imagine c is dropped at the } bracket
Avatar
Avatar
Learath2
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
well thats the purpose of borrow checker
Avatar
Avatar
Ryozuki
ye
Might not work with an explicit drop, I remember borrowck having an issue with those combined with explicit lifetimes
Avatar
it may invalidate some valid code but it makes all invalid code non compile
Avatar
Avatar
Learath2
Might not work with an explicit drop, I remember borrowck having an issue with those combined with explicit lifetimes
the explicit drop is nothing fancy, it just takes the value by value
18:06
which is like taking ownership
18:06
drop is implemented like fn drop(x: T) {} literally
Avatar
Avatar
Learath2
Just show the new compiler error 😄
MilkeeyCat 2024-10-23 18:06
it's the same .__.
Avatar
can u show me parse_path fn?
Avatar
Yeah, see, it's not the smartest 😄
Avatar
pls
Avatar
Avatar
Ryozuki
can u show me parse_path fn?
pub fn parse_path(&'ast self, path: &'_ str) -> Path<'ast>
Avatar
@MilkeeyCat what if u put the { let c = asdsadsa } drop
18:07
do it like this
18:07
i always prefer using brackets for specifing lifetimes
18:07
before drops
18:07
blocks*
Avatar
Yeah, the block might work, I vaguely remember blocks working better
Avatar
Avatar
Learath2
pub fn parse_path(&'ast self, path: &'_ str) -> Path<'ast>
why does it take 'ast lifetime? shouldnt it take the str lifetime?¿
18:09
whats going on
Avatar
Avatar
Ryozuki
why does it take 'ast lifetime? shouldnt it take the str lifetime?¿
A general purpose programming language. Contribute to alumina-lang/alumina development by creating an account on GitHub.
Avatar
Avatar
Ryozuki
i think it recognizes .h files as c++
hmmm i don't think there is a way to fix that righht?
Avatar
there is
18:09
find .gitattributes file format on github
Avatar
ah i found it thx
Avatar
ah no
18:10
idk
Avatar
@MilkeeyCat if having c inside a block works try with -Zpolonius on nightly, I'm just curious
Avatar
cmon cat
18:11
answer!
18:11
no purrs
18:11
btw it allocates the path on a arena
18:11
but it doesnt do any interning
Avatar
Avatar
Ryozuki
ah no
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
Avatar
tell them they can optimize it
Avatar
Avatar
Learath2
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
yeah, the Path is not the std path, its their own struct
Avatar
Oh, that's interesting
Avatar
pub fn parse_path(&'ast self, path: &'_ str) -> Path<'ast> { let (path, absolute) = if path.starts_with("::") { (path.strip_prefix("::").unwrap(), true) } else { (path, false) }; let segments: Vec<_> = path .split("::") .filter_map(|s| { if s.is_empty() { None } else { Some(PathSegment(s.alloc_on(self))) } }) .collect(); Path { absolute, segments } } }
18:12
Some(PathSegment(s.alloc_on(self)))
18:13
is the key
18:13
anyway im 99% sure a block works
Avatar
Avatar
Ryozuki
find .gitattributes file format on github
looks better thx
Avatar
pub struct PathSegment<'ast>(pub &'ast str); pub struct Path<'ast> { pub absolute: bool, pub segments: Vec<PathSegment<'ast>>, } Does seem it behaves similarly though, it is not an owned type, it just refers to the ast
Avatar
it calls this
18:14
impl<'gcx, T: Allocatable> ArenaAllocatable<'gcx, AstCtx<'gcx>> for T where T: 'gcx, { type ReturnType = &'gcx T; fn alloc_on(self, ctx: &'gcx AstCtx<'gcx>) -> Self::ReturnType { ctx.arena.alloc(self) } }
Avatar
Avatar
Ryozuki
anyway im 99% sure a block works
Me too, I don't remember exactly why though, something something non lexical lifetime something something?
Avatar
i guess with blocks it can make sense of lifetimes easier
18:16
but because its aided by thje block scope
Avatar
Actually doesn't feel like a non-lexical-lifetime thing, there is no control flow here changing the length of borrows
Avatar
btw the other day i learnt smth
Avatar
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
Avatar
let _ = (); _ = ();
18:17
iirc both work fine
18:17
i need to confirm this again
18:17
but _ doesnt need let
Avatar
I wonder if there is something like a flag to disable all lifetime elision
Avatar
Compiling playground v0.0.1 (/playground) Finished dev profile [unoptimized + debuginfo] target(s) in 0.56s Running target/debug/playground
18:18
yep
Avatar
Avatar
Ryozuki
let _ = (); _ = ();
What is this even supposed to do? This is too advanced 5 me
Avatar
you use _ when u want to discard a value
18:18
but u can avoid the let
18:18
i guess its because its not rly a binding
Avatar
Ah, interesting, never seen it before
Avatar
Avatar
Learath2
I wonder if there is something like a flag to disable all lifetime elision
Apparently not, a shame, it'd be a great learning tool
Avatar
@heinrich5991 you awake?
Avatar
Avatar
Learath2
@MilkeeyCat if having c inside a block works try with -Zpolonius on nightly, I'm just curious
MilkeeyCat 2024-10-23 18:37
idk wat that does but at least it increases compile time 10x 😬 (edited)
Avatar
maybe someone else can give some rough pointers. upon map change, the CClients seems to loose its state. How does a map change work on a protocol level, dunno myself what I'm asking for 😄
Avatar
WhiteKitty 2024-10-23 18:41
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
18:41
Avatar
Avatar
MilkeeyCat
idk wat that does but at least it increases compile time 10x 😬 (edited)
Polonius is the "experimental" borrow checker, it has much more advanced lifetime analysis allowing more code to be accepted (like evaluating non-lexical lifetimes)
Avatar
Avatar
Learath2
Polonius is the "experimental" borrow checker, it has much more advanced lifetime analysis allowing more code to be accepted (like evaluating non-lexical lifetimes)
MilkeeyCat 2024-10-23 18:45
then it's still not smart enough
Avatar
Such advanced analysis comes at the cost of time 😄
Avatar
Avatar
MilkeeyCat
then it's still not smart enough
Did the block work?
Avatar
MilkeeyCat 2024-10-23 18:45
no
Avatar
Well if the block didn't work I didn't think Polonius would help either
Avatar
MilkeeyCat 2024-10-23 18:47
should've written my compiler in C feelsbadman
Avatar
WhiteKitty 2024-10-23 18:47
so what can i finally do with it
Avatar
Avatar
MilkeeyCat
if i remove lifetime from self on method
@MilkeeyCat what did you mean by this? Which method were you talking about?
Avatar
Avatar
WhiteKitty
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
i think #developer is the wrong channel to ask, you're better of in #bugs or #questions (edited)
Avatar
does anyone know how to save chat logs in the game as a txt file
Avatar
Avatar
Learath2
@MilkeeyCat what did you mean by this? Which method were you talking about?
MilkeeyCat 2024-10-23 18:49
i broke a lot of other stuff but if I changed pub fn parse_path(&'ast self, path: &'_ str) -> Path<'ast> { to pub fn parse_path(&self, path: &'_ str) -> Path<'ast> { error wasn't shown
Avatar
Avatar
jxsl13
maybe someone else can give some rough pointers. upon map change, the CClients seems to loose its state. How does a map change work on a protocol level, dunno myself what I'm asking for 😄
They are supposed to lose most state
Avatar
found OnClientDataPersist
18:51
might help with what I'm trying to achieve (edited)
Avatar
Yes, that's what we use for persisting stuff past a map reload
Avatar
Avatar
MilkeeyCat
i broke a lot of other stuff but if I changed pub fn parse_path(&'ast self, path: &'_ str) -> Path<'ast> { to pub fn parse_path(&self, path: &'_ str) -> Path<'ast> { error wasn't shown
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 (edited)
Avatar
MilkeeyCat 2024-10-23 18:59
C is the savior
18:59
no lifetimes, no problems
Avatar
Exactly, come back to the light side, no more of this "safe coding"
19:00
What is the point of the language being safe if the compiler won't allow you to code the thing you want?
Avatar
MilkeeyCat 2024-10-23 19:00
it's time to write the compiler in meraki, so I can do watever I want
justatest 1
Avatar
Avatar
Learath2
Exactly, come back to the light side, no more of this "safe coding"
thisemoji
Avatar
MilkeeyCat 2024-10-23 19:01
but why does this code work -.- use std::collections::HashSet; struct Foo<'a> { bar: HashSet<&'a str>, } impl<'a> Foo<'a> { fn new() -> Self { Self { bar: HashSet::new(), } } fn test(&'a self) -> &'a str { todo!(); } } fn main() { let foo = Foo::new(); let c = foo.test(); std::mem::drop(foo); }
Avatar
Only Allah and the 4 people on the rust core team know why that works and the other doesn't
19:02
Try to use c after the drop
19:03
Perhaps there is an early bail inside borrowck
Avatar
MilkeeyCat 2024-10-23 19:03
Ye, I can't use it after the drop
19:03
But in that compiler code it doesn't work even if when it's before
Avatar
Avatar
MilkeeyCat
But in that compiler code it doesn't work even if when it's before
Perhaps the todo you have right after? Idk how todo is implemented
Avatar
Avatar
Learath2
Perhaps the todo you have right after? Idk how todo is implemented
MilkeeyCat 2024-10-23 19:05
I changed to self.bar.get("").unwrap() and nothing changed
Avatar
Avatar
Learath2
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 (edited)
&'ast self and &self is completly different
20:00
the first asks for a borrow that lasts atleast 'ast
20:01
@MilkeeyCat where is the parse_ast method?
Avatar
MilkeeyCat 2024-10-23 20:02
idk justatest
Avatar
oh parse_path sry i misread
20:02
tbh idk if i had the project at hand it would be easier
Avatar
MilkeeyCat 2024-10-23 20:02
i sent the link xd
Avatar
thats the project that fails?
20:05
or you changed something?
Avatar
MilkeeyCat 2024-10-23 20:05
uncomment the line and you have the problem
Avatar
what line
20:05
i git cloned git@github.com:alumina-lang/alumina.git
Avatar
MilkeeyCat 2024-10-23 20:06
src/alumina-boot/src/compiler.rs:263 (edited)
Avatar
I love c++, changed stuff around OnClientDataPersist, application crashes somewhere in db pool
KEKW 1
oop 1
Avatar
error[E0505]: cannot move out of `ast` because it is borrowed --> src/alumina-boot/src/compiler.rs:263:14 | 102 | .map(|source_file| { | ------------- borrow of `ast` occurs here ... 112 | Ok((parse_tree, ast.parse_path(&source_file.path))) | --- borrow occurs due to use in closure ... 263 | drop(ast); | ^^^ | | | move out of `ast` occurs here | borrow later used here For more information about this error, try `rustc --explain E0505`. error: could not compile `alumina-boot` (bin "alumina-boot") due to 1 previous error
Avatar
Avatar
Ryozuki
&'ast self and &self is completly different
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
Avatar
Avatar
Ryozuki
error[E0505]: cannot move out of `ast` because it is borrowed --> src/alumina-boot/src/compiler.rs:263:14 | 102 | .map(|source_file| { | ------------- borrow of `ast` occurs here ... 112 | Ok((parse_tree, ast.parse_path(&source_file.path))) | --- borrow occurs due to use in closure ... 263 | drop(ast); | ^^^ | | | move out of `ast` occurs here | borrow later used here For more information about this error, try `rustc --explain E0505`. error: could not compile `alumina-boot` (bin "alumina-boot") due to 1 previous error
MilkeeyCat 2024-10-23 20:10
replace compile function body with let ast = AstCtx::new(); ast.parse_path(&source_files[0].path); drop(ast); todo!();
Avatar
you know i think the problem is
20:11
pub struct AstCtx<'ast> { pub arena: Bump, pub counter: Cell<usize>, types: RefCell<HashSet<TyP<'ast>>>, strings: RefCell<HashSet<&'ast str>>, lang_items: RefCell<HashMap<Lang, ItemP<'ast>>>, local_names: RefCell<HashMap<Id, &'ast str>>, metadata: RefCell<HashMap<ItemP<'ast>, Metadatum<'ast>>>, }
Avatar
Avatar
Learath2
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
Ah, I'm wrong, I think that would become pub fn parse_path(&'a self, path: &'b str) -> Path<'ast>
Avatar
MilkeeyCat 2024-10-23 20:12
RefCell
Avatar
so here 'ast is a lifetime used for items allocated in the arena it has
20:12
which is odd
20:12
tbh
20:13
im trying to think this
Avatar
MilkeeyCat 2024-10-23 20:13
use std::cell::RefCell; struct Foo<'a> { bar: RefCell<&'a str>, } impl<'a> Foo<'a> { fn new() -> Self { Self { bar: RefCell::new("foo"), } } fn test(&'a self) -> &'a str { &self.bar.borrow() } } fn main() { let foo = Foo::new(); let c = foo.test(); std::mem::drop(foo); } this code doesn't compile
Avatar
i think u dont need &'ast self
Avatar
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 😄
20:13
well the code in the repo is more complex
20:13
than the examples here
20:14
but i think its mostly trying to store the stuff in the same struct that "allocates" it
Avatar
sixup: couldn't load map maps7/ctf5.map 2024-10-23 21:59:19 I sixup: disabling 0.7 compatibility 2024-10-23 21:59:19 I ddnet-insta: cleaning up database connection ... 2024-10-23 21:59:19 I ddnet-insta: connecting to database ... DDNet-Server(35680,0x16ff13000) malloc: Corruption of tiny freelist 0x107b05370: size too small (0/7) DDNet-Server(35680,0x16ff13000) malloc: *** set a breakpoint in malloc_error_break to debug might also be related to me trying to change my map to one map that has no 0.7 version ddnet-insta codebase (edited)
Avatar
which is problematic in rust
Avatar
Borrow checking and lifetimes feel like they are impossible to master
20:14
Unless you are dtolnay that is
Avatar
Avatar
jxsl13
sixup: couldn't load map maps7/ctf5.map 2024-10-23 21:59:19 I sixup: disabling 0.7 compatibility 2024-10-23 21:59:19 I ddnet-insta: cleaning up database connection ... 2024-10-23 21:59:19 I ddnet-insta: connecting to database ... DDNet-Server(35680,0x16ff13000) malloc: Corruption of tiny freelist 0x107b05370: size too small (0/7) DDNet-Server(35680,0x16ff13000) malloc: *** set a breakpoint in malloc_error_break to debug might also be related to me trying to change my map to one map that has no 0.7 version ddnet-insta codebase (edited)
ASan should instantly figure this out I guess
Avatar
me too dumb for that ._.
20:15
please teach
20:15
got lldb to work
Avatar
Avatar
jxsl13
please teach
I think we have something you can copy paste in the README
Avatar
get asan get pc boot up chatgpt say you have problem let computer fix computer ... profit
Avatar
found a line
20:16
of coke
20:16
kek
20:16
to copy*
Avatar
That gives you ubsan too, which is fine, even better
20:17
though ubsan does add a bit of slowdown
🚀 1
Avatar
@Learath2 i found something
20:18
In the following scenario, the compiler seemingly can't determine that foo is no longer used and can be dropped before f is called. The resulting error is error[E0505]: cannot move out of bar because it is borrowed. When I understand correctly, the problem is that the lifetime'g which is inferred to be the lifetime of bar spans the whole main f...
20:18
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(); …
20:19
i guess that ast is not trivially droppable (in fact it has many things non trivially in it
20:19
ok
20:19
nvm
20:19
its not this problem
20:19
xdd
Avatar
is it supposed to create some dump or more output in case of a crash?
Avatar
MilkeeyCat 2024-10-23 20:20
all their RefCell<'ast> types inside AstCtx are basically this Basically, while you can make things with &'a T<'a> compile, it's not interoperable with many core rust features. 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.
Other rustacean's opinion
(edited)
Avatar
yeah thats what i kind of guessed
Avatar
Avatar
Ryozuki
pub struct AstCtx<'ast> { pub arena: Bump, pub counter: Cell<usize>, types: RefCell<HashSet<TyP<'ast>>>, strings: RefCell<HashSet<&'ast str>>, lang_items: RefCell<HashMap<Lang, ItemP<'ast>>>, local_names: RefCell<HashMap<Id, &'ast str>>, metadata: RefCell<HashMap<ItemP<'ast>, Metadatum<'ast>>>, }
.
Avatar
Avatar
Ryozuki
so here 'ast is a lifetime used for items allocated in the arena it has
.
20:22
i would refactor this in a more rusty way
20:22
imho the easy way would be to just not have the arena: Bump in the struct
Avatar
MilkeeyCat 2024-10-23 20:26
now I can finally check da stuff I was looking for in the first place xd
Avatar
hm, san files
Avatar
void CSnapshotStorage::PurgeAll() { while(m_pFirst) { CHolder *pNext = m_pFirst->m_pNext; free(m_pFirst->m_pSnap); free(m_pFirst->m_pAltSnap); free(m_pFirst); m_pFirst = pNext; } m_pLast = nullptr; } does m_pFirst also need to be reset to null after the loop?
20:53
================================================================= ==43980==ERROR: AddressSanitizer: heap-use-after-free on address 0x606000018208 at pc 0x0001057de03c bp 0x00016b373320 sp 0x00016b373318 READ of size 8 at 0x606000018208 thread T0 #0 0x1057de038 in CSnapshotStorage::PurgeAll() snapshot.cpp:624 #1 0x104b3e03c in CServer::CClient::Reset() server.cpp:214 #2 0x104badcc0 in CServer::Run() server.cpp:2897 #3 0x104ad90e4 in main main.cpp:198 #4 0x196a68270 (<unknown module>) 0x606000018208 is located 8 bytes inside of 56-byte region [0x606000018200,0x606000018238) freed by thread T0 here: #0 0x10735cd40 in free+0x98 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x54d40) #1 0x1057de28c in CSnapshotStorage::PurgeAll() snapshot.cpp:627 #2 0x104beff24 in CSnapshotStorage::~CSnapshotStorage() snapshot.h:137 #3 0x104befeac in CSnapshotStorage::~CSnapshotStorage() snapshot.h:137 #4 0x104befe34 in CServer::CClient::~CClient() server.h:109 #5 0x104b42ff4 in CServer::CClient::~CClient() server.h:109 #6 0x104b51690 in CServer::gCTFState(int) const server.cpp:670 #7 0x104e9b4e8 in CGameContext::OnClientDataPersist(int, void*) gamecontext.cpp:1681 #8 0x104bace14 in CServer::Run() server.cpp:2878 #9 0x104ad90e4 in main main.cpp:198 #10 0x196a68270 (<unknown module>) previously allocated by thread T0 here: #0 0x10735cc04 in malloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x54c04) #1 0x1057dea3c in CSnapshotStorage::Add(int, long long, unsigned long, void const*, unsigned long, void const*) snapshot.cpp:665 #2 0x104b5b630 in CServer::DoSnapshot() server.cpp:956 #3 0x104bb1bcc in CServer::Run() server.cpp:2989 #4 0x104ad90e4 in main main.cpp:198 #5 0x196a68270 (<unknown module>) SUMMARY: AddressSanitizer: heap-use-after-free snapshot.cpp:624 in CSnapshotStorage::PurgeAll() ... ... ==43980==ABORTING
20:55
hm #7 0x104e9b4e8 in CGameContext::OnClientDataPersist(int, void*) gamecontext.cpp:1681
20:56
I recognize stuff that I broke, lol
20:56
kek
Avatar
Avatar
MilkeeyCat
my reptile brain no understand
heinrich5991 2024-10-23 21:26
try asking the compiler instead of the language server
21:26
the compiler might give better errors
Avatar
Avatar
Learath2
Me too, I don't remember exactly why though, something something non lexical lifetime something something?
heinrich5991 2024-10-23 21:27
drop doesn't get rid of the variable, just of its value. the type is still there
Avatar
Avatar
Ryozuki
you use _ when u want to discard a value
heinrich5991 2024-10-23 21:28
calling it discard is dangerous. let _ = a; is a no-op, it doesn't move out of a
Avatar
Avatar
MilkeeyCat
but why does this code work -.- use std::collections::HashSet; struct Foo<'a> { bar: HashSet<&'a str>, } impl<'a> Foo<'a> { fn new() -> Self { Self { bar: HashSet::new(), } } fn test(&'a self) -> &'a str { todo!(); } } fn main() { let foo = Foo::new(); let c = foo.test(); std::mem::drop(foo); }
heinrich5991 2024-10-23 21:29
remove the 'a from self
Avatar
Avatar
Learath2
Perhaps the todo you have right after? Idk how todo is implemented
heinrich5991 2024-10-23 21:29
todo!() is irrelevant
Avatar
Avatar
heinrich5991
remove the 'a from self
Can you help me understand why the 'a changes things there?
Avatar
Avatar
Learath2
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
heinrich5991 2024-10-23 21:30
note that the lifetime parameter isn't declared at the function, it might also appears elsewhere
Avatar
its a struct that owns and has reference to data it owns
21:30
so it gives problems with drop
Avatar
Avatar
Learath2
Borrow checking and lifetimes feel like they are impossible to master
heinrich5991 2024-10-23 21:30
nah, I think I mostly understand them
Avatar
Avatar
heinrich5991
nah, I think I mostly understand them
Ok, so it's dtolnay, you and the rest of the core team 😛
Avatar
the explicit drop is a move
21:32
so thats why u cant with it
Avatar
Avatar
Learath2
Can you help me understand why the 'a changes things there?
heinrich5991 2024-10-23 21:34
the function signature is fn test<'a>(self: &'a Foo<'a>) -> &'a str; // vs fn test<'a, 'b>(self: &'b Foo<'a>) -> &'a str
21:34
in the former case, the returned lifetime depends on the lifetime of the self reference and the inner lifetime of Foo
21:34
in the latter case, it only depends on the inner lifetime of Foo
Avatar
Ah the lifetime of the reference vs the inner lifetime, yeah that makes sense
Avatar
heinrich5991 2024-10-23 21:35
there's a bit magic involved there, too
21:35
the rust compiler knows that it can change the inner Foo lifetime to shorter ones
Avatar
So by adding the 'a there you are "accidentally" forcing the borrow to exist as long as Foo exists?
Avatar
heinrich5991 2024-10-23 21:36
because it looks into the struct and sees that the lifetime is used in a reference there
21:36
you are forcing the compiler to select a shorter lifetime
21:36
for the function
21:36
namely the shorter one of the inner lifetime and the self reference
21:36
which is always going to be the lifetime of the self reference
Avatar
heinrich5991 2024-10-23 21:37
so now the returned string has the lifetime of the self reference
Avatar
i guess im no expert
21:38
im a rust nobo sadSnail
Avatar
So you can't drop the reference, since the returned strings lifetime would have to end there but it doesn't
Avatar
i wonder if its that, or that u simply cant move the object
21:39
because of the reference lifetimes
21:39
drop needs a move but the implicit drop doesnt i think
Avatar
Avatar
Ryozuki
i guess im no expert
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
Avatar
so its more a question of being able to "move" it or not
21:39
not about dropping
Avatar
Avatar
Learath2
So you can't drop the reference, since the returned strings lifetime would have to end there but it doesn't
heinrich5991 2024-10-23 21:39
yes
Avatar
Avatar
Ryozuki
not about dropping
Well a drop is a move, no?
Avatar
the explicit drop call is
21:40
drop()
21:40
a implicit drop doesnt need to move it just deallocs in place no?
21:40
thats my understanding
21:40
idk
Avatar
Avatar
heinrich5991
drop doesn't get rid of the variable, just of its value. the type is still there
heinrich5991 2024-10-23 21:40
the problem is AFAIK that the variable exists beyond the drop
21:40
after the block ends, the variable is no longer there
21:41
it's just the instance that you drop
Avatar
Avatar
Learath2
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
well, u mostly hit this stuff with self referential stuff
Avatar
Avatar
Ryozuki
well, u mostly hit this stuff with self referential stuff
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 😄
Avatar
idk, i code rust daily at work and i rarely hit issues like this
21:42
and i dont do simple stuff
Avatar
Avatar
Learath2
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 😄
idk it would be lot of work
Avatar
heinrich5991 2024-10-23 21:43
I guess I was forced to learn with a stricter borrow checker
Avatar
Avatar
heinrich5991
I guess I was forced to learn with a stricter borrow checker
You were there before 1.0?
Avatar
heinrich5991 2024-10-23 21:43
people say it's become more complicated to teach the borrow checker since it got relaxed. because the easy examples simply compile nowadays
Avatar
Avatar
Learath2
You were there before 1.0?
heinrich5991 2024-10-23 21:44
yes, but the borrow checker also got laxer after 1.0
Avatar
Avatar
Ryozuki
idk it would be lot of work
I meant as like an option to disable it completely
21:44
I would totally disable it for a couple months to learn better
Avatar
The Dark Arts of Advanced and Unsafe Rust Programming
Avatar
Avatar
heinrich5991
yes, but the borrow checker also got laxer after 1.0
heinrich5991 2024-10-23 21:45
I recently noticed that I can claim 10 years of rust experience 😄
Avatar
damn
21:45
i started on 2018
21:45
4 years i guess
Avatar
heinrich5991 2024-10-23 21:46
matricks was at least among the people who got me into rust
Avatar
I have still yet to convince myself to start trying to use Rust
21:48
it's a damn cult I tell ya
21:48
something fishy about those guys
Avatar
just do it
21:48
u will learn something
21:48
even if u dont like it or use it
21:49
and nothing bad comes from learning more languages (edited)
Avatar
We should write more Haskell
Avatar
im learning ocaml now
Avatar
The functional people are the real cult 😄
Avatar
@Learath2 honestly, functiona llangs have nice stuff
21:49
like partial application
Avatar
God forbid I mutate a variable
Avatar
In computer science, partial application (or partial function application) refers to the process of fixing a number of arguments of a function, producing another function of smaller arity. Given a function f : ( X × Y × Z ) → N ...
Avatar
heinrich5991 2024-10-23 21:50
did you see that rust is making the libcs make exit thread-safe? ^^
Avatar
Avatar
heinrich5991
did you see that rust is making the libcs make exit thread-safe? ^^
How can exit become thread-safe even?
Avatar
Avatar
heinrich5991
did you see that rust is making the libcs make exit thread-safe? ^^
epic win
Avatar
Avatar
Learath2
The functional people are the real cult 😄
I enjoy writing pointless code
Avatar
Avatar
Learath2
How can exit become thread-safe even?
heinrich5991 2024-10-23 21:51
did you know that calling exit on two different threads is instant UB in C? ^^
Avatar
point free programming my beloved
Avatar
Avatar
heinrich5991
did you know that calling exit on two different threads is instant UB in C? ^^
I did
Avatar
heinrich5991 2024-10-23 21:52
I did not and found it insane. but that's probably changing in the future
21:52
i.e. exit will likely become threadsafe in the future
Avatar
I also thought it was unfixable though
Avatar
Avatar
heinrich5991
did you know that calling exit on two different threads is instant UB in C? ^^
Isn't it only natural that you can't exit more than once?
Avatar
Avatar
Learath2
I also thought it was unfixable though
heinrich5991 2024-10-23 21:52
just take a lock at the start of the exit impl
21:53
and never drop it
Avatar
Oh, just bolting on a lock, yeah I guess you can make it thread-safe like that
Avatar
did you know ocaml functions only take 1 argument
Avatar
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
Avatar
heinrich5991 2024-10-23 21:54
(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)
Avatar
Avatar
Learath2
Oh, just bolting on a lock, yeah I guess you can make it thread-safe like that
heinrich5991 2024-10-23 21:55
if you want to be more performant, you can do an atomic compare-and-exchange
Avatar
ChillerDragon 😮
Avatar
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?
Avatar
Avatar
jxsl13
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
See #7669
poggers2 1
Avatar
Load a map that doesn't have an equivalent 0.7 map in maps7/ This will disable sv_sixup as there is no supported map for 0.7. Try to load a map that has a map in maps7, but it won't check t...
Avatar
(I mean, it's fine, should be nice that libc also fixes it, just wondering why it's being done on that side)
Avatar
Avatar
Learath2
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?
heinrich5991 2024-10-23 21:56
because rust tries to interoperate with the world. you can't make it safe to exit if not everyone takes the same lock
Avatar
Avatar
heinrich5991
because rust tries to interoperate with the world. you can't make it safe to exit if not everyone takes the same lock
As in the ffi case or if someone bypasses the rust wrapper?
Avatar
heinrich5991 2024-10-23 21:56
e.g. python calling sys.exit concurrently with a rust library calling std::process::exit should ideally not be UB
21:57
if a rust library is called from python, for example
22:00
similar to how rust putting a lock around std::env::set_var isn't enough
22:01
because rust tries to interoperate with the world and the world has decided that everyone can read the environment variables without taking a lock (edited)
Avatar
uclibc doesn't seem to hold it long enough, musl doesn't seem to have a lock at all
22:03
freebsd does it properly 😄
Avatar
heinrich5991 2024-10-23 22:03
musl and freebsd recently added the lock
22:03
The current implementation of std::process::exit is unsound on Linux and possibly related platforms where it defers to libc's exit() function. exit() is documented to be not thread-safe, and he...
22:03
yep
22:03
very recent
Avatar
heinrich5991 2024-10-23 22:03
as a result of the rust thing ^^
22:04
see the links in the first post of that issue
22:04
note that it was caused by an issue reported by deen 😄
Avatar
Rust should either mark std::process::exit as unsafe
This is probably the route that I would have gone through
Avatar
lol
Avatar
heinrich5991 2024-10-23 22:06
that just sounds insane to me ^^
Avatar
I have a question, how will rust programs running on an old system be correct now?
Avatar
heinrich5991 2024-10-23 22:06
why would process exiting ever be UB
Avatar
People don't run bleeding edge libcs
Avatar
how would u exit soundly in a thread safe manner?
Avatar
Avatar
Learath2
I have a question, how will rust programs running on an old system be correct now?
heinrich5991 2024-10-23 22:06
they added a lock
Avatar
Avatar
heinrich5991
they added a lock
On the rust side, through ffi it would be UB e.g.
Avatar
with a non thread safe libc exit
22:07
can u do a syscall directly? xd
Avatar
Avatar
Learath2
On the rust side, through ffi it would be UB e.g.
heinrich5991 2024-10-23 22:07
yes. it's unfixable in general withotu fixing libcs
22:07
but that's being done, so everythign will work out fine
22:07
(and they also want ot take it to the C standard)
22:08
(it's already accepted in POSIX, I think)
Avatar
Avatar
heinrich5991
why would process exiting ever be UB
Because it is, idk some things are just not perfectly thought out. I would have marked exit unsafe because it just is unsafe, you can talk about whether that's sane or not but it doesn't change the fact that it can and does cause UB
Avatar
who are the old beards that manage posix?
Avatar
Avatar
Learath2
Because it is, idk some things are just not perfectly thought out. I would have marked exit unsafe because it just is unsafe, you can talk about whether that's sane or not but it doesn't change the fact that it can and does cause UB
heinrich5991 2024-10-23 22:09
or you try to fix the root cause, that the C standard seemingly accidentally made exit thread-unsafe
Avatar
Avatar
heinrich5991
e.g. python calling sys.exit concurrently with a rust library calling std::process::exit should ideally not be UB
the probability of me using a library that calls exit:
Avatar
Avatar
heinrich5991
but that's being done, so everythign will work out fine
It won't be fixed on older systems though, no? There the "safety" of std::process::exit will just be hiding the fact that it is indeed very much UB when called at the same time through ffi e.g.
Avatar
heinrich5991 2024-10-23 22:10
older systems contain bugs, that always happens. when things are on a timeline to be fixed, I'm happy
Avatar
Avatar
heinrich5991
or you try to fix the root cause, that the C standard seemingly accidentally made exit thread-unsafe
You can't force people to download a new libc, but marking it unsafe will 100% reflect the truth for every system on earth
Avatar
heinrich5991 2024-10-23 22:11
you can't force people to not run buggy kernels, but rust can still say that File::open will not cause UB
Avatar
Honestly props to the rust people that they even managed to get so many desperate parties to agree to fix it to begin with
Avatar
heinrich5991 2024-10-23 22:11
I think it was easier because it was relatively obvious that this is a bad idea
22:12
to make calling exit from multiple threads UB, over a probably accidental wording issue
Avatar
Avatar
heinrich5991
you can't force people to not run buggy kernels, but rust can still say that File::open will not cause UB
Every instruction is UB We can't trust CPU manufacturers! The CIA is putting chemicals in our transistors!
Avatar
heinrich5991 2024-10-23 22:12
that stemmed from a fact that the C standard wanted to make calling exit from an atexit handler UB
22:12
e.g. exit is not in the otherwise exhaustive list of thread-unsafe functions
22:13
in the C standard. so there's already some discrepancy
Avatar
Avatar
risu
Every instruction is UB We can't trust CPU manufacturers! The CIA is putting chemicals in our transistors!
bugs = protein
Avatar
Avatar
heinrich5991
you can't force people to not run buggy kernels, but rust can still say that File::open will not cause UB
But this is different, the kernel does promise that open(2) will behave a certain way, rust relies on that promise which is "correct". The C standard and POSIX never made the promise that exit(3) is thread-safe, marking it "safe" is in"correct"
Avatar
heinrich5991 2024-10-23 22:13
but we know that impls and POSIX will correct, and likely the C standard, too
Avatar
But you can't retroactively correct it. Things that are published are set in stone
Avatar
heinrich5991 2024-10-23 22:14
and e.g. glibc is also thread-safe if you register fewer than 31 atexit handlers
22:14
there are also buggy kernels out there
22:14
we can just call them buggy and move on
Avatar
It's not a "bug" to make something not thread-safe if you made no such promises
Avatar
heinrich5991 2024-10-23 22:14
even if they could cause otherwise correct rust code to have UB
22:15
welllll. why is exit not in the list of thread-unsafe functions?
Avatar
Avatar
jxsl13
bugs = protein
You will own nothing and you will be happy!
Avatar
heinrich5991 2024-10-23 22:15
and everyone seems to agree that exit not being threadsafe is a mistake
Avatar
Avatar
risu
You will own nothing and you will be happy!
Klaus Schwab quotes, eh? (edited)
Avatar
I just know the quote, not the guy 😔
Avatar
should lookup the guy
Avatar
Avatar
jxsl13
bugs = protein
maybe I'll start describing software as protein-rich from now on (edited)
Avatar
"my protein are the bugs in my code"
Avatar
Avatar
heinrich5991
welllll. why is exit not in the list of thread-unsafe functions?
Where is this list? As far as I know C99 explicitly states that more than one call to exit is immediately UB, threads shouldn't even come into the equation
22:18
C99 doesn't even have the concept of a thread
22:19
I'm guessing it's somewhere in POSIX
Avatar
pthread
22:20
p <--
Avatar
Avatar
heinrich5991
and everyone seems to agree that exit not being threadsafe is a mistake
Everyone can agree on whatever they want, there is a ground truth here peoples opinions aren't all that relevant to this discussion
Avatar
Posix
Avatar
Avatar
jxsl13
p <--
haha he said pee
banhammer 1
Avatar
Avatar
Learath2
Everyone can agree on whatever they want, there is a ground truth here peoples opinions aren't all that relevant to this discussion
heinrich5991 2024-10-23 22:21
if you were to do that, you'd have no threads before C11. seems not very useful
Avatar
(even if dennis ritchie himself came back from the dead to say that it was a mistake, it was still published and implemented, opinions are irrelevant)
Avatar
Avatar
heinrich5991
if you were to do that, you'd have no threads before C11. seems not very useful
There is no concept of a memory model or threads, so everything you do is at your own risk aka unsafe. POSIX makes you some guarantees which you can rely on instead in this case
Avatar
All functions defined by this volume of POSIX.1-2017 shall be thread-safe, except that the following functions1 need not be thread-safe.
Though this is fairly conclusive, so I guess there is some sense to say that the standard itself is buggy since it contradicts itself
(edited)
Avatar
heinrich5991 2024-10-23 22:35
Dive deep into the open-source architecture of Lichess.org to understand the technical processes behind making a move in a game.
22:35
I found it interesting that they use short JSON keys and compressed representations
Avatar
That reminds me, Thibault is such an interesting person, lichess is probably my favorite open source product out there
👍 1
22:36
It truly embodies everything I like about the open source sphere
Avatar
heinrich5991 2024-10-23 22:44
I also really like it
23:05
they also publish their server costs and system architecture which is cool to look at (edited)
Avatar
I also love how they deployed, proof that you don't need weird cloud solutions to serve billions of requests
Exported 449 message(s)
Timezone: UTC+0