-
-
Notifications
You must be signed in to change notification settings - Fork 114
Description
I have been getting various assertion errors that look like this
java: ./imgui.h:1778: const T& ImVector<T>::operator[](int) const [with T = imnodes::{anonymous}::NodeData]: Assertion `i >= 0 && i < Size' failed.
The issue is, I'm not sure how to debug these errors. My application is getting kinda large so it's not 100% viable to put print statements everywhere (edit: though maybe breakpoints could work i honestly havent tried). I can't get other debugging features to work. Since the JVM freezes for a few seconds before closing when an assertion error happens, I'm not able to generate a thread dump afterwards, IntelliJ's debugger and VisualVM aren't able to retrieve any data from the JVM after an "assertion failed" error happens for the same reason.
I'm not 100% sure how it works, but wouldn't it be possible to throw a "ImException" when an assertion error happens? That would give a useful stacktrace. For example, how OpenCV does it:
OpenCV Error: Assertion failed (clEnqueueReadBuffer(q, (cl_mem)u->handle, CL_TRUE, 0, u->size, alignedPtr.getAlignedPtr(), 0, 0, 0) == CL_SUCCESS) in cv::ocl::OpenCLAllocator::map, file ..\..\..\..\opencv\modules\core\src\ocl.cpp, line 3961
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: ..\..\..\..\opencv\modules\core\src\ocl.cpp:3961: error: (-215) clEnqueueReadBuffer(q, (cl_mem)u->handle, CL_TRUE, 0, u->size, alignedPtr.getAlignedPtr(), 0, 0, 0) == CL_SUCCESS in function cv::ocl::OpenCLAllocator::map
]
at org.opencv.objdetect.CascadeClassifier.detectMultiScale_1(Native Method)
at org.opencv.objdetect.CascadeClassifier.detectMultiScale(CascadeClassifier.java:176)
at test.processor.detect(window.java:66)
at test.window.main(window.java:100)
It throws a Java exception with a useful stack trace when assertion errors happen, I'm not 100% sure if this would be a good and viable idea, neither how that works in the native side (haven't worked much with JNI) but if there is any possibility making it I'd look forward to it!