kr57
for making a project
Pavel
for making a project
You need to be more specific, also check out our OT group
Rose
Offtopic discussions should be done in the C/C++ Offtopic group. Please take your discussion/questions there.
Uzumaki
Hru
Cayetano
for making a project
I'm working on a project but is not commercial at all
Cayetano
If you wanna hear me... 😉
Cayetano
We can move to Offtopic group...
kr57
txt me
Cayetano
Ok, I will
The
Can anyone recommend a good place to look for SDL2 used in C, except for SDL2 wiki.
klimi
Can anyone recommend a good place to look for SDL2 used in C, except for SDL2 wiki.
maybe seeing some projects on github that use this SDL2?
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?
Ludovic 'Archivist'
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?
You need to be very strict and keep track of who owns the memory (and hence needs to clear it) which is a habit to get. Document your functions and make it explicit who is supposed to clear memory, and if it is passed as a form of reference or if it is passed as the actual ownership of the memory
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
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?
Abbasi
Can you guys share what are your steps when you encounter segmentation faults in large codebase?
- isolate the problem - use a debugger - use print messages - use compiler flags to help with more details A segmentation fault is typically related to accessing a memory address which is disallowed.
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
Might be possible, but gonna take too much time and effort
Abbasi
Might be possible, but gonna take too much time and effort
The set was mainly a general idea. It can be too hard in a large codebase to find such a bug. The first handy step might be to isolate the area containing the issue.
Ludovic 'Archivist'
Can you guys share what are your steps when you encounter segmentation faults in large codebase?
Mostly debugger, unless there is stack corruption, then valgrind and an unhealthy amount of coffee to wait for the application to reach the problem
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
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'
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'
actually, isn't a bad thing to have many many mutexes around? is it only bad if i'm using all of them?
It is only bad if you lock them in random order and/or if you expect to fail locking more than to succeed (high contention)
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
Are you there ?
no, we here
Vlad
Are you there ?
No, Sarah, in fact, I were not there.
Vlad
All those allegations are false
Ludovic 'Archivist'
are you smartest?
Vlad is, in facts, not
Vlad
are you smartest?
I'm a proud dum-dum
aaswq1
Vlad is, in facts, not
yeah, this dumb asshole think he can joking here
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
harmony5 🇺🇳 ⌤
Ig this may be the ot group as well…
Vlad
Ig this may be the ot group as well…
In the absence of actual C++ questions the chat yearns for content
Vlad
I guess I should start asking total dumb fuck questions here and stir up the water
Roxifλsz 🇱🇹
rastn
Aha
🇱🇹🇱🇹🇱🇹
rastn
i akropoli dabar vaziuju seni
Roxifλsz 🇱🇹
i akropoli dabar vaziuju seni
Prikolas, aš tai tik nesenai atsikėliau :D Reik eit mašinos tvarkyt
Vlad
The resident provocateur eh
Bro caught the french virus
Roxifλsz 🇱🇹
Bro caught the french virus
Le not really, anyway I'm gonna go get my le breakfast cigarette and le coffee
Vlad
I don't le care
No le baguette for thee mister
Roxifλsz 🇱🇹
Rose
/warn non-english
I'm not going to warn an admin!
Roxifλsz 🇱🇹
/warn non-english
/ban I love admin abuse
Rose
/ban I love admin abuse
Why would I ban an admin? That sounds like a pretty dumb idea.
rastn
/warn non-english
kill urself g
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
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