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

exec_async crashes #174

Closed
rasmushenningsson opened this issue Sep 28, 2023 · 13 comments
Closed

exec_async crashes #174

rasmushenningsson opened this issue Sep 28, 2023 · 13 comments

Comments

@rasmushenningsson
Copy link

exec_async is causing frequent crashes (segmentation faults) for me - but exec works fine.
It crashes every time I run basic/observable.jl from QmlJuliaExamples.

Sometimes there's also a printout saying Maximum call stack size exceeded when using exec_async.

@ufechner7
Copy link
Member

ufechner7 commented Sep 28, 2023

I can confirm that the example observable.jl crashes on Ubuntu 20.04 using Julia 1.9.3 and QML 0.8.
Stacktrace:

julia> include("observable.jl")
Output changed to 2.0

julia> 
[82118] signal (11.1): Speicherzugriffsfehler
in expression starting at none:0
_ZN8QVariantD1Ev at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Core.so.6 (unknown line)
_ZN11QQmlBinding8doUpdateERKN24QQmlJavaScriptExpression13DeleteWatcherE6QFlagsIN16QQmlPropertyData9WriteFlagEERN3QV45ScopeE at /home/ufechner/.julia/artifacts/5ec56e0e1b25eaaa5a9562609d54195b360a0348/lib/libQt6Qml.so.6 (unknown line)
_ZN11QQmlBinding6updateE6QFlagsIN16QQmlPropertyData9WriteFlagEE at /home/ufechner/.julia/artifacts/5ec56e0e1b25eaaa5a9562609d54195b360a0348/lib/libQt6Qml.so.6 (unknown line)
_ZN12QQmlNotifier10emitNotifyEP20QQmlNotifierEndpointPPv at /home/ufechner/.julia/artifacts/5ec56e0e1b25eaaa5a9562609d54195b360a0348/lib/libQt6Qml.so.6 (unknown line)
_Z10doActivateILb0EEvP7QObjectiPPv at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Core.so.6 (unknown line)
_Z10doActivateILb0EEvP7QObjectiPPv at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Core.so.6 (unknown line)
_ZN10QQuickItem5eventEP6QEvent at /home/ufechner/.julia/artifacts/5ec56e0e1b25eaaa5a9562609d54195b360a0348/lib/libQt6Quick.so.6 (unknown line)
_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Core.so.6 (unknown line)
_ZN10QQuickItem5eventEP6QEvent at /home/ufechner/.julia/artifacts/5ec56e0e1b25eaaa5a9562609d54195b360a0348/lib/libQt6Quick.so.6 (unknown line)
_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Core.so.6 (unknown line)
_ZN10QQuickItem5eventEP6QEvent at /home/ufechner/.julia/artifacts/5ec56e0e1b25eaaa5a9562609d54195b360a0348/lib/libQt6Quick.so.6 (unknown line)
_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Core.so.6 (unknown line)
_ZN10QQuickItem5eventEP6QEvent at /home/ufechner/.julia/artifacts/5ec56e0e1b25eaaa5a9562609d54195b360a0348/lib/libQt6Quick.so.6 (unknown line)
_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Core.so.6 (unknown line)
_ZN12QQuickWindow5eventEP6QEvent at /home/ufechner/.julia/artifacts/5ec56e0e1b25eaaa5a9562609d54195b360a0348/lib/libQt6Quick.so.6 (unknown line)
_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Core.so.6 (unknown line)
_ZN22QGuiApplicationPrivate21processActivatedEventEPN29QWindowSystemInterfacePrivate20ActivatedWindowEventE at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Gui.so (unknown line)
_ZN22QWindowSystemInterface22sendWindowSystemEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Gui.so (unknown line)
_ZL17xcbSourceDispatchP8_GSourcePFiPvES1_ at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/plugins/platforms/../../lib/libQt6XcbQpa.so.6 (unknown line)
g_main_context_dispatch at /home/ufechner/.julia/artifacts/b6ebc4def1211ec4043d7c055f450d59f56747cc/lib/libglib-2.0.so.0 (unknown line)
g_main_context_iterate.isra.26 at /home/ufechner/.julia/artifacts/b6ebc4def1211ec4043d7c055f450d59f56747cc/lib/libglib-2.0.so.0 (unknown line)
g_main_context_iteration at /home/ufechner/.julia/artifacts/b6ebc4def1211ec4043d7c055f450d59f56747cc/lib/libglib-2.0.so.0 (unknown line)
_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Core.so.6 (unknown line)
_ZN16QCoreApplication13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEEi at /home/ufechner/.julia/artifacts/8a8d0ba819ce1e30b93f34cc61f891d1334be59d/lib/libQt6Core.so.6 (unknown line)
process_events at /home/ufechner/.julia/packages/CxxWrap/VnssN/src/CxxWrap.jl:624 [inlined]
#23 at /home/ufechner/.julia/packages/QML/UTMZh/src/QML.jl:609 [inlined]
macro expansion at ./asyncevent.jl:281 [inlined]
#702 at ./task.jl:134
unknown function (ip: 0x7f37db22b92f)
_jl_invoke at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/julia.h:1880 [inlined]
start_task at /cache/build/default-amdci5-5/julialang/julia-release-1-dot-9/src/task.c:1092
Allocations: 5938121 (Pool: 5931601; Big: 6520); GC: 9
Speicherzugriffsfehler (Speicherabzug geschrieben)

@barche Any idea what could be the reason or how to further debug this issue?

@barche
Copy link
Collaborator

barche commented Sep 28, 2023

I can confirm this and actually noticed it before the release, but I have no idea what causes it. It is due to a change between Qt 6.4 and 6.5.

@ufechner7 ufechner7 added the bug label Sep 29, 2023
@ufechner7 ufechner7 added this to the 0.8.1 milestone Sep 29, 2023
@ufechner7
Copy link
Member

Is it possible that this issue is related? JuliaGraphics/jlqml#15

@barche
Copy link
Collaborator

barche commented Oct 6, 2023

Unfortunately no. I have no idea what is causing this, what I have determined is that launching any Qt6 event loop from within a Julia task (which is what exec_async does) crashes the program. Even if we place the normal exec in a julia @async call it crashes. There must be some kind of interaction between the Julia task system and the Qt event processing code, but I don't know what it is.

@ufechner7
Copy link
Member

ufechner7 commented Oct 8, 2023

While the examples listmodel-fromjulia and observable crash, the example repl-background just works fine. (On Ubuntu 20.04).

@barche Any idea?

@barche
Copy link
Collaborator

barche commented Oct 8, 2023

The difference is that in the repl-background example the QML doesn't contain any UI elements that take input. If you add e.g. a button it also crashes. I still have no idea at all on the root cause.

@ufechner7
Copy link
Member

Both examples don't crash if you start Julia with: JULIA_COPY_STACKS=yes julia --project

@barche
Copy link
Collaborator

barche commented Oct 9, 2023

Thanks to @ufechner7 's observation in barche/QmlJuliaExamples#12 we now know that a workaround is to set JULIA_COPY_STACKS=yes before launching Julia. Searching further on this in the Julia issues, the full explanation can be found here: JuliaLang/julia#31104 (comment)

The reason is that Qt 6.5 has a new stack bound checker: https://bugreports.qt.io/browse/QTBUG-106875, so that's why Qt 6.4 was not affected.

@ufechner7
Copy link
Member

ufechner7 commented Oct 10, 2023

So what is the way to proceed?

  • document this parameter in the docstring of exec_async and the effected examples
  • add an assertion to exec_async that JULIA_COPY_STACKS is set to yes?
  • revert to Qt 6.4 ? (probably not)
    Is there any other way to avoid the need for this workaround?

@barche
Copy link
Collaborator

barche commented Oct 10, 2023

The only currently viable workaround is setting JULIA_COPY_STACKS, so I think both an assertion and a docstring are needed.

@barche
Copy link
Collaborator

barche commented Oct 11, 2023

Thanks to the golden tip here: JuliaLang/julia#31104 (comment)

I now have a fix running locally, so this should be committed soon.

@ufechner7
Copy link
Member

You are a genius!

barche added a commit that referenced this issue Oct 14, 2023
Issue `exec_async` crashes #174
barche added a commit that referenced this issue Oct 16, 2023
Issue `exec_async` crashes #174
@barche
Copy link
Collaborator

barche commented Oct 16, 2023

Fixed in QML.jl 0.8.1

@barche barche closed this as completed Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants