





Except the C++ βCore dumpedβ line is telling you it just wrote a file out with the full state of the program at the time of the crash, you can load it up and see where it crashed and then go and look at what every local variable was at the time of the crash.
Pretty sure you can even step backwards in time with a good debugger to find out exactly how you got to the state youβre currently in.
Where does it write the file
Nobody knows
deleted by creator
On a secret FBI server somewhere where they watch your failures and laugh
deleted by creator
I believe itβs /var/lib/apport/coredump on Ubuntu.
imagine if it, like, told you this so you didnβt have to find out about it via a post on lemmy
imagine if it like, read that file and gave you a stack trace
gdb gives you waaaaaaaaaaaaaaay more than a stack trace.
β¦unless you build the executable with optimizations that remove the stack frame. Good luck debugging that sucker!
I love gdb! I recently had to do a debug and wow its so cool! On gentoo I can compile everything with symbols and source and can do a complete stack trace.
Am I the only one in this thread who uses VSCode + GDB together? The inspection panes and ability to breakpoint and hover over variables to drill down in them is just great, seems like everyone should set up their own c_cpp_properties.json && tasks.json files and give it a try.
i mean youβre expected to know the basic functioning of the compiler when you use it
Imagine if you knew the most basic foundational features of the language you were using.
Next weβll teach you about this neat thing called the compiler.
Iβm not a C/C++ dev, but isnβt apport Ubuntuβs crash reporter? Why would dumps be going into there?
Though on a rhetorical thought, I am aware of systemdβs coredumptctl so perhaps its collecting dumps the same way systemd does.
https://wiki.ubuntu.com/Apport
It intentionally acts as an intercept for such things, so that core dumps can be nicely packaged up and sent to maintainers in a GUI-friendly way so maintainers can get valuable debugging information even from non-tech-savvy users. If youβre running something on the terminal, it wonβt be intercepted and the core dump will be put in the working directory of the binary, but if you executed it through the GUI it will.
Assuming, of course, you turn crash interception on- itβs off by default since it might contain sensitive info. Apport itself is always on and running to handle Ubuntu errors, but the crash interception needs enabled.
Ah I see, thatβs actually pretty cool - thanks!
tl;dw: writes to the path in /proc/sys/kernel/core_pattern
If you are using systemd, thereβs a tool called coredumpctl.
letβs not act like Javaβs error log is useful
deleted by creator
Super-advanced java devs like me do it like try{} catch (Exception e) { System.out.println("something went wrong"); e.printStackTrace(); }
deleted by creator
On Error Resume Next never before have more terrible words been spoken.
On Error Resume Nextnever before have more terrible words been spoken.
Every time Iβm reading a PowerShell script at work and see -ErrorAction SilentlyContinue I want to scream into a pillow and forcefully revert their commit.
Iβve actually done it a few times, but I want to do it every time.
And thatβs why youβre a hero.
Yeah cos everyone knows other languages are impossible to write bad code with
you can follow any exception down to the exact line of code
Which is usually not a piece of code written by us and is caused by another piece of code not written by us either
Does your IDE not highlight the lines written by you in a different colour? Of course that doesnβt help when itβs an error in production!
Is it possible to make intelliJ do this?
I thought it highlighted the line number in blue when it was your code. I use eclipse so canβt properly remember
deleted by creator
but you can follow any exception down to the exact line of code (or JNI call, I guess) where the problem occurs.
But, itβs not really where the problem occurred. How often do you get a stack trace and the bug fix is at the line referenced by the stack trace? Almost never. Itβs more that it takes you down to the exact line of code where the effects of the problem are bad enough to affect the running of the program. But, the actual problem happened earlier, sometimes much earlier.
For example, NullPointerException isnβt actually the problem, itβs a symptom of the problem. Something didnβt get initialized properly, and nobody noticed for a while, until we tried to use it, and got a null pointer. Sometimes itβs easy to go from the effect (null pointer) to the cause (uninitialized thing). But, other times that βthingβ was passed in, so you have to work backwards to try to figure out where that thing comes from, and why itβs in that broken state.
Sure, itβs better than nothing, but itβs still frustrating.
deleted by creator
I think itβs pretty useful, be interested to hear your hangups with it though because itβs definitely not perfect.
If something goes wrong and I have a stack trace, that plus the type of exception will almost always be enough for me to figure out whatβs wrong at least as a starting point. Iβve worked mostly with JVM languages in my career though so maybe I just donβt know how bad it actually is.
Itβs not bad. Itβs better than what most languages give you
The same applies to using the core dump.
In fact, the Python one is the lest useful of the trio.
When the day comes that you need gdb you will indeed be amazed at how fucking powerful it is. If your server crashes grab that core dump!
Itβs extraordinarily useful
Implying you canβt consistently go to the same line every time and it always has what you need.
My favorite compile error happened while I was taking a Haskell class.
ghc: panic! (the βimpossibleβ happened)
The issue is plainly stated, and it provides clear next steps to the developer.
I had a similar error, though not from the compiler
Error message just read this should never happen
Ah, good old PlarformIO
Python: So you used spaces and tabs for indentation? NOW DIE!
Mixing spaces and tabs should be a warcrime.
And in Python, itβs merely a SyntaxCrime.
Find me anyone who claims they use tabs for indentation, and I bet Iβll find at least one case where theyβre using both tabs and spaces.
The only safe way to avoid war crimes is to avoid tabs.
Why would I use spaces if I use tabs? Also, it seemd like a huge waste of time hitting the space bar so many timesβ¦
Why would I use spaces if I use tabs?
To comply with Pythonβs best practices:
https://peps.python.org/pep-0008/
Also, if you work on the Linux Kernel, youβll see a mix of tabs and spaces:
https://elixir.bootlin.com/linux/latest/source/block/bfq-iosched.c#L390
Also, it seemd like a huge waste of time hitting the space bar so many timesβ¦
You use an editor that doesnβt auto-indent?
Removed by mod
I use vi without syntax highlighting.
Removed by mod
deleted by creator
I use the tab key but Iβm pretty sure vs code converts that to spaces
Depends on your settings, but yeah typically it does
It worries me that a programmer wouldnβt know for sure whatβs happening when they hit tab, and that itβs a setting that can be changed.
I mean I was 99% sure it convert to spaces, I cannot say I was certain. The default settings are fine for what I do, I only ever had to change the spacing from 4 to 2 spaces once when dealing with someone elseβs files
Donβt IDEs just replace any tab with 4 spaces anyways? Pretty sure VSCode does
IΒ Β Β Β donβtΒ Β Β Β useΒ Β Β Β anΒ Β Β Β ide,Β Β Β Β butΒ Β Β Β IΒ Β Β Β wroteΒ Β Β Β aΒ Β Β Β scriptΒ Β Β Β thatΒ Β Β Β replacesΒ Β Β Β anyΒ Β Β Β spaceΒ Β Β Β IΒ Β Β Β typeΒ Β Β Β withΒ Β Β Β four.
IΒ Β Β Β havenβtΒ Β Β Β workedΒ Β Β Β outΒ Β Β Β allΒ Β Β Β theΒ Β Β Β useΒ Β Β Β casesΒ Β Β Β yet,Β Β Β Β though.
Thatβs a setting in the editor.
Linux kernel?
https://www.kernel.org/doc/html/v4.10/process/coding-style.html#indentation
edit: oh python, nevermind
The kernel definitely mixes tabs and spaces:
https://elixir.bootlin.com/linux/latest/source/block/bfq-iosched.c#L390
Good. Spaces and tabs for indentation should never be mixed in any language other than Whitespace.
Some people use tabs for indentation and spaces for alignment. It kind of gets the pros of tabs (user configurable indent-width) and the pros of spaces (alignment). That doesnβt work in Python where you canβt align stuff and the interpreter doesnβt allow mixing tabs with spaces, but in other languages it is a possible style.
There are no pros to tabs. Configure tabs to a number of spaces.
Raw adjust with tabs, fine adjust with spaces.
Donβt laugh, people are actually doing that.
Mixing tabs and white spaces in 2024 is categorically a you problem lmao
Are you ok?
Rust developer: Iβd like to compile some code
Rust compiler: the fuck you are
The rust compiler holds your hand, wraps you in blankets, makes you hot chocolate, kisses you on the forehead before it gently and politely points out what you did wrong and how you can solve it step-by-step. It would never think of something as heinous as swearing at you, shame on you for insulting my wifeβs honour like this.
Rust compiler is passive agressive, like:
βThereβs an error at line 286 because you still donβt know how to use the borrow checker after all this time β₯οΈβ
its a compiler. That is at best projection, especially considering how the compilerβs error feedback is designed to be firm yet gentle.
I need a rust compiler in my life π
Damn right. And once it compiles⦠it works.
Meet my friend: .unwrap()
Fair.
except when it gives errors about lifetimes of some object.
boy, that makes my brain hurt
The rust compiler produces a flawless understanding of your code, and then quits out because understanding that code is a Nightly-only feature and youβre using the stable build.
deleted by creator
gdb: Am I a joke to you?
Yes. Itβs a surprisingly bad debugger the more you think about it. I use it largely in assembly and it loves to spit out random errors about memory it tried to access based on the current register state. The shortcuts are kind of dumb.
It certainly works but I wouldnβt call it a pleasure to use.
Ex: try disp x/1i $eip often just doesnβt work.
I use gdb with great success for x64, rv64, and c:
info registers rip or just setup tui:
# ~/.config/gdb/gdbinit:
tui new-layout default regs 1 {-horizontal src 1 asm 1} 2 status 0 cmd 1
tui layout default
tui enable
I honestly vastly prefer using IDA and Windows specific tools (x64dbg) over gdb. IDA can interface with gdb so it can act as a frontend which can be handy for visualization.
Embedded C entered the chat
Your loop had a race condition, so we let the smoke out for you.
Canβt believe that my code is racist smh
Ho hoo, that isnβt smoke, itβs steam, from the steamed rams weβre having! Mmm, steamed rams.
// I am responsible for every byte of this code and still don't know why this line breaks everything.

https://www.youtube.com/@TsodingDaily
If youβre a programmer, or think you might want to be one, I highly recommend this channel. Heβs a savant at all sorts of low level things, quite funny and entertaining, and does a fantastic job of explaining whatβs going on.
Good gods, a long-form content creator! Will be checking this out later
tsodingβs channel is one I look forward to watching every single day, never a dull moment in his streams/videos.
If youβre someone who likes to watch things live, his Twitch channel is available here.
heβs russian tho
The guy is testing the result of malloc and you are complaining about how?
Imagine unironically praising Java.
The one thing I can say about java; the kinds of people who like Java tend to really like Java. Everyone else just leaves them to it.
And the people hating on it somehow never used any version above 8, which is 10 years old and EOL.
Same could be said about PHP
Having used PHP and Java extensively in my career, itβs always entertaining to read what people think about these languages.
I havenβt touched PHP since college, so about a decade, but back then I compared it to a very disorganized but well equipped toolbox. Everything you need to do your projects is there, but itβs scattered through 12 different unorganized drawers and cubbies, thereβs an annoying mix of metric and imperial stuff, plus some random bits and bobs you inherited from your grandfather that you have no idea what they do.
Oh Iβm firmly in the second camp. They can use whatever version they like, as long as I donβt have to go near it.
Iβve used Java 21 pretty extensively, and itβs still comically bad compared to various alternatives, even apples-to-apples alternatives like C#. The only reason to use Java is that youβve already been using Java.
itβs still comically bad compared to various alternatives, even apples-to-apples alternatives like C#.
Iβd be interested to hear why. IMO Java has the superior ecosystem, runtime(s!), and community. The best part is that you donβt even HAVE to use java to access all this - you can just use kotlin, groovy, scala,β¦ instead.
In terms of the language itself, while it (still) lacks some more modern language features, it has improved massively in that area as well, and theyβre improving at a significant rate still. It also suffers from similar issues as PHP, where it has some old APIs that they donβt want to get rid of (yet?), but overall itβs a solid language.
Java is a traditional and conservative language, which has its strong upsides, like the syntax being familiar to many people who havenβt used the language before. Itβs a language that brought us the JVM, gave a job to many people and established fundamentals for other languages to inspire and improve on. If you donβt like Java, you can just use another language for the JVM, like Scala, Kotlin or Clojure.
and inspired C#, which is pretty rad! (humble opinionβ¦ preparing for downvotes because I donβt get the feeling lemmy is where M$ devs hang out)
Only a fool could miss the value C# has when used to solve the proper problems :)
Totally! Thanks π
You only named one upside, I canβt think of any other, and C-like syntax is pretty common, so itβs not much of an upside. Itβs at least debatable whether the JVM is a good thing at all - the majority of languages get along perfectly well without it, and thereβs no reason to believe the ones that do target it wouldnβt be doing just fine if it didnβt exist. Itβs weird to say Java gave a job to anybody - the demand to have software written resulted in programmers being hired; if Java hadnβt been pushed on the market by Sun, it would have just been another language. Java didnβt establish any fundamentals at all, it just borrowed from other places. While all three of the other languages you mention are interesting, for sure, Iβm not sure why somebody who doesnβt like Java should limit themselves to JVM languages.
Java is good. Supporting Java legacy is bad
Java good
Opinion bad
All the ideas are good.
Only the ideas are good.
Java: Not all poo poo.
Java is awesome. There ya go
Oh yes, letβs pick on the weak programming languages because haha funi
This C++ message has an urgency vibes to it:
βSegmentation fault!! Drop the Nuclear Reactor quick!!β
Average C++ error

gdb ./fuck
r
where
you should get a complete stack trace (complete with values of some function arguments)
No bounds checking, only fast.
There is bounds checking, but itβs opt-in. I often enable it on debug builds.
This right here - C++ iirc is used mostly for microprocessor code in an industry setting, where EXTENSIVE testing is done so that bloated code doesnβt need to constantly check for programmer errors every single time, i.e. where execution speed is prioritized over programmer development time. And whenever that is not the case, well, as OP pointed out, other higher-level languages also exist (implication: to choose from).
C++ iirc is used mostly for microprocessor code
lol no, itβs used almost everywhere where performance is important and people want(ed) OOP, from tiny projects to web browsers (Chrome, Firefox) to game engines (Unreal, CryEngine). Many of these are hugely complex and do encounter segfaults on a somewhat frequent basis.
Saying C++ is mostly used for embedded applications is like saying C# is mostly used for scripting games, i.e. it doesnβt nearly cover all the use cases.
higher-level languages also exist
This depends on your definition of βhigher-levelβ, but many people would argue that C++ is on a similar level to Java or C# in terms of abstraction. The latter two do, however, have a garbage collector, which vastly simplifies memory management for the programmer(generally anyway).
deleted by creator
Lots of those in C# now, especially with Unity coming along like it did.
I also currently use it for a new project since all needed 3rd party libraries are from a very specific domain and the project has a deadline, so writing and testing wrappers for Rust that would provide me with any meaningful advantages down the road are too costly to budget for before the deadline.
That could become part of a future refactoring, though.
Nevermind that the C++ program is two orders of magnitude faster when completed.
I would love to learn and use Rust but Iβm a embedded systems guy. Everything of consequence is C and C++.
If the embedded system is old or poorly-maintained enough, there might be more Rust than youβd think.
Thereβs embedded rust for a few platforms. Using it on ESPs is fun
Rust seems pretty performant
https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust-gpp.html
I meant faster than Python, not faster than Rust. Rust is fast.
Ah. OK. Makes more sense.
Joke on you until the python program segfaults
If it does itβs because of C/C++ code
The developer must either provide the logging and attach a debugger or go get fucked when a runtime error happens
Thatβs not true though. You can get the backtrace and other useful information from the coredump mentioned by the error message by loading it with gdb. Not as good as attaching it to a living process, since you canβt see step-by-step what happens leading up to the error, but still quite useful.
Well yes, thatβs a pretty good way of debugging a third party app but if you are developing something you can have more ease with gdb attached
are you c++?
You can also debug post-mortem with the minidump or the core dump file with WDT on Windows. Great fun and a good way to brush up on your assembly skills
Great fun and a good way to brush up on your assembly skills
Just load it on the debugger and leave your asm skill gather patina.