kr57
for making a project
Rose
Offtopic discussions should be done in the C/C++ Offtopic group. Please take your discussion/questions there.
Uzumaki
Hru
Cayetano
If you wanna hear me... 😉
Cayetano
We can move to Offtopic group...
kr57
kr57
txt me
Cayetano
Ok, I will
Null
The
Can anyone recommend a good place to look for SDL2 used in C, except for SDL2 wiki.
klimi
Uzma
Been diving into C lately trying to wrap my head around pointers and memory handling. It makes sense in theory, but writing actual code trips me up.
Anyone else struggled with this early on? What helped it finally click?
Antonio
Ludovic 'Archivist'
My recommendation is to start from an object oriented view, with a function to prepare memory for use, and a function to dispose of the typed memory, and to work towards structuring your memory usage
Vlad
Cayetano
@kr_1357 @gameraccoon
Whoops, sorry guys. I totally crashed at my desk last night and today has been hectic. Jumping over to OffTopic to fill you in on the project.
Rose
Reported Leyla [1076958512] to admins.
~
Can you guys share what are your steps when you encounter segmentation faults in large codebase?
Pavel
Can you guys share what are your steps when you encounter segmentation faults in large codebase?
If it is reproduced on a client machine, then we usually would have crash reporting (like Sentry), that would send us a crash dump (stack trace + a bit of values from memory/registers), and it would also symbolize it (tl;dr make them human-readable).
I would then start from analyzing it to figure out if I can make sense of it just from that.
Then if it is reported by the user or QA, they may have included information about repro steps and repro rate (usually QA would always try to repro the bugs coming from users if they get any hints of how it can be reproduced).
Then if that alone didn't give enough info already I would try to add logs and reproduce it myself, to see more info from the callstack of the crash as well. Then I will try to use this info, add more logs, and debug to get to the bottom of it if I can.
If nothing helps, and if the repro rate is 100% and the repro steps are simple, one could also do git bisect (or manually doing that in other VCS) to find the first commit that introduced it, and use that info to aid the investigation.
Vlad
Vlad
Might be possible, but gonna take too much time and effort
Dero
Hi guys, i need to implement a doubly linked list that is optimized for high-concurrency environments. I am thinking about how to attack this problem, maybe doing it lockfree is not worth it but having a mutex for each node probably it's not the best either. To remove a node i need to acquire the mutex of 3 nodes in the worst case (prev, current, next)
any ideas?
Cayetano
Cayetano
And you can treat each node as a state machine. In the way, the state will determine if you'll need a semaphore or another tool
Dero
Can you elaborate on that? what do you mean by "depending on the situation?"
Cayetano
Depending if the user wants to add, insert, move, update, delete or whatever a node
Ludovic 'Archivist'
Ludovic 'Archivist'
Those will do the job of mutex in write mode, but allow traversal in read mode
Ludovic 'Archivist'
Note that you need to be able to hold several locks at once deterministically in a way that never deadlocks
Ludovic 'Archivist'
Your nodes will also need to be reference counted atomically. My advice is that when you need to do an operation, hold the nodes and lock them in increasing sequence only, keep reference to nodes and verify once locked that the state is the expected one, if it is not, unlock and reject the operation (it will need to be tried again)
Dero
So you think it's fine to basically have one RW mutex per node
Dero
actually, isn't a bad thing to have many many mutexes around? is it only bad if i'm using all of them?
Ludovic 'Archivist'
Failing to lock a mutex is very expensive, locking successfully is not. So if you fail to lock in write mode but you were locking in progressive order consistently, you will never fail more than once but your failures will be deterministic and the ordering will prevent any deadlock by design as you will always have an acyclic graph of locking dependencies
Ludovic 'Archivist'
If your operations on the list are strictly bounded in time and if that bound of time is short enough, I would actually not recommend a futex but an RW spin lock since deadlocking is impossible and livelocking is extremely unlikely of the ordered semantics are respected
Ludovic 'Archivist'
For more information on locking in general look at Malte Skarupke's blog
This article is on high contention locks (using a single lock a lot) : https://probablydance.com/2019/12/30/measuring-mutexes-spinlocks-and-how-bad-the-linux-scheduler-really-is/
This one is on a low contention system (few people trying to lock each lock) https://probablydance.com/2022/12/05/fine-grained-locking-with-two-bit-mutexes/
Sarah
Are you there ?
aaswq1
Vlad
All those allegations are false
aaswq1
Vlad
aaswq1
Easy there, fellow churka
listen piece of you know what
If you say something wrong to me again, I'll tell Alfredo and he will decide what to do with you
Vlad
aaswq1
harmony5 🇺🇳 ⌤
Ig this may be the ot group as well…
Vlad
I guess I should start asking total dumb fuck questions here and stir up the water
Roxifλsz 🇱🇹
rastn
Roxifλsz 🇱🇹
rastn
rastn
i akropoli dabar vaziuju seni
rastn
Vlad
Roxifλsz 🇱🇹
Roxifλsz 🇱🇹
klimi
rastn
Ludovic 'Archivist'
#WARNACTION:
Chat: C/C++ Programming
Admin: Ludovic 'Archivist' Lagouardette (ID: 419914295)
User: rastn (ID: 7768945254)
Message link: link
Reason: thinking harassing admin is a good idea
klimi
Ludovic 'Archivist'
Ludovic 'Archivist'
Hey dear group members, this is a C++ interview style book, here you can enhance your knowledge
in C++ and software engineering mainly focused and has relation with C++.
In general this book is not for starters, it could be overkill, more this is for mid/sr level engineers,
starters can got familiar with language concepts.
Enjoy !!
Ludovic 'Archivist'
Note: Anton is the one that published the book