many
Which one is your style? Spaces or tabs? 2 spaces or 4 spaces? I'm forced to use 2 spaces but come on I just can't read the code with indentation of 2 spaces
Nils
you should use atomic variable for loginStatus. and why do you use Heap? it is just single char
I somehow have to pass it into a lambda that runs in another thread.
Alex
also you use LoginStatus in another thread, but you already delete it
Nils
can you use a copy in lambda?
No, because I want the main thread to wait for the change
many
4 spaces is the way.
Do old programmers prefer 2 spaces?
Alex
No, because I want the main thread to wait for the change
you should use this one http://www.cplusplus.com/reference/condition_variable/condition_variable/wait/
Nils
thx
Asdew
Do old programmers prefer 2 spaces?
That would be a stupid generalization to make.
many
Then why do some people prefer two spaces?
Asdew
Please contact me in DMs.
Nils
delete reinterpret_cast<void*>(1); this should always segfault, right?
Nils
not always, but this is odd code
Just trying to find some way to cause a segfault reliably
Anonymous
Hi, is this valid: char *loginStatus = reinterpret_cast<char*>(malloc(sizeof(char))); ?
sizeof(char) evaluates to 1 by definition. No need to write that out
Alex
Just trying to find some way to cause a segfault reliably
get address of the function and try write to it. however it depends on platform
Alex
try to write to NULL address
Nils
solved, thx
Nils
But, does crashing one thread crash the entire process?
Alex
this is guaranteed I suppose
Dima
Please contact me in DMs.
what the hell is happening
Asdew
I thought I DMed you?
Nils
Just got this weird message 🤔
Dima
/ban @Nani_999
Nils
Thx
Anonymous
Just got this weird message 🤔
Probably clicked on stupid link and logged in with telegram. There was a guy who posted here too.
Nils
Interesting 🤔
Nils
Ouch
Nils
Can I somehow see weather a specific scope was ever entered? Seems like I can't use stdout and such
Dima
that sounds like impossible
Dima
how come one bot could access your contacts
Dima
imagine clicking on stranger’s link
Dima
Asdew
It's a real Telegram bot, just a scam.
Asdew
It's even marked by Telegram as a scam.
Rohit
Actually i am just a beginner . So want to know how to learn from the beginning.
PO
Hi
PO
who can tell me how can I replace each second and third element of 2d array with zero?
Nils
But isn't it just one byte?
Nils
I mean a data race can't happen with just one byte?
Alex
I mean a data race can't happen with just one byte?
can, because of compiler/cpu optimization. cpu has cache and it changes order of instructions
Nils
Should I use that "atomic chat"?
Nils
Oh I thought some compiler thingy 😅
Alex
How can I disable that cache?
in BIOS. but it would not help. and CPU will work slower
Nils
but yeah makes sense…
Nils
oh, atomic<char>
Nils
What does atomic mean?
Nils
Also can I try if it is the CPU cache by making it somehow flush into memory?
Nils
"well" defined? Doesn't sound like it can still be undefined behavior?
Nils
ah, thx
Nils
auto* loginStatus = new std::atomic<char>(0); Okay?
Nils
Yes
Nils
but it's a pointer?
Nils
I mean new returns a pointer right?
Nils
Ah, okay.
Nils
Well… It's still deadlocking 😢
Anonymous
int *a = new int[10]; int *b = a +100; Does have UB?
Nils
https://hastebin.com/jurovohuzo.cpp
Nils
but it's a pointer
Nils
np
Nils
How can I check if a thread was ever started?
Nils
I am not, that's why I am asking how to verify that
Nils
Can I log to clog?
Nils
Can I log to clog?
Or will that never be visible?
Nils
What happens when such a thread segfaults?
Nils
Does that mean yes to my question?
Nils
or does that mean yes that's alright?
Nils
thx
Nils
alright…
Nils
turns out it's never executed
Nils
I think so…