Guild icon
DDraceNetwork
Development / developer
Development discussion. Logged to https://ddnet.tw/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 2022-11-09 00:00:00Z and 2022-11-10 00:00:00Z
02:41
xd
Avatar
Avatar
deen
How did you trigger the crash? Just on server start?
Run Linux DDNet-Server binary from website, join server, change map to the one I sent, server crashes. Nothing fishy in the terminal log except "Segmentation Fault" That is a 100% way to reproduce the bug. We also managed to crash the server randomly just by playing a bunch on other maps. Building from the source fixes the issue, at least on anyone's machine except @deen santatrollet
Avatar
suggestion, add an icon at the edge of the hud that indicates if your team is locked or not
Avatar
[quakenet] ChillerDragon BOT 2022-11-09 07:21:55Z
Yea that sounds nice
07:22
also lock icons can be really obvious to understand :)
07:30
good morning
Avatar
Avatar
YupHio
Do the published binaries on the DDNet website get built on a standard build machine (like a container), or does someone just build with whatever environment they have locally that day and then publish it? xD (edited)
built in a debian 10 chroot
Avatar
Add option to let people keep vote menu opened after starting a vote. cl_show_votes_window_after_voting basically. It will be handly for other mods and for ddnet, when you voting server difficulty first and map after. Menus dont have much config options afaik, so adding new option and testing it with other options mustn't be a problem. Duplicate of https://github.com/ddnet/ddnet/issues/813
Avatar
Avatar
YupHio
Run Linux DDNet-Server binary from website, join server, change map to the one I sent, server crashes. Nothing fishy in the terminal log except "Segmentation Fault" That is a 100% way to reproduce the bug. We also managed to crash the server randomly just by playing a bunch on other maps. Building from the source fixes the issue, at least on anyone's machine except @deen santatrollet
Thanks, I can repro the crash
Avatar
[quakenet] ChillerDragon BOT 2022-11-09 09:49:31Z
F
09:50
wait I can not reproduce how do I get git some? :(
09:51
Would be hilarious if it worked
Avatar
A little helper script to quickly generate git commits. - GitHub - GROSSWEBER/git-some: A little helper script to quickly generate git commits.
10:27
This one maybe
Avatar
Avatar
GitHub
Click to see attachment 🖼️
You about "ui_close_window_after_changing_setting"?
10:34
It would be really convenient if for example there was some kind of flag from server-side
Avatar
Avatar
Kurosio
You about "ui_close_window_after_changing_setting"?
Issue transfered to https://github.com/ddnet/ddnet/issues/813, as @Ryozuki commented maybe finally implementing server custom menu will be solution, but not sure how that will work and probably a lot of new graphics will be needed, to fold/unfold and maybe even drag this menu
Avatar
I already did that xd
Avatar
I remember, but that was on 0.7 and ddnet guys are kinda sceptical, i think justatest
Avatar
Avatar
Anime.pdf
I remember, but that was on 0.7 and ddnet guys are kinda sceptical, i think justatest
I think you right
Avatar
It doesnt need more graphics than what we have currently
Avatar
2021 06 xd
Avatar
That looks good
10:50
I dislike the fade out tho
Avatar
It no libraries needed, has window action flags, and registers an inverse function, interconnected by a tree For example if you kill a menu, all submenus will be closed (edited)
Avatar
Yeah sounds good
Avatar
It's a little sad that other mods are statistically insignificant
Avatar
Avatar
Learath2
It's a little sad that other mods are statistically insignificant
2982pepecry
Avatar
It'd be great for the health of the game if we had more mod players
Avatar
Avatar
Learath2
It's a little sad that other mods are statistically insignificant
It is really difficult to make a mod idea that stays interesting for players so they keep returning
🔜 1
™️ 1
Avatar
Avatar
deen
Thanks, I can repro the crash
So I made a nightly build with symbols and can't reproduce it anymore :/
Avatar
Heisenbug pog
Avatar
or it's fixed in nightly maybe
12:08
nope, just happens without symbols, but still fails on nightly without symbols
Avatar
Asan is clean too
Avatar
1. Start server 2. Connect to server with client 3. Change map to Skill_Issue.zip 4. Linux x86-64 nightly build crashes, 16.5 too: ``` Thread 1 "DDNet-Server" received signal SIGSEGV, Segmentation fault. 0x00000000004c218d in ?? () (gdb) bt #0 0x00000000004c218d in ?? () #1 0x00000000004ba7c1 in ?? () #2 0x00000000004eedd6 in ?? () #3 0x000000000040be14 in ?? () #4 0x00007ffff7c30290 in __libc_start_call_main (ma...
Avatar
Skill Issue
Avatar
@deen it crashes exactly when a client is connected
12:35
You can start the server with that map exactly
12:35
And it'll only crash once a player connects
Avatar
Well, still doesn't help me with figuring out the reason
Avatar
i had 2 maps on my old pc
12:55
one crashed server
12:55
second every player that connected
12:55
kekw
Avatar
Updating crates.io index is this gonna happen every time when i clean build or it is downloaded somewhere in home directory? took like 2 mins
Avatar
I'm not getting that when building from scratch
13:11
all I get is the expected components in Rust being rebuilt: Compiling ddnet-engine-shared v0.0.1 (/Users/deen/git/ddnet/src/engine/shared) Compiling ddnet-test v0.0.1 (/Users/deen/git/ddnet/src/rust-bridge/test) Compiling ddnet-base v0.0.1 (/Users/deen/git/ddnet/src/base) Compiling ddnet-engine v0.0.1 (/Users/deen/git/ddnet/src/engine) Finished release [optimized] target(s) in 0.67s
Avatar
yeah ig it is on the home folder, i am not getting it anymore. i just installed rust first time so
Avatar
Avatar
nori
Updating crates.io index is this gonna happen every time when i clean build or it is downloaded somewhere in home directory? took like 2 mins
those go into ~/.cargo
Avatar
The first index update is quite big
Avatar
I think they're working on sparse registries which would make the updates small
13:32
@Ryozuki do you know how I can execute rust-analyzer without setting it up in some IDE?
Avatar
I guess call the binary and give it the path to the dir with cargo toml
13:33
Note that rustup doesnt add it to path
13:33
There is a command to find where its located
13:33
I dont remember
Avatar
found it
13:34
~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rust-analyzer
Avatar
Does cargo rust-analyzer work?
Avatar
no
13:39
I don't manage to reproduce the error without an IDE
13:39
I guess I have to set up one
Avatar

Checklist

  • [ ] Tested the change ingame
  • [ ] Provided screenshots if it is a visual change
  • [ ] Tested in combination with possibly related configuration options
  • [ ] Written a unit test (especially base/) or added coverage to integration test
  • [ ] Considered possible null pointers and out of bounds array indexing
  • [ ] Changed no physics that affect existing maps
  • [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-ad...
Avatar
I use neovim
13:43
@heinrich5991 the logs may not show to stdout
13:43
Maybe they are on a file
13:44
RA_LOG=info
13:44
If rust-analyzer outright crashes, try running rust-analyzer analysis-stats /path/to/project/directory/ on the command line. This command type checks the whole project in batch mode bypassing LSP machinery.
13:45
@heinrich5991
Avatar
ah
13:49
it doesn't crash though, it completes
13:49
AFAICT
Avatar
I think the program itself doesnt crash
13:50
It reports that it fails to check cuz the build script
13:50
Panics
Avatar
"failed to run build scripts Check the server logs for additional information"
13:54
do you know where those are? @Ryozuki
Avatar
Doesnt it say where?
13:57
I forgot rn
13:57
Not at a pc currently
Avatar
I found it in the output console within vscode
Avatar
Detect that we're being run from rust-analyzer and don't link to C++ libraries in that case. Fixes #6019.

Checklist

  • [x] Tested the change ingame
  • [ ] Provided screenshots if it is a visual change
  • [ ] Tested in combination with possibly related configuration options
  • [ ] Written a unit test (especially base/) or added coverage to integration test
  • [ ] Considered possible null pointers and out of bounds array indexing
  • [ ] Changed no physics that affect existing map...
Avatar
@Ryozuki does this help with your problem? https://github.com/ddnet/ddnet/pull/6025
Avatar
@heinrich5991 where did you find the env var? I did google around a bit for it but couldn't find it
Avatar
I googled around and didn't find anything but some other weird hack
14:12
so I just took a look at the environment I get
Avatar
Yeah I was thinking that too 😄
Avatar
then checked the source code of rust-analyzer for that variable, to see if it's reliable
Avatar
trying now
Avatar
Avatar
ReiTW
And it'll only crash once a player connects
Avatar
How does that even happen? Why is FindEntities even returning >0 here?
Avatar
80d72cf Fix being run from rust-analyzer with a clean environment - heinrich5991 57fbaa3 Merge #6025 - bors[bot]
Avatar
Player just joined, but character isn't initialized properly yet?
Avatar
Hm, no laptop with me so I can't check but Players don't really have a position, nor is CGameWorld even aware of them iirc
14:41
I mean if it fixes the issue it fixes the issue. Just wanted to make sure we aren't masking a deeper issue
Avatar
Hm, it's really weird indeed
14:42
We dereference the character in FindEntities as well and there it doesn't fail
14:43
the only thing I can imagine is that the entity has ENTTYPE_CHARACTER type, but is still not a CCharacter
Avatar
Do we dereference as a CCharacter there? Maybe some undefined behaviour?
Avatar
there we use it as CEntity only
Avatar
ubsan should catch that though, hm
Avatar
Learning cxx rust
15:20
Hope i can add some rust stuff
Avatar
30df2ca Disable IPO for official releases again (for ddnet/ddnet#6023) - def-
Avatar
Avatar
Ryozuki
Click to see attachment 🖼️
lmaooo
Avatar
I realize it's only a joke. sleep() doesn't guarantee accurate sleep times, this function might easily return num1 + num2 - 1
Avatar
sleep(abs(num1) sleep(abs(num2)
Avatar
considering how slow python is i could imagine they have code paths like these
Avatar
num1 + num2 justatest
17:43
omg so slow
18:20
Got a new job
18:20
My pay augmented by 8k€
18:20
nekospin
18:21
After 4 interviews
18:23
Rust,erlang,elixir,julia
18:23
Some langs they use
Avatar
Avatar
Ryozuki
My pay augmented by 8k€
monkaS
Avatar
(yearly)
18:24
thats...
18:24
nice
18:24
:)
Avatar
I mean im above average on spain rn ngl
Avatar
where are you working? what are you doing there? what do you make?
18:25
just trying to figure out whether it's something I'd also like to do
Avatar
Avatar
Ryozuki
I mean im above average on spain rn ngl
in ukraine average salary is ~320$/mo kek
Avatar
They focus a lot on distributed systems
Avatar
you know erlang and elixir? 😮
Avatar
And virtual machines like java
18:26
I dont
Avatar
ah, I misread
18:26
cool
Avatar
Its what they use
18:26
Anyway i can free myself from nodejs stuff now
18:26
Full rust
Avatar
cool
Avatar
Avatar
Ryozuki
My pay augmented by 8k€
per month or per year? 😄
Avatar
Per year ye
18:27
If i got 8k per month i would be super upper class
18:27
BASED
Avatar
and what are you doing there?
Avatar
I dont wanna dox myself xd
18:29
Anyway happy day
Avatar
okay 🙂
Avatar
You are studying still right?
Avatar
yes
Avatar
Im sure u will get a good job
18:30
Ur rly good
Avatar
although I'll probably finish at some point ^^
18:30
thank you
Avatar
One thing is its easy to get comfy on a boring job thats routine
18:31
But well im young so i wanted to change and risk a bit more
Avatar
Avatar
heinrich5991
although I'll probably finish at some point ^^
you never finish studying
Avatar
every day you learn something new
Avatar
maybe one will finish university though 😉
Avatar
I think this dev chat makes a bubble
18:32
The level here is above average by a lot
Avatar
Rust bubble? 😄
Avatar
Nah xd
18:32
Well too
18:32
All hail rust
18:32
monkalaugh
Avatar
Avatar
Ryozuki
The level here is above average by a lot
So one might think they dont know much
18:33
Thanks for coming to my ted talk
18:33
Im still amazed that ddnet is what got me most into programming
18:33
And here i am, working on it now
18:33
nekospin
Avatar
@Ryozuki local company in Barcelona? How are the notice periods in Spain usually? No one wanted to hire me when I had 6 months notice period 😄
18:37
and congrats
Avatar
how long is your notice period now? @deen
Avatar
15 day period
Avatar
Avatar
heinrich5991
how long is your notice period now? @deen
1 month, but it's a US company so kind of expected to be the legal minimum here
Avatar
Avatar
Ryozuki
I think this dev chat makes a bubble
all chats are a bubble, a non representative group of any larger group
Avatar
i guess xd
Avatar
for instance, no chat has people with no internet access
Avatar
31% monthly net pay increase
18:49
Not bad
Avatar
Only GCC supports this, Clang doesn't. Let's see if it finds any problems, UBSan seems not helpful here.

Checklist

  • [ ] Tested the change ingame
  • [ ] Provided screenshots if it is a visual change
  • [ ] Tested in combination with possibly related configuration options
  • [ ] Written a unit test (especially base/) or added coverage to integration test
  • [ ] Considered possible null pointers and out of bounds array indexing
  • [ ] Changed no physics that affect existing maps
  • [ ]...
Avatar
is noalias tag standard?
19:11
restrict
19:11
its called
19:12
19:12
this is what a &mut is in rust more or less iirc
19:13
this can enable some optimizatiosn
19:14
maybe we can use it
19:14
but its hard to use cuz UB
19:15
oh wait
19:15
is this a C only thing?
19:15
not C++? xd
Avatar
it works in c++ with gcc and double underscore: __restrict__
Avatar
so it might be non standard
19:16
in c++
19:16
>
restrict is a c99 keyword. Yes, Rpbert S. Barnes, I know that most compilers support __restrict__. You will note that anything with double underscores is, by definition, implementation specific and thus NOT C++, but a compiler specific version of it. – KitsuneYMG Jan 6, 2010 at 9:31
(edited)
Avatar
Debugging with an optimized binary and LTO is such pain
Avatar
depends
19:27
do we have another UB in our code?
Avatar
Avatar
Jupstar ✪
do we have another UB in our code?
the answer is probs yes
19:30
its c++
19:30
ub can exist and be mostly harmless iirc
Avatar
Avatar
Learath2
Debugging with an optimized binary and LTO is such pain
enabling lto on a rust project made the runtime go from 70s to 58s
19:31
poggers
19:31
thinlto 60s
19:31
within noise probs
Avatar
i once had a compiler bug in gcc with lto
19:41
so not impossible its a compiler bug, better always also test with clang
Avatar
why does C++ not have that "restrict" feature?
Avatar
Yeah, weird. I wanted to use that too
19:51
two alternatives: 1. make FindEntities be a template method so no cast 2. Always keep apPlayersInRange as CEntity**
19:51
The second one works
19:51
haven't tried first yet
19:53
zero-length arrays and unions seem like weird hacks to work around this, don't like them
Avatar
[build] mimalloc: warning: thread 0x7f725bc006c0: unable to allocate aligned OS memory directly, fall back to over-allocation (67108864 bytes, address: 0x7f7257000000, alignment: 67108864, commit: 0) [build] mimalloc: warning: thread 0x7f725bc006c0: mi_usable_size: pointer might not point to a valid heap region: 0x7f7254020080 [build] (this may still be a valid very large allocation (over 64MiB)) wtf is that xD
20:02
is that a new rust feature xD
Avatar
where do you get that from? 😮
20:03
is ddnet outputting that?
Avatar
i started vscode, pressed compile
20:03
yeah
Avatar
hm, that sounds like it might be vscode though
20:04
I think mimalloc is microsoft malloc
20:04
mimalloc is a compact general purpose allocator with excellent performance. - GitHub - microsoft/mimalloc: mimalloc is a compact general purpose allocator with excellent performance.
Avatar
ok but weird, bcs its inside the terminal and says [build]
20:06
yep also happens in terminal
Avatar
hm
20:07
it's during build or during run?
Avatar
build
20:07
maybe clang broken
20:12
1 google entry for that warning 5 days ago
20:12
ez
20:12
seems to be related to mold
20:13
and linux 6.1
20:13
link?
Avatar
u should report it
20:14
well i needed to upgrade to linux 6.1 bcs my nvme doesnt work on linux 6.0 xD
20:14
so quite possible i am just living on the edge too much
Avatar
linux 6.1 is the one that contains rust, no?
20:15
or at least infrastructure to support modules in written in rust
Avatar
i think so yeah
Avatar
i use 6.1
20:16
didnt find problems
20:17
but i use gcc
20:17
and not mold
20:17
wait
20:17
do i use 6.1
Avatar
I have this feeling that the issue here is that the character is in static memory
Avatar
maybe not
20:17
20:17
i use 6.0.7 lol
20:17
i guess gentoo hasnt patched it yet
Avatar
debian fast af
Avatar
well i wonder why gentoo doesnt have 6.1
Avatar
Avatar
deen
two alternatives: 1. make FindEntities be a template method so no cast 2. Always keep apPlayersInRange as CEntity**
Oh, so you figured it out? What is the real issue?
Avatar
Avatar
Ryozuki
well i wonder why gentoo doesnt have 6.1
probs bcs its only release candidate yet
Avatar
I didn't spot a strict aliasing issue there
Avatar
ah yeah
Avatar
Avatar
Ryozuki
well i wonder why gentoo doesnt have 6.1
It's also probably because the patchset isn't tested yet
Avatar
i need to get a guru account
Avatar
Ah, nope, vanilla-sources doesn't have 6.1 yet either
Avatar
who the fuck takes const ref to an int xD
20:21
const bool
Avatar
Avatar
Jupstar ✪
who the fuck takes const ref to an int xD
It should work
Avatar
ref
20:21
yes
20:30
heinrich already got his answer two years ago
20:30
xd
20:30
but const ref int is 8 bytes, vs 4 bytes if the compiler isnt optimizing this lel
Avatar
it's gonna take an extra 8 bytes
20:30
the actual int has to be stored somewhere, too
Avatar
registers
Avatar
not if you have a pointer to it ^^
Avatar
@Jupstar ✪ how do u find this
Avatar
so a const ref to an int needs like 12 bytes in this case
Avatar
Avatar
Ryozuki
@Jupstar ✪ how do u find this
i remembered the pr when we talked about it
20:32
so i just searched the pr
Avatar
Avatar
heinrich5991
so a const ref to an int needs like 12 bytes in this case
true^^
Avatar
Avatar
heinrich5991
note that relaxed atomics use exactly the same instructions for loading/storing as normal variables on all platforms that I know of: https://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
if somebody wants to enlighten me, i am still interested in knowing if atomics have downsides e.g. variables could live in L1/2/3 cache only or simply in registers But ofc interesting cases are objects with a specific lifetime, e.g. heap objects And what about stack allocated objects? What if a share a stack object with another thread lol
21:05
who is compiler pro here, do we have such ppl
Avatar
if you put your atomic into a register, then there cannot be a downside
Avatar
Avatar
Learath2
I didn't spot a strict aliasing issue there
i think with LTO FindEntities is inlined and the Entities array being passed to it in a different type is causing the strict aliasing problem.
Avatar
I don't quite get your question. what do you mean? do you ask if atomics can live in registers?
21:15
yes, they can
Avatar
Avatar
heinrich5991
if you put your atomic into a register, then there cannot be a downside
well if the compiler can assume it so easily i some situation it probs optimizes them out
Avatar
it's the same as for a normal variable
21:16
if it'd put the normal variable into a register, it'd also do it for the atomic
Avatar
atomics have overhead right
Avatar
not Ordering::Relaxed ones (edited)
21:16
on all platforms that I know
Avatar
i find it curious many people confuse volatile with it being thread safe because the compiler cannot reorder it
21:17
right?
Avatar
Avatar
deen
i think with LTO FindEntities is inlined and the Entities array being passed to it in a different type is causing the strict aliasing problem.
Hm, I don't really see the aliasing issue there :/
21:17
Maybe I need to brush up on my aliasing rules
Avatar
Avatar
heinrich5991
if it'd put the normal variable into a register, it'd also do it for the atomic
well with what optimization level?
Avatar
Avatar
Ryozuki
i find it curious many people confuse volatile with it being thread safe because the compiler cannot reorder it
volatile was the way to go before C had a memory model (edited)
Avatar
ah i see
Avatar
e.g. o2 might consider this a break of the standard which garantuees visibility of the atomic or smth like this
Avatar
Avatar
Jupstar ✪
well with what optimization level?
at the optimization level where vector iterators don't have overhead over pointers
Avatar
new shiny stuff
21:19
With GitHub code search, your code—and the world’s—is at your fingertips.
Avatar
well thats the optmization i use xdd
Avatar
its funny
21:20
they show rust code
21:20
in the image
21:20
XD
21:20
Avatar
i could swear i trigged this today already, without applying for the beta
Avatar
I wonder if this is just a compiler bug, it smells sane to me
Avatar
Avatar
heinrich5991
on all platforms that I know
if i remember correctly, its because relaxed is a weak memory ordering right? but if you use a strong memory ordering on a weakly ordered cpu arch it has a lot of overhead
Avatar
they should show inlay hints for parameters so i can use references without ppl complaining that points are more obvious xdd
Avatar
i need to reread atomics again
21:23
and strong orderings in strongly ordered cpus are cheap too
21:23
such as x86
Avatar
its like with teeworlds strong and weak
Avatar
i think its not really overhead, but simply less optimization oppoturnities
21:25
i think the weak ordered cpus have to add more instructions
21:25
to achieve the strong ordering
21:25
i forgot the blog post
Avatar
i mean they have to flush all memory before the fence
21:26
thats already overhead
Avatar
yeah rip, we need a new multi threaded design
21:27
i kinda dislike "stopping" execution midrun
Avatar
well u gotta sync
21:27
somehow
Avatar
i wish we'd have amazin AIs that would be like. YO nobos here this is better
21:27
yes
21:27
sync at a specific point
21:27
but not so randomly
21:28
i mean our CPUs are optimized for this now anyway
21:28
but who knows what potentials we are wasting
Avatar
well it's not very random anyway, cache coherency is pretty well designed 😄
Avatar
and pretty slow xd
21:29
i used coherent memory first for our vulkan backend but an explicit flush at a good timepoint so much faster
21:29
the driver, hardware whatever simply isnt clever enough
Avatar
The issue is that the ram speed isn't catching up to the cpu. "Memory wall" creates a huge issue
Avatar
when 10ghz ram
Avatar
but wouldnt that be an argument against these random cache flushes
Avatar
shared l2 caches helped a fair bit in delaying the writeback
Avatar
u go back to RAM then
21:30
ok sure
Avatar
but at the end of the day, data just has to go to the ram for the caches to all sync up
Avatar
@Learath2 are l2 shared? wasnt the l3? i read about caches not long ago
Avatar
shared cache will make it a bit better
Avatar
but i dont know much
21:31
also why is a cache line 64bytes
Avatar
Avatar
Ryozuki
@Learath2 are l2 shared? wasnt the l3? i read about caches not long ago
Depends on the architecture
Avatar
we should do branchless programming
21:32
it can be rly fast
21:32
Avatar
Only really worth it in cases where branch predictor is more likely to fail than succeed, but yes, it's a nice place to get some optimization in
21:33
In general, data structures are made branchless by implicitly or explicitly padding them so that their operations take a constant number of iterations. Refer to the article for more complex examples.
21:34
the std string is a nice example
21:34
rings. Oversimplifying things, an std::string is comprised of a pointer to a null-terminated char array (also known as a “C-string”) allocated somewhere on the heap and one integer containing the string size.
>
A common value for a string is the empty string — which is also its default value. You also need to handle them somehow, and the idiomatic approach is to assign nullptr as the pointer and 0 as the string size, and then check if the pointer is null or if the size is zero at the beginning of every procedure involving strings.
>
However, this requires a separate branch, which is costly (unless the majority of strings are either empty or non-empty). To remove the check and thus also the branch, we can allocate a “zero C-string,” which is just a zero byte allocated somewhere, and then simply point all empty strings there. Now all string operations with empty strings have to read this useless zero byte, but this is still much cheaper than a branch misprediction.
Avatar
@Ryozuki Relaxed is the weakest possible memory ordering
21:35
it's basically none at all
21:35
at that point, the CPU only guarantees that it doesn't tear writes
21:35
but I know of no CPU that would tear writes at atomic widths
Avatar
@heinrich5991 whats a write tear?
Avatar
I seem to have an addiction to debugging, I just can't stop
Avatar
Avatar
Learath2
I seem to have an addiction to debugging, I just can't stop
weird addiction but ok
Avatar
Avatar
Learath2
I seem to have an addiction to debugging, I just can't stop
I'd employ you instantly 😄
21:36
but I'm no employer
Avatar
Avatar
Ryozuki
@heinrich5991 whats a write tear?
Say you are writing a 32 bit value, it shouldn't be possible for half the write 16 bit to be observed
Avatar
to be observed means read?
Avatar
E.g. the old value was FFFF FFFF. You are writing 0000 0000. 0000 FFFF should never be read
Avatar
@Ryozuki use non volatile int64 in jvm and read and write at the same time to one var
Avatar
Write tears can be an issue with some types that can have trap representations and stuff
Avatar
so it cant half write
Avatar
i dont even know if that still happens
Avatar
it shouldnt*
Avatar
but that was the first time i actually encountered it xD
Avatar
a tear is not completly writing all bytes
21:38
i guess
Avatar
yes
21:38
well
21:38
no
21:38
not writing all bytes at the same time
Avatar
so that the intermediate value can be observed
Avatar
is write tear the term?
21:38
i only see vsync stuff in google
Avatar
lel
Avatar
when merge vk pr for more awesome vk prs
21:39
soon mailbox support
21:39
for tearless lower latency gameplay
21:39
and fifo relaxed for tryhards
Avatar
I'll spend 30 more minutes on this, if I don't get it I need to find a way to stop myself 😛
Avatar
Avatar
Ryozuki
is write tear the term?
Atomic vs. non-atomic operation, Programmer All, we have been working hard to make a technical sharing website that all programmers love.
Avatar
Ok, deen is definitely right. The compiler seems confident FindEntities doesn't modify apPlayersInRange
Avatar
change it to array ref and u'll know
Avatar
I'm still wondering if this is standard C++ or the compiler optimizing too much
21:48
but probably it's standard and I have to go through and change dozens of places in DDNet code now 😄
Avatar
I think it's the compiler to be honest. This really looks sane to me :/
Avatar
but if u explicitly take the pointer of the array, what then?
Avatar
Avatar
Jupstar ✪
but if u explicitly take the pointer of the array, what then?
what do you mean by that?
Avatar
&aArray and aArray are the same pointer wise
21:49
but maybe its still aliasing differently
Avatar
Avatar
Learath2
I think it's the compiler to be honest. This really looks sane to me :/
I think at the point where you use (CEntity **) apPlayersInRange the compiler says this is a totally different value than apPlayersInRange since they have a different type. And then it reorders the inlined FindEntities code to be run afterwards.
21:50
Since FindEntities has no side effects anymore then
Avatar
Well I can actually check this. Let me just disassemble it 😛
Avatar
so if you call a function with a parameter that gets written to, don't cast it to another type
21:51
I'd be happier if this was a compiler bug and not another annoying C/C++ thing to keep in mind when coding/reviewing
21:52
but just disabling strict aliasing probably costs too much performance
Avatar
changed all alaising and works
Avatar
Why does it work?
Avatar
c++ struct measurements_t { uint8_t level; uint16_t temperature; uint32_t force; }; void convert(const uint8_t* data, struct measurements_t* measurements) { /* Fill measurements object with raw data. */ *measurements = *((struct measurements_t*) &data[0]); }
Avatar
I think the article is wrong in claiming that this is UB because of the aliasing rule
Avatar
In an attempt to convert data stored in a buffer (maybe read over a network connection) into a high-level structure, a pointer to ‘struct measurements_t’ is aliased with a pointer to a ‘uint8_t’. Since both types are incompatible (pointer to struct vs. pointer to ‘uint8_t’) this code is a violation of the strict aliasing rule. Experienced C developers most likely recognized immediately that this code yields undefined behavior, but they would have probably attributed it to struct padding and alignment issues. The real reason, as we know by now, is a violation of the strict aliasing rule.
Avatar
because uint8_t is unsigned char, and char stuff is allowed to alias
22:01
it might still be UB due to other reasons
22:01
like alignment
Avatar
Avatar
deen
Why does it work?
i dunno i mean we dont go from CCharacter pointers to CEntity pointers, but from array to pointer but i dunno why exactly its forbidden
Avatar
The accepted answer to What is the strict aliasing rule? mentions that you can use char * to alias another type but not the other way. It doesn't make sense to me — if we have two pointers, one of...
Avatar
but lto really gives a shit about u using UB XD
Avatar
ea sports
Avatar
its in the game
22:07
@Jupstar ✪
22:07
xd
Avatar
the first comment lol
22:08
its actually true
22:08
python is the fusion, very "sn[e]aky"
Avatar
Mh the call isn't inlined, nor is it reordered
Avatar
does the call do anything at all?
22:09
Maybe it's optimized away because the compiler thinks it does nothing anyway
Avatar
It looks like the whole function
Avatar
Now you're confusing me 😄
Avatar
@Jupstar ✪ btw re putting atomics into registers: https://rust.godbolt.org/z/5boWoq4zx
Avatar
yeah wow, for 2 lines of code
Avatar
well, it's going to be that way in larger examples, too
22:12
what kind of example would you like to see?
Avatar
It seems the call is done and the result is correct, but the compiler doesnt use the actual array. Unless I'm completely misreading this
Avatar
Avatar
heinrich5991
what kind of example would you like to see?
i want to know when exactly the compiler makes this assumption
22:13
under which assumption does it break it
Avatar
relaxed atomics have the same semantics as normal variables
22:13
it breaks under no assumption
22:13
on all cpu architectures that I know of
22:14
on optimization levels that optimize vector iterators to the same level as pointers
Avatar
Avatar
Learath2
It seems the call is done and the result is correct, but the compiler doesnt use the actual array. Unless I'm completely misreading this
well, that still fits with my strict aliasing theory though
22:14
for the rest of the function the optimizer decided it doesn't need the array because it was zero-initialized anyway and no one accessed it inbetween the read
22:15
so just put a constant 0 there
Avatar
@heinrich5991 what is x86-64-v2
Avatar
it makes some assumptions about the modernity of the x86-64 cpu
22:16
if you mean the target architecture
Avatar
Avatar
heinrich5991
on optimization levels that optimize vector iterators to the same level as pointers
e.g. if u read the var in a different thread, how would it optimize it then? relaxed atomics must be visible in finite time to the other thread normal variables not i mean there is a reason volatile is different to relaxed atomics i guess
Avatar
maybe a volatile variable could (in theory) never expose itself to the other thread
Avatar
ah, I see
22:20
@Jupstar ✪ here's a difference, indeed: https://rust.godbolt.org/z/a8x9P4Tr7
use std::sync::atomic; use std::sync::atomic::AtomicU64; pub fn add_one_atomic(a: &AtomicU64) { while a.load(atomic::Ordering::Relaxed) == 0 {} } pub fn add_one(a: &u64) { while *a == 0 {} }
22:21
so basically the compiler has to guarantee that it reloads the atomic at some point
22:21
but not the variable
Avatar
bad gateway lol
Avatar
works for me™
Avatar
a hard refresh fixed it
Avatar
Avatar
deen
well, that still fits with my strict aliasing theory though
if u find the c++ ref to this show pls when it comes to upcasting and downcasting and then even from array to pointer pointer it gets hard to search google for this xD
Avatar
Okay yeah this is UB
Avatar
Avatar
heinrich5991
because uint8_t is unsigned char, and char stuff is allowed to alias
This bug (and some linked discussions) indicate that compiler developers don’t necessarily consider int8_t and uint8_t to be character types for aliasing purposes.
From https://blog.regehr.org/archives/1307
22:34
Also, help:
A lot of C code is broken under strict aliasing. Separate compilation is probably what protects us from broader compiler exploitation of the brokenness, but it is a very poor kind of protection.
Maybe we should disable strict aliasing after all...
22:34
Makes sense that LTO exposes these problems then
Avatar
Ok I give up. This is way too confusing 😄
22:36
It should be fine. We are accessing through a type that is the base class of the dynamic type of the object. C++17 6.10p8.7
Avatar
We should fix all
Avatar
Avatar
Learath2
It should be fine. We are accessing through a type that is the base class of the dynamic type of the object. C++17 6.10p8.7
I wouldn't be so sure. We talk about arrays here
22:37
This is a completely different data type
Avatar
Should I just open a GCC bug and tell them their compiler is wrong? Probably easiest way to get a standard reference 😄
Avatar
Xdd
22:37
Good idea
Avatar
I heard they are very mean 😛
Avatar
Hm, they do have a warning when opening a compiler bug not to do so if it is aliasing related:
Before reporting that GCC compiles your code incorrectly, compile it with gcc -Wall -Wextra and see whether this shows anything wrong with your code. Similarly, if compiling with -fno-strict-aliasing -fwrapv makes a difference, your code probably is not correct.
Avatar
Use fake account xd
Avatar
Let me ask on the C++ irx
22:39
irc*
22:39
They have pedants on call 7/24
Avatar
Avatar
deen
Hm, they do have a warning when opening a compiler bug not to do so if it is aliasing related:
Before reporting that GCC compiles your code incorrectly, compile it with gcc -Wall -Wextra and see whether this shows anything wrong with your code. Similarly, if compiling with -fno-strict-aliasing -fwrapv makes a difference, your code probably is not correct.
I love the confidence
Avatar
Avatar
deen
Hm, they do have a warning when opening a compiler bug not to do so if it is aliasing related:
Before reporting that GCC compiles your code incorrectly, compile it with gcc -Wall -Wextra and see whether this shows anything wrong with your code. Similarly, if compiling with -fno-strict-aliasing -fwrapv makes a difference, your code probably is not correct.
Clang compiles it properly, no? Maybe a difference might pique their interest
Avatar
I bet they had factor 100 more false bug reports with strict aliasing compared to true bugs
Avatar
Avatar
Learath2
Clang compiles it properly, no? Maybe a difference might pique their interest
It probably has less insane optimizations
Avatar
Avatar
Learath2
Clang compiles it properly, no? Maybe a difference might pique their interest
yes, with Clang it's fine
Avatar
I'd trust GCC. Their binaries are still faster xd
22:40
The performance is everything rule never betrayed me (edited)
Avatar
you can access them from methods of the same class. if you want children to have access, make them protected, if you want everyone to have access make public or use a getter/setter method. If you want some specific functions/classes to access them, you can use friends
👀 1
Exported 516 message(s)