3 ms·
That reminds me of the time I debugged some code (also neural network) that was in both Java and C++ and I was able to attach both gdb and jdb to the same proce
by PaulHoule 4y ago
That reminds me of the time I debugged some code (also neural network) that was in both Java and C++ and I was able to attach both gdb and jdb to the same process but had to disable the segfault trap on gdb because the jvm segfaults all the time in normal operation.
- kelahcim 4y agoWhich reminds me that with IntelliJ you can get a really nice combo for debugging Java/C/C++ code: https://youtu.be/8Cjeq4l5COU https://youtu.be/8Cjeq4l5COU
- MereInterest 4y agoAs a C++ developer, I'm struggling to understand how and why segfaults would ever be part of normal operation. In my mental model, the presence of a segfault means that a program has gone so far off the expected path that no guarantees can be made about its state whatsoever, so the only safe thing to do is to let the program crash. Is there a reason why the JVM regularly segfaults?
- aa-jv 4y agoA pretty good investigation into this matter - "segfaults in Java (redux)": https://www.lukeshu.com/blog/java-segfault-redux.html https://www.lukeshu.com/blog/java-segfault-redux.html Read the prior article for some context, too ..
- planede 4y agoSegfaults are unexpected and shouldn't happen in a conforming C++ program that doesn't evaluate operations with undefined behavior. But in non-portable C or C++ program doing manual memory management with OS primitives targeting a specific OS the conditions for segfault are well documented, and you can also rely on the programs behavior when that happens (the OS raises a signal for you, that you can handle). There are not many programs that should be written this way, but I assume the JVM might fall into this category. I'm still not sure if handling page faults this way in regular operation is the best strategy, but I would worry about performance more than correctness.
- PaulHoule 4y agoI think Java catches the segfault and throws a NullPointerException or something like that.