<kazinsal>
comedy option: some insane 8086 calling convention that specifies only near pointers but never specifies that ds == es
<kazinsal>
in which memcpy(0x1000, 0x1000, 16) may not actually do what you expect
<geist>
the above routine seems to be in many cases compiled to a call through to memcpy, so the compiler must also interpret copying two objects via pointers as being UB if they happen to be the same pointer
<geist>
i always thought i remember something like if you write your own operator= you must check for the same object and skip it, but then maybe hta'ts just a good idea?
<geist>
yah you're supposed to guard for self assignment in the operator= operator
<geist>
hmm, maybe that's because operator= is an assignment operator against an existing thing, and can't be a standalone operator
valshaped has quit [Ping timeout: 250 seconds]
<geist>
ah i see, it's not *required* that you do the self test in the assignment operator, it's just expected if there is bad behavior
<bslsk05>
github.com: CppCoreGuidelines/CppCoreGuidelines.md at master · isocpp/CppCoreGuidelines · GitHub
<geist>
so that's still odd, the compiler for simple structures will just call through to memcpy in the default assignment operator *without* a self test
valshaped has joined #osdev
<geist>
hmm fiddling with godbolt i think it has something to do with trivial POD types vs something more complicated
<mrvn>
geist: it's expected that memcpy to the same pointer has no bad effect.
<sham1>
"I like trains" might just be my favourite answer for a question about UB
<mrvn>
you don't like pregnant kittens?
<geist>
mrvn: expected, but it's specced as UB
<geist>
i totally agree that it's expected, and thus a memcpy implementation can simply skip the copy if it wanted to
<geist>
so i think it's some sort of odd case where the spec and reality dont exactly line up, but it seems that what you say is reality
bgs has quit [Remote host closed the connection]
<sham1>
Well in reality it is the most reasonable thing to have it do
<sham1>
But if one wants guarantees they use memmove
<klange>
In the naive case that the overlapping-areas thing is intended to address, equivalent source and destination should not suffer any ill outcome anyway
<geist>
right. what was faking me out is the fact that the compiler actually sometimes emits calls to memcpy in cases where it expects the compile to either go through or not copy
<sham1>
Well the compiler knows it to not be UB and thus emits the call
<geist>
well, except that memcpy is *specced* to be UB if it overlaps
<geist>
seems like it should be calling through to memmove if nothing else
x8dcc has quit [Remote host closed the connection]
<sham1>
The compiler ought to be conservative and only emit memcpy when it can prove that they don't overlap
<geist>
but yeah, from quickly searchig around for different memcpy implementations (musl, glibc, etc) none of them seem to test for dst==src
<sham1>
Whether that happens is a different matter
<geist>
sham1: exactly, that's what i was surprised to see
<geist>
various amounts of size changing the compiler(s) will switch to manual copying instead of a memcpy call through, but in the manual case they also dont check for overlap
<geist>
anyway, horse beaten dead, just a thought because i'm writing a new memcpy implementation for work and i'm sure the libc gods will strike me down
<geist>
so i need to make sure i got all my ducks in a row
<mjg>
these fucking string ops feel like leetcode exercises for me now
<mjg>
fucking bullshit nobody should have to do
<mjg>
testing if dst == src is crap, the condition almost never is true
<mjg>
i did see a memcpy doing it tho
<mjg>
in bionic
Halofreak1990 has quit [Ping timeout: 246 seconds]
<geist>
mjg: need one for riscv in asm
<mjg>
are you even optimizng it
<mjg>
this one does look like a candidate to generate with automemcpy and call it a day
<bslsk05>
yetzt/null-island - A design reflection about the representation of missing values. (0 forks/40 stargazers/CC0-1.0)
eroux has quit [Read error: Connection reset by peer]
GeDaMo has quit [Quit: That's it, you people have stood in my way long enough! I'm going to clown college!]
eroux has joined #osdev
eroux has quit [Read error: Connection reset by peer]
linear_cannon has joined #osdev
eroux has joined #osdev
dude12312414 has quit [Quit: THE RAM IS TOO DAMN HIGH]
dude12312414 has joined #osdev
dude12312414 has quit [Remote host closed the connection]
heat_ has quit [Remote host closed the connection]
heat_ has joined #osdev
* sham1
reflects on trusting trust
<zid`>
just trust me
<zid`>
I will tell you who to trust from there
<zid`>
easy
frkazoid333 has joined #osdev
sebonirc has quit [Remote host closed the connection]
sebonirc has joined #osdev
* kof123
casts wall on sham1, bouncing off back to himself
<heat_>
my OS seems to die when booting the 43rd CPU :/
<zid`>
rude
<heat_>
it is
<mjg>
it glances at your shitlocks
<mjg>
then the srat table
<zid`>
have you considered not having a 96 byte per-cpu struct
<mjg>
then at your shitlocks
<mjg>
and decides fuck it, i'm out
<heat_>
zid`, i have larger pcpu data than that
<mjg>
per computer data amiright
<zid`>
multiply it by an integer then
<heat_>
mjg, your mom's a shitlock
<zid`>
43*96 = 1 page
<heat_>
no, it has nothing to do with that. it's trying a TLB shootdown for KASAN data and waiting endlessly for a CPU that never looks at it
heat_ is now known as heat
<zid`>
have you considered not having cpus
<sham1>
Just don't computer
<gog>
i don't
<zid`>
where would someone even get 43 cpus, mafia?
<heat>
amd
<heat>
or in my case, -smp
<zid`>
I know you could *pay* for 43 cpus
<zid`>
but who has the 40 or so million dollars that would cost
<zid`>
and the warehouse to put them in
<zid`>
I dread to think the electricity cost too
slidercrank has quit [Quit: Why not ask me about Sevastopol's safety protocols?]
<heat>
hehehe
<heat>
found the bug. i was setting the CPU online from the waking processor, which could hang if inside vmalloc I tried to shootdown an AP *while it was initializing*, because the AP init process also requires memory allocation (and runs with irqs off)
epony has joined #osdev
<mjg>
kernel startup is fraught with peril
<mjg>
personally i like vm init requiring memory to be allocated
<heat>
my page allocator has a page allocator :)
<heat>
i have a bootmem page allocator, THE page allocator, virtual memory allocator (vmalloc), slab allocator, and a small memory pool allocator
<heat>
its gr8
<mjg>
it's allocators all the way down innit
<heat>
oh and *the* actual virtual memory allocator for all matters userspace too
<heat>
absolutely
Turn_Left has joined #osdev
Turn_Left has quit [Max SendQ exceeded]
Turn_Left has joined #osdev
Left_Turn has quit [Ping timeout: 264 seconds]
Turn_Left has quit [Max SendQ exceeded]
Turn_Left has joined #osdev
danilogondolfo has quit [Remote host closed the connection]
<Halofreak1990>
for me, any memory my AP init process requires is allocated by the BSP beforehand, and the APs really only have to load their various descriptors before dropping into the idle loop, waiting for stuff to be scheduled on them
<heat>
yes, that's usually the case for me, except where it isn't
nyah has quit [Quit: leaving]
theboringkid has joined #osdev
theboringkid has quit [Client Quit]
[itchyjunk] has joined #osdev
CalculusCats is now known as Calculuscat
Calculuscat is now known as CalculusCat
sleider has joined #osdev
epony is now known as Guest3663
Guest3663 is now known as epony
Turn_Left has quit [Read error: Connection reset by peer]