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

vector::_M_range_check: __n (which is 0) >= this->size() (which is 0) #322

Open
benstox opened this issue Nov 26, 2022 · 4 comments
Open

Comments

@benstox
Copy link

benstox commented Nov 26, 2022

Hello,

I am getting this error when I run android-file-transfer, built at commit 5ae0221, tag continuous, version 4.3.0. I am running Ubuntu 22.04.1 LTS. It is trying to connect to a Motorola "Moto G (3rd Generation)", Android version 6.0.1.

An UI window opens with the text: "Could not open MTP session: vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)"

And I get the terminal output:

Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
upload worker started
current text color value:  0 , guessed theme:  "light"
scan
probing device...
probing device...
probing device...
probing device...
device found, opening session...
open session/device info failed:  "vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)"
open session/device info failed:  "vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)"
open session/device info failed:  "vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)"

Running aft-mtp-cli gives:

Device::Find failed:vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
@leamas
Copy link

leamas commented Dec 25, 2022

Same on Fedora 36, building from source at 9967dec

EDIT: The crash only occurs on Wayland, on Xorg everything is fine.

Stacktrace:

#0  __pthread_kill_implementation
    (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0)
    at pthread_kill.c:44
#1  0x00007ffff608ec73 in __pthread_kill_internal
    (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff603e986 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/posix/raise.c:26
#3  0x00007ffff60287f4 in __GI_abort () at abort.c:79
#4  0x00007ffff64a2b77 in __gnu_cxx::__verbose_terminate_handler() ()
    at ../../../../libstdc++-v3/libsupc++/vterminate.cc:95
#5  0x00007ffff64ae3bc in __cxxabiv1::__terminate(void (*)())
    (handler=<optimized out>)
    at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:48
#6  0x00007ffff64ae427 in std::terminate() ()
    at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:58
#7  0x00007ffff64ae6db in __cxxabiv1::__cxa_rethrow() ()
    at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:136
#8  0x00007ffff6e857cc in QCoreApplication::notifyInternal(QObject*, QEvent*)
    (this=0x7fffffffdac0, receiver=receiver@entry=0x7fffffffd9d0, event=event@entry=0x7fffffffd8f0) at kernel/qcoreapplication.cpp:958
#9  0x00007ffff74cdac5 in QCoreApplication::sendEvent(QObject*, QEvent*)
    (event=0x7fffffffd8f0, receiver=0x7fffffffd9d0)
    at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#10 QWidgetPrivate::show_helper() (this=0x848600) at kernel/qwidget.cpp:7569
#11 0x00007ffff74cf6ec in QWidget::setVisible(bool)
    (this=0x7fffffffd9d0, visible=<optimized out>) at kernel/qwidget.cpp:7791
#12 0x00000000004f2652 in QWidget::show() (this=0x7fffffffd9d0)
    at /usr/include/QtGui/qwidget.h:497
#13 0x00000000004f22c2 in main(int, char**) (argc=1, argv=0x7fffffffdc78)
    at /home/mk/src/android-file-transfer-linux/qt/main.cpp:85

@leamas
Copy link

leamas commented Dec 25, 2022

Furthermore, the crash on wayland can be avoided by export GDK_BACKEND=x11 before invoking android-file-transfer

@leamas
Copy link

leamas commented Dec 25, 2022

Below a simple patch which works around the issue (too lazy to make a PR, sorry, perhaps someone else is motivated)

iff --git a/qt/main.cpp b/qt/main.cpp
index 4a70feb..e5efbaf 100644
--- a/qt/main.cpp
+++ b/qt/main.cpp
@@ -25,6 +25,7 @@
 #include <QMessageBox>
 #include <QTranslator>
 #include <mtp/log.h>
+#include <stdlib.h>
 #if QT_VERSION >= 0x050000
 #      include <QGuiApplication>
 #endif
@@ -52,6 +53,10 @@ namespace
 
 int main(int argc, char *argv[])
 {
+       if (getenv("WAYLAND_DISPLAY")) {
+               // See #322
+               setenv("GDK_BACKEND", "x11", true);
+       }
        QApplication app(argc, argv);
        Q_INIT_RESOURCE(android_file_transfer);
 

@llyyr
Copy link

llyyr commented Mar 3, 2023

Setting GDK_BACKEND=x11 just forces aft to run under xwayland, you should instead set QT_QPA_PLATFORM=wayland to run under wayland

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

3 participants