OmixVisualization / qtjambi

QtJambi is a wrapper for using Qt in Java.
http://www.qtjambi.io
Other
354 stars 40 forks source link

Use RTTI to identify dangling pointers #150

Closed omix closed 1 year ago

omix commented 1 year ago

Programming errors may lead to internal object deletions where it is not possible to unregister the Java counterpart which then remains linked to dangling pointer. Using this object will crash the application.

In case of polymorphic object types it is possible to provoke a catchable exception by typeid(*pointer) thrown when pointer points to deleted object. This native exception could then be thrown as Java exception.

The user should be able to switch on/off this feature.

omix commented 1 year ago

The behavior of typeid(*pointer) to throw an exception in case of dangling pointers is windows-msvc-specific. On unix-based systems a SIGSEGV is sent and the app crashes.

omix commented 1 year ago

Dangling pointer check on Linux/macOS works at least nearly as good as on Windows. Possibly it will detect less situations. It does definitely not work on aarch64.

omix commented 1 year ago

In case of dangling pointer, QtJambi will throw io.qt.QDanglingPointerException.