Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async callbacks throw error #103

Closed
sowelipililimute opened this issue Jun 2, 2024 · 6 comments
Closed

Async callbacks throw error #103

sowelipililimute opened this issue Jun 2, 2024 · 6 comments

Comments

@sowelipililimute
Copy link

[error] java.lang.NullPointerException: Cannot invoke "java.lang.ref.WeakReference.get()" because "proxy" is null
[error]         at io.github.jwharm.javagi.gobject.InstanceCache.handleToggleNotify(InstanceCache.java:331)
[error]         at org.gnome.gio.FileEnumerator.nextFilesAsync(FileEnumerator.java:525)
[error]         at Shades.GIOFS2$.list$$anonfun$3$$anonfun$1$$anonfun$1$$anonfun$1(GIOFS2.scala:323)
                    MethodHandles.g_input_stream_read_async.invokeExact(handle(), 
                            (MemorySegment) (buffer == null ? MemorySegment.NULL : _bufferPointer), 
                            count, ioPriority, 
                            (MemorySegment) (cancellable == null ? MemorySegment.NULL : cancellable.handle()), 
                            (MemorySegment) (callback == null ? MemorySegment.NULL : callback.toCallback(_callbackScope)), 
                            MemorySegment.NULL);
enumerator.nextFilesAsync(1, GLib.GLib.PRIORITY_DEFAULT, cancellable, (obj, res, data) =>
    try
        val it = enumerator.nextFilesFinish(res)
        if it.isEmpty() then
            callback(Right(None))
        else
            println(it.iterator)
            println(it.iterator.next)
            callback(Right(Some(it.iterator.next, ())))
    catch case e => callback(Left(e))
) // <- stack trace here

[error] java.lang.NullPointerException: Cannot invoke "java.lang.ref.WeakReference.get()" because "proxy" is null
[error]         at io.github.jwharm.javagi.gobject.InstanceCache.handleToggleNotify(InstanceCache.java:331)
[error]         at org.gnome.gio.InputStream.readAsync(InputStream.java:530)
[error]         at Shades.ReadFileHandle.read$$anonfun$1$$anonfun$2$$anonfun$1(GIOFS2.scala:153)
                    MethodHandles.g_input_stream_read_async.invokeExact(handle(), 
                            (MemorySegment) (buffer == null ? MemorySegment.NULL : _bufferPointer), 
                            count, ioPriority, 
                            (MemorySegment) (cancellable == null ? MemorySegment.NULL : cancellable.handle()), 
                            (MemorySegment) (callback == null ? MemorySegment.NULL : callback.toCallback(_callbackScope)), 
                            MemorySegment.NULL);
stream.readAsync(
    buffer,
    GLib.GLib.PRIORITY_DEFAULT,
    cancellable,
    (obj, res, data) => {
        try
            val nbytes = stream.readFinish(res)
            callback(
                Right(
                    Some(
                        Chunk.array(
                            Arrays.copyOfRange(
                                buffer.get(),
                                0,
                                nbytes.toInt,
                            )
                        )
                    )
                )
            )
        catch case e =>
            callback(Left(e))
    }, // <-- stack trace here
)

i think it has something to do with garbage collection because it's indeterminate which of these two throw and both involve callbacks passed into GObject land

@jwharm
Copy link
Owner

jwharm commented Jun 3, 2024

Probably caused by a missing ref() somewhere.

Can you run with environment variable "G_MESSAGES_DEBUG=all" and copy the output here?

@sowelipililimute
Copy link
Author

[error] WARNING: A restricted method in java.lang.foreign.SymbolLookup has been called
[error] WARNING: java.lang.foreign.SymbolLookup::libraryLookup has been called by io.github.jwharm.javagi.interop.Interop in an unnamed module
[error] WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
[error] WARNING: Restricted methods will be blocked in a future release unless native access is enabled
[info] (process:364022): GLib-DEBUG: 22:21:32.099: unsetenv() is not thread-safe and should not be used after threads are created
[info] (process:364022): GLib-DEBUG: 22:21:32.099: unsetenv() is not thread-safe and should not be used after threads are created
[info] (process:364022): GLib-DEBUG: 22:21:32.099: unsetenv() is not thread-safe and should not be used after threads are created
[info] (process:364022): java-gi-DEBUG: 22:21:33.150: New org.gnome.gtk.Application 140115938043968
[info] (process:364022): java-gi-DEBUG: 22:21:33.156: Toggle 140115938043968 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:33.180: Toggle 140115938043968 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:33.180: Toggle 140115938043968 to weak reference (is last ref)
[info] (java:364022): GLib-GIO-DEBUG: 22:21:33.181: Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)
[info] (java:364022): java-gi-DEBUG: 22:21:33.184: Toggle 140115938043968 to strong reference
[info] (java:364022): GLib-GIO-DEBUG: 22:21:33.219: _g_io_module_get_default: Found default implementation dconf (DConfSettingsBackend) for ‘gsettings-backend’
[info] (java:364022): dconf-DEBUG: 22:21:33.219: watch_fast: "/org/gnome/desktop/interface/" (establishing: 0, active: 0)
[info] (java:364022): dconf-DEBUG: 22:21:33.220: watch_fast: "/org/gnome/desktop/peripherals/mouse/" (establishing: 0, active: 0)
[info] (java:364022): dconf-DEBUG: 22:21:33.220: watch_fast: "/org/gnome/desktop/sound/" (establishing: 0, active: 0)
[info] (java:364022): dconf-DEBUG: 22:21:33.220: watch_fast: "/org/gnome/desktop/privacy/" (establishing: 0, active: 0)
[info] (java:364022): dconf-DEBUG: 22:21:33.220: watch_fast: "/org/gnome/desktop/wm/preferences/" (establishing: 0, active: 0)
[info] (java:364022): dconf-DEBUG: 22:21:33.220: watch_fast: "/org/gnome/settings-daemon/plugins/xsettings/" (establishing: 0, active: 0)
[info] (java:364022): dconf-DEBUG: 22:21:33.220: watch_fast: "/org/gnome/desktop/a11y/" (establishing: 0, active: 0)
[info] (java:364022): dconf-DEBUG: 22:21:33.220: watch_fast: "/org/gnome/desktop/a11y/interface/" (establishing: 0, active: 0)
[info] (java:364022): GLib-GIO-DEBUG: 22:21:33.220: Using cross-namespace EXTERNAL authentication (this will deadlock if server is GDBus < 2.73.3)
[info] (java:364022): dconf-DEBUG: 22:21:33.222: watch_established: "/org/gnome/desktop/interface/" (establishing: 1)
[info] (java:364022): dconf-DEBUG: 22:21:33.228: watch_established: "/org/gnome/desktop/peripherals/mouse/" (establishing: 1)
[info] (java:364022): dconf-DEBUG: 22:21:33.228: watch_established: "/org/gnome/desktop/sound/" (establishing: 1)
[info] (java:364022): dconf-DEBUG: 22:21:33.228: watch_established: "/org/gnome/desktop/privacy/" (establishing: 1)
[info] (java:364022): dconf-DEBUG: 22:21:33.228: watch_established: "/org/gnome/desktop/wm/preferences/" (establishing: 1)
[info] (java:364022): dconf-DEBUG: 22:21:33.228: watch_established: "/org/gnome/settings-daemon/plugins/xsettings/" (establishing: 1)
[info] (java:364022): dconf-DEBUG: 22:21:33.228: watch_established: "/org/gnome/desktop/a11y/" (establishing: 1)
[info] (java:364022): dconf-DEBUG: 22:21:33.228: watch_established: "/org/gnome/desktop/a11y/interface/" (establishing: 1)
[info] (java:364022): Gtk-DEBUG: 22:21:33.269: Connecting to session manager
[error] (java:364022): Gtk-WARNING **: 22:21:33.273: Unknown key gtk-modules in /home/jblackquill/.config/gtk-4.0/settings.ini
[info] (java:364022): Gtk-DEBUG: 22:21:33.269: Failed to get the GNOME session proxy: The name org.gnome.SessionManager is not owned
[info] (java:364022): Gtk-DEBUG: 22:21:33.270: Failed to get the Xfce session proxy: The name org.xfce.SessionManager is not owned
[info] (java:364022): GLib-GIO-DEBUG: 22:21:33.282: _g_io_module_get_default: Found default implementation gvfs (GDaemonVfs) for ‘gio-vfs’
[info] (java:364022): java-gi-DEBUG: 22:21:33.524: New org.gnome.gtk.Settings 140115940939968
[info] (java:364022): java-gi-DEBUG: 22:21:33.524: Ref org.gnome.gtk.Settings 140115940939968
[info] (java:364022): java-gi-DEBUG: 22:21:33.632: Ref org.gnome.gtk.Settings 140115940939968
[info] (java:364022): java-gi-DEBUG: 22:21:33.667: New org.gnome.gtk.ApplicationWindow 140115942486224
[info] (java:364022): java-gi-DEBUG: 22:21:33.668: Ref org.gnome.gobject.GObject 140115942486224
[info] (java:364022): java-gi-DEBUG: 22:21:33.675: New org.gnome.gtk.HeaderBar 140115941491504
[info] (java:364022): java-gi-DEBUG: 22:21:33.675: Ref org.gnome.gobject.GObject 140115941491504
[info] (java:364022): java-gi-DEBUG: 22:21:33.692: New org.gnome.gtk.Box 140115941070816
[info] (java:364022): java-gi-DEBUG: 22:21:33.692: Ref org.gnome.gobject.GObject 140115941070816
[info] (java:364022): java-gi-DEBUG: 22:21:33.692: Ref org.gnome.gobject.GObject 140115941070816
[info] (java:364022): java-gi-DEBUG: 22:21:33.701: New org.gnome.gtk.Button 140115942824048
[info] (java:364022): java-gi-DEBUG: 22:21:33.701: Ref org.gnome.gobject.GObject 140115942824048
[info] (java:364022): java-gi-DEBUG: 22:21:33.702: Ref org.gnome.gtk.Button 140115942824048
[info] (java:364022): java-gi-DEBUG: 22:21:33.706: New org.gnome.gtk.Button 140115942771216
[info] (java:364022): java-gi-DEBUG: 22:21:33.706: Ref org.gnome.gobject.GObject 140115942771216
[info] (java:364022): java-gi-DEBUG: 22:21:33.707: Ref org.gnome.gtk.Button 140115942771216
[info] (java:364022): java-gi-DEBUG: 22:21:33.713: New org.gnome.gtk.Button 140115942701376
[info] (java:364022): java-gi-DEBUG: 22:21:33.713: Ref org.gnome.gobject.GObject 140115942701376
[info] (java:364022): java-gi-DEBUG: 22:21:33.714: Ref org.gnome.gtk.Button 140115942701376
[error] يونيو 03, 2024 10:21:35 م dev.ludovic.netlib.blas.InstanceBuilder initializeNative
[info] trying to return java 16 instance
[error] WARNING: Failed to load implementation from:dev.ludovic.netlib.blas.JNIBLAS
[error] يونيو 03, 2024 10:21:35 م dev.ludovic.netlib.blas.InstanceBuilder initializeJava
[error] WARNING: Failed to load implementation from:dev.ludovic.netlib.blas.VectorBLAS
[info] return java 11 instance
[info] (java:364022): java-gi-DEBUG: 22:21:35.351: New Shades.LayerWidget 140115955324128
[info] (java:364022): java-gi-DEBUG: 22:21:35.352: Ref org.gnome.gobject.GObject 140115955324128
[info] (java:364022): java-gi-DEBUG: 22:21:35.355: New org.gnome.gtk.EventControllerScroll 140115955337952
[info] (java:364022): java-gi-DEBUG: 22:21:35.356: Toggle 140115955337952 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:35.391: Toggle 140115955337952 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:35.394: New org.gnome.gtk.GestureZoom 140115955510480
[info] (java:364022): java-gi-DEBUG: 22:21:35.394: Toggle 140115955510480 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:35.403: Toggle 140115955510480 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:35.404: New org.gnome.gtk.EventControllerMotion 140115955531648
[info] (java:364022): java-gi-DEBUG: 22:21:35.405: Toggle 140115955531648 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:35.405: Toggle 140115955531648 to strong reference
[info] (java:364022): Gtk-DEBUG: 22:21:35.498: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:35.498: snapshot symbolic icon using mask
[info] (java:364022): java-gi-DEBUG: 22:21:37.267: New org.gnome.gtk.FileDialog 140115958425792
[info] (java:364022): java-gi-DEBUG: 22:21:37.268: Toggle 140115958425792 to weak reference (is last ref)
[info] (java:364022): dconf-DEBUG: 22:21:37.314: watch_fast: "/org/gtk/gtk4/settings/file-chooser/" (establishing: 0, active: 0)
[info] (java:364022): dconf-DEBUG: 22:21:37.315: watch_established: "/org/gtk/gtk4/settings/file-chooser/" (establishing: 1)
[info] (java:364022): java-gi-DEBUG: 22:21:37.315: Toggle 140115958425792 to strong reference
[info] (java:364022): Gtk-DEBUG: 22:21:37.315: Got version 3 for portal interface 'org.freedesktop.portal.FileChooser'
[info] (java:364022): Gtk-DEBUG: 22:21:37.564: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.564: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.579: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.580: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.595: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.596: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.615: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.615: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.628: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.628: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.643: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.643: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.658: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.658: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.680: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.680: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.692: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.692: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.709: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.710: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.736: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.736: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.758: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:37.758: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:43.947: snapshot symbolic icon using mask
[info] (java:364022): Gtk-DEBUG: 22:21:43.947: snapshot symbolic icon using mask
[info] (java:364022): java-gi-DEBUG: 22:21:43.960: New org.gnome.gio.File$FileImpl 140115936330752
[info] (java:364022): java-gi-DEBUG: 22:21:44.028: New org.gnome.gio.File$FileImpl 140115936540736
[info] (java:364022): java-gi-DEBUG: 22:21:44.028: Toggle 140115936540736 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.041: New org.gnome.gio.Cancellable 140115456299904
[info] (java:364022): java-gi-DEBUG: 22:21:44.042: Toggle 140115456299904 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.052: Toggle 140115936540736 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.052: Toggle 140115958425792 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.052: Toggle 140115456299904 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.065: Toggle 140115936330752 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.068: New org.gnome.gio.FileEnumerator 140114584251328
[info] (java:364022): java-gi-DEBUG: 22:21:44.070: Toggle 140114584251328 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.070: Toggle 140115456299904 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.163: Unref 140115456299904
[info] (java:364022): java-gi-DEBUG: 22:21:44.289: New org.gnome.gio.Cancellable 140115458444272
[info] (java:364022): java-gi-DEBUG: 22:21:44.289: Toggle 140115458444272 to weak reference (is last ref)
[info] org.gnome.gio.FileEnumerator@8b4c4d3
[info] (java:364022): java-gi-DEBUG: 22:21:44.296: Toggle 140114584251328 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.296: Toggle 140115458444272 to strong reference
[info] org.gnome.glib.List$1@57070dea
[info] org.gnome.gio.FileInfo@d261e83
[info] (java:364022): java-gi-DEBUG: 22:21:44.303: Toggle 140114584251328 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.304: Toggle 140115458444272 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.316: New org.gnome.gio.File$FileImpl 140115993200144
[info] (java:364022): java-gi-DEBUG: 22:21:44.316: Toggle 140115993200144 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.318: New org.gnome.gio.File$FileImpl 140115993207808
[info] (java:364022): java-gi-DEBUG: 22:21:44.318: Toggle 140115993207808 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.323: New org.gnome.gio.Cancellable 140115993233824
[info] (java:364022): java-gi-DEBUG: 22:21:44.323: Toggle 140115993233824 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.326: Toggle 140115993207808 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.326: Toggle 140115993233824 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.329: New org.gnome.gio.FileInputStream 140114584243168
[info] (java:364022): java-gi-DEBUG: 22:21:44.329: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.330: Toggle 140115993207808 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.330: Toggle 140115993233824 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.352: New org.gnome.gio.Cancellable 140116194590544
[info] (java:364022): java-gi-DEBUG: 22:21:44.352: Toggle 140116194590544 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.383: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.384: Toggle 140116194590544 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 512
[info] (java:364022): java-gi-DEBUG: 22:21:44.397: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.399: Toggle 140116194590544 to weak reference (is last ref)
[info] {
[info] glyphname = "a-sp";
[info] layers = (
[info] {
[info] background = {
[info] shapes = (
[info] {
[info] closed = 1;
[info] nodes = (
[info] (906,1490,l),
[info] (906,816,l),
[info] (1096,816,l),
[info] (1096,1490,l)
[info] );
[info] },
[info] {
[info] closed = 1;
[info] nodes = (
[info] (1076,-8,o),
[info] (1141,52,o),
[info] (1168,111,c),
[info] (1177,111,l),
[info] (1178,0,l),
[info] (1348,0,l),
[info] (1347,619,l),
[info] (1175,619,l),
[info] (1176,499,l),
[info] (1169,499,l),
[info] (1143,562,o),
[info] (1077,625,o),
[info] (949,625,cs),
[info] (792,625,o),
[info] (654,530,o),
[info] (653,309,cs),
[info] (653,100,o),
[info] (782,-8,o),
[info] (949,-8,cs)
[info] );
[info] },
[info] {
[info] closed = 1;
[info] nodes = (
[info] (890,124,o),
[info] (829,202,o),
[info] (830,311,cs),
[info] (831,414,o),
[info] (888,4
[info] (java:364022): java-gi-DEBUG: 22:21:44.446: New org.gnome.gio.Cancellable 140115458558880
[info] (java:364022): java-gi-DEBUG: 22:21:44.446: Toggle 140115458558880 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.449: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.450: Toggle 140115458558880 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 512
[info] (java:364022): java-gi-DEBUG: 22:21:44.455: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.455: Toggle 140115458558880 to weak reference (is last ref)
[info] 
[info] (java:364022): java-gi-DEBUG: 22:21:44.457: New org.gnome.gio.Cancellable 140113644360064
[info] (java:364022): java-gi-DEBUG: 22:21:44.457: Toggle 140113644360064 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.458: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.459: Toggle 140113644360064 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 512
[info] norAxisWidth = 15;
[info] };
[info] "Letterink-NibStyleId" = 1;
[info] })
[info] );
[info] },
[info] {
[info] closed = 1;
[info] nodes = (
[info] (1045,688,o),
[info] (805,490,cs,{
[info] "Letterink-NibData" = {
[info] MainAxisWidth = 110;
[info] MinorAxisWidth = 105;
[info] ValidForParentMainAxisWidth = 30;
[info] ValidForParentMinorAxisWidth = 15;
[info] };
[info] "Letterink-NibStyleId" = 1;
[info] }),
[info] (534,268,o),
[info] (855,-116,o),
[info] (1105,130,cs,{
[info] "Letterink-NibData" = {
[info] MainAxisWidth = 110;
[info] MinorAxisWidth = 105;
[info] ValidForParentMainAxisWidth = 30;
[info] ValidForParentMinorAxisWidth = 15;
[info] };
[info] "Letterink-NibStyleId" = 1;
[info] }),
[info] (1327,348,o)
[info] );
[info] }
[info] (java:364022): java-gi-DEBUG: 22:21:44.463: New org.gnome.gio.Cancellable 140113778583520
[info] (java:364022): java-gi-DEBUG: 22:21:44.463: Toggle 140113778583520 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.464: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.465: Toggle 140113644360064 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.465: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.465: Toggle 140113778583520 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 467
[info] (java:364022): java-gi-DEBUG: 22:21:44.468: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.468: Toggle 140113778583520 to weak reference (is last ref)
[info] ,
[info] {
[info] closed = 0;
[info] nodes = (
[info] (1259,583,l,{
[info] "Letterink-NibData" = {
[info] MainAxisWidth = 110;
[info] MinorAxisWidth = 105;
[info] ValidForParentMainAxisWidth = 30;
[info] ValidForParentMinorAxisWidth = 15;
[info] };
[info] "Letterink-NibStyleId" = 1;
[info] }),
[info] (1196,496,o),
[info] (1214,42,o),
[info] (1242,6,c,{
[info] "Letterink-NibData" = {
[info] MainAxisWidth = 110;
[info] MinorAxisWidth = 105;
[info] ValidForParentMainAxisWidth = 30;
[info] ValidForParentMinorAxisWidth = 15;
[info] };
[info] "Letterink-NibStyleId" = 1;
[info] })
[info] );
[info] }
[info] );
[info] width = 2000;
[info] }
[info] );
[info] unicode = 989440;
[info] }
[info] (java:364022): java-gi-DEBUG: 22:21:44.469: New org.gnome.gio.Cancellable 140116127745456
[info] (java:364022): java-gi-DEBUG: 22:21:44.470: Toggle 140116127745456 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.471: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.472: Toggle 140116127745456 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.474: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.474: Toggle 140116127745456 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.475: New org.gnome.gio.Cancellable 140116261659472
[info] (java:364022): java-gi-DEBUG: 22:21:44.476: Toggle 140116261659472 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.477: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.477: Toggle 140116261659472 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.480: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.481: New org.gnome.gio.Cancellable 140116396298528
[info] (java:364022): java-gi-DEBUG: 22:21:44.481: Toggle 140116261659472 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.481: Toggle 140116396298528 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.482: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.483: Toggle 140116396298528 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.486: New org.gnome.gio.Cancellable 140115791854176
[info] (java:364022): java-gi-DEBUG: 22:21:44.486: Toggle 140115791854176 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.487: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.487: Toggle 140116396298528 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.488: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.488: Toggle 140115791854176 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.492: New org.gnome.gio.Cancellable 140116194738608
[info] (java:364022): java-gi-DEBUG: 22:21:44.492: Toggle 140116194738608 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.493: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.493: Toggle 140115791854176 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.494: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.494: Toggle 140116194738608 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.500: New org.gnome.gio.Cancellable 140115458557312
[info] (java:364022): java-gi-DEBUG: 22:21:44.500: Toggle 140115458557312 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.501: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.501: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.502: Toggle 140115458557312 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.502: Toggle 140116194738608 to weak reference (is last ref)
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.506: New org.gnome.gio.Cancellable 140116127747680
[info] (java:364022): java-gi-DEBUG: 22:21:44.507: Toggle 140116127747680 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.511: Toggle 140116127747680 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.512: Toggle 140115458557312 to weak reference (is last ref)
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.519: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.519: Toggle 140116127747680 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.520: New org.gnome.gio.Cancellable 140116194739136
[info] (java:364022): java-gi-DEBUG: 22:21:44.520: Toggle 140116194739136 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.522: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.522: Toggle 140116194739136 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.525: New org.gnome.gio.Cancellable 140116395825904
[info] (java:364022): java-gi-DEBUG: 22:21:44.525: Toggle 140116395825904 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.527: Toggle 140116395825904 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.528: Toggle 140116194739136 to weak reference (is last ref)
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.530: New org.gnome.gio.Cancellable 140116127748944
[info] (java:364022): java-gi-DEBUG: 22:21:44.531: Toggle 140116127748944 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.532: Toggle 140116127748944 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.533: Toggle 140116395825904 to weak reference (is last ref)
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.535: New org.gnome.gio.Cancellable 140116194739440
[info] (java:364022): java-gi-DEBUG: 22:21:44.536: Toggle 140116194739440 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.538: Toggle 140116194739440 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.539: Toggle 140116127748944 to weak reference (is last ref)
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[error] java.lang.NullPointerException: Cannot invoke "java.lang.ref.WeakReference.get()" because "proxy" is null
[error]         at io.github.jwharm.javagi.gobject.InstanceCache.handleToggleNotify(InstanceCache.java:331)
[error]         at org.gnome.gio.InputStream.readAsync(InputStream.java:530)
[info] (java:364022): java-gi-DEBUG: 22:21:44.541: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.542: Toggle 140116194739440 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.542: New org.gnome.gio.Cancellable 140115791854096
[info] (java:364022): java-gi-DEBUG: 22:21:44.542: Toggle 140115791854096 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.545: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.546: Toggle 140115791854096 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.549: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.549: Toggle 140115791854096 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.550: New org.gnome.gio.Cancellable 140116261659840
[info] (java:364022): java-gi-DEBUG: 22:21:44.550: Toggle 140116261659840 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.551: Toggle 140114584243168 to strong reference
[error]         at Shades.ReadFileHandle.read$$anonfun$1$$anonfun$2$$anonfun$1(GIOFS2.scala:157)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[info] (java:364022): java-gi-DEBUG: 22:21:44.552: Toggle 140116261659840 to strong reference
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at cats.effect.IO$$anon$5.apply$$anonfun$3$$anonfun$1$$anonfun$1(IO.scala:1317)
[error]         at cats.effect.IO$$anon$5.apply$$anonfun$3$$anonfun$1$$anonfun$adapted$1(IO.scala:1317)
[error]         at cats.effect.IOFiber.runLoop(IOFiber.scala:396)
[error]         at cats.effect.IOFiber.execR(IOFiber.scala:1364)
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[error]         at cats.effect.IOFiber.run(IOFiber.scala:112)
[info] (java:364022): java-gi-DEBUG: 22:21:44.554: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.554: Toggle 140116261659840 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.555: New org.gnome.gio.Cancellable 140116060294176
[info] (java:364022): java-gi-DEBUG: 22:21:44.555: Toggle 140116060294176 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.556: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.557: Toggle 140116060294176 to strong reference
[error]         at cats.effect.unsafe.WorkerThread.run(WorkerThread.scala:743)
[error] Unrecoverable uncaught exception encountered. The VM will now exit
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.559: New org.gnome.gio.Cancellable 140116194739760
[info] (java:364022): java-gi-DEBUG: 22:21:44.560: Toggle 140116194739760 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.561: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.561: Toggle 140116060294176 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.562: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.562: Toggle 140116194739760 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.565: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.565: Toggle 140116194739760 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.565: New org.gnome.gio.Cancellable 140116395829488
[info] (java:364022): java-gi-DEBUG: 22:21:44.566: Toggle 140116395829488 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.568: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.568: Toggle 140116395829488 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.572: New org.gnome.gio.Cancellable 140116194741104
[info] (java:364022): java-gi-DEBUG: 22:21:44.573: Toggle 140116194741104 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.573: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.574: Toggle 140116395829488 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.574: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.575: Toggle 140116194741104 to strong reference
[info] org.gnome.gio.FileInputStream@8b8a0f3
[info] 0
[info] (java:364022): java-gi-DEBUG: 22:21:44.584: New org.gnome.gio.Cancellable 140115993241088
[info] (java:364022): java-gi-DEBUG: 22:21:44.584: Toggle 140115993241088 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.586: Toggle 140114584243168 to strong reference
[info] (java:364022): java-gi-DEBUG: 22:21:44.587: Toggle 140114584243168 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:44.587: Toggle 140116194741104 to weak reference (is last ref)
[info] (java:364022): java-gi-DEBUG: 22:21:51.445: Toggle 140115938043968 to weak reference (is last ref)
[info] (java:364022): dconf-DEBUG: 22:21:51.445: sync
[error] tcache_thread_shutdown(): unaligned tcache chunk detected

some of the output is intermixed with my application prints

@jwharm
Copy link
Owner

jwharm commented Jun 5, 2024

The FileInputStream at address 140114584243168 emits a ToggleNotify with is_last_ref=false twice in a row. As result java-gi attempst to change the weak ref into a strong ref twice. This explains the NPE for the weak reference.

I think my assumption was incorrect, and this can happen in an async context when multiple threads access the same object concurrently. I will change the ToggleNotify event handler to handle this more gracefully.

@jwharm
Copy link
Owner

jwharm commented Jun 6, 2024

I changed the toggle reference functionality to handle the situation described above. I also found another bug related to refcounting: for all objects with floating references (i.e. all Gtk widgets) an extra call to g_object_ref was done when java-gi added them to the InstanceCache. This is a memory leak, so I fixed this as well.

I published a 0.10.2-SNAPSHOT release with both these fixes. Can you please retest?

For snapshot dependencies, add https://s01.oss.sonatype.org/content/repositories/snapshots to the repositories in your build script.

@sowelipililimute
Copy link
Author

Looks like it fixed the issue for me

@jwharm
Copy link
Owner

jwharm commented Jun 9, 2024

Fixed with commit ae67610

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants