Bug 335161

Summary: get_stringlist_reply returns invalid data for single item lists
Product: [Frameworks and Libraries] frameworks-kwindowsystem Reporter: Luiz Angelo De Luca <luizluca>
Component: generalAssignee: henriquemuzzi9
Status: CONFIRMED ---    
Severity: critical CC: bhush94, elchevive, henriquemuzzi9, hrvoje.senjan, kde, kdelibs-bugs, kwin-bugs-null, luizromario, octavio, reesa.e3, stasnel, thomas.luebking
Priority: VHI Flags: bhush94: Translation_missing+
Version: 5.0.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot
Localization section in systemsettings
Screenshot
screenshot
aDSFDHNM

Description Luiz Angelo De Luca 2014-05-21 22:14:14 UTC
Hello,

In a clean installation, I get a single virtual desktop with this strange name: "EEEEEEEEEEEEEEEEo 1". I guess other name is better (even "Desktop 1")



Reproducible: Always
Comment 1 Bhushan Shah 2014-05-22 04:13:08 UTC
Eh, what do you mean? I can not reproduce.. screenshot maybe?
Comment 2 Luiz Angelo De Luca 2014-05-22 18:30:05 UTC
Created attachment 86775 [details]
Screenshot

Notice the EEEEEEEEE. Is it from pt_BR translation?
Comment 3 Bhushan Shah 2014-05-23 04:28:16 UTC
it looks like translation problem..
Comment 4 David Edmundson 2014-05-27 17:02:01 UTC
There's no EEEEE in pt_BR translations (current master)

void DesktopNamesWidget::setDefaultName(int desktop)
{
    if ((desktop < 1) || (desktop > m_maxDesktops))
        return;
    QString name = m_desktopConfig->cachedDesktopName(desktop);
    if (name.isEmpty())
        name = i18n("Desktop %1", desktop);
    m_nameInputs[ desktop -1 ]->setText(name);
}

Luiz, can you confirm if the bug is still there and which translations you are using.

Re-assigning to kwin which is where the KCM is.
Comment 5 Thomas Lübking 2014-05-27 17:33:40 UTC
What's the output of

   kreadconfig --file kwinrc --group Desktops --key Name_1
Comment 6 Luiz Angelo De Luca 2014-05-27 18:00:05 UTC
$ kreadconfig --file kwinrc --group Desktops --key Name_1

Did not work (there is no kreadconfig for kf5 in opensuse packages. It might tried to read kde4 files)

However, I got the kwinrc file directly.

cat ~/.config/kwinrc
[Compositing]
OpenGLIsUnsafe=false

[Desktops]
Name_1=EEEEEEEEE
Number=1
Rows=1

[Effect-Zoom]
InitialZoom=1

[Plugins]
cubeslideEnabled=false
desktopchangeosdEnabled=false
kwin4_effect_fadedesktopEnabled=false
slideEnabled=true

[Script-desktopchangeosd]
PopupHideDelay=1000
TextOnly=false

[Windows]
RollOverDesktops=true

 Is it maybe a downstream problem?
I looked for this EEEEE and found nothing:

$ rpm -qa --queryformat "%{Name}:%{Vendor}\n" | grep obs://build.opensuse.org/KDE:Unstable | cut -d: -f1 | xargs rpm -ql | sed 's/.*/"&"/' | xargs strings | grep EEEEEEEEE
FIXXXXXMMEEEEEEEEEEEEE
N3WTF10RefCountedIN7WebCore7SVGListINS_6RefPtrINS1_14SVGPODListItemINS1_12SVGTransformEEEEEEEEE
N3WTF10RefCountedIN7WebCore7SVGListINS_6RefPtrINS1_14SVGPODListItemINS1_10FloatPointEEEEEEEEE
N3WTF10RefCountedIN7WebCore7SVGListINS_6RefPtrINS1_14SVGPODListItemINS1_9SVGLengthEEEEEEEEE
N3WTF10RefCountedIN7WebCore7SVGListINS_6RefPtrINS1_14SVGPODListItemINS1_12SVGTransformEEEEEEEEE
N3WTF10RefCountedIN7WebCore7SVGListINS_6RefPtrINS1_14SVGPODListItemINS1_10FloatPointEEEEEEEEE
N3WTF10RefCountedIN7WebCore7SVGListINS_6RefPtrINS1_14SVGPODListItemINS1_9SVGLengthEEEEEEEEE
strings: /var/lib/NetworkManager: Permissão negada
strings: /var/log/NetworkManager: Permissão negada

And also nothing on /etc

The only thing I know is that if I remove all .config contents, kde generate a new config with the EEEEEEEEE.
Comment 7 Martin Flöser 2014-05-27 18:16:23 UTC
it's kreadconfig5 with kf5.

KWin saves the configuration of the desktop names before shutting down. As you have a desktop called EEEEEEEEE, it gets saved. You have to go to the desktop settings KCM and click defaults and apply them.

I don't know where the strange name came from, but not from KWin, thus setting to worksforme.
Comment 8 Bhushan Shah 2014-05-28 04:06:55 UTC
*** Bug 335436 has been marked as a duplicate of this bug. ***
Comment 9 Luiz Angelo De Luca 2014-05-28 04:40:14 UTC
Reopen? There is another report (Bug 335436)
Comment 10 Thomas Lübking 2014-05-28 05:19:03 UTC
@romario
what does your locale happen to be...?
Comment 11 Romário Rios 2014-05-28 08:44:04 UTC
(In reply to comment #10)
> @romario
> what does your locale happen to be...?
pt_BR
Comment 12 Thomas Lübking 2014-05-28 09:49:27 UTC
That's what I call a pattern - can you try pt?
There's sth. interesting:

pt is "Ecrã %1" whilte pt_BR id "Área de trabalho %1"
Comment 13 Romário Rios 2014-05-28 15:38:17 UTC
(In reply to comment #12)
> That's what I call a pattern - can you try pt?
Well, I can't find the language KCM in systemsettings. Where do I change the system language?

> There's sth. interesting:
> 
> pt is "Ecrã %1" whilte pt_BR id "Área de trabalho %1"
OT: The pt_BR translation literally translates to "Working area", while the pt_PT translation -- I think -- is an adaptation from the French "écran", which translates to "Screen".
Comment 14 Romário Rios 2014-05-28 15:39:41 UTC
Created attachment 86883 [details]
Localization section in systemsettings

This is all I have in the localization section in systemsettings. There's no language selection KCM.
Comment 15 André Marcelo Alvarenga 2014-05-29 00:37:33 UTC
Created attachment 86890 [details]
Screenshot

Correct translation (Área de trabalho) with Project Neon5.
Comment 16 Hrvoje Senjan 2014-05-30 15:21:00 UTC
should be reassigned IMO. have the EEEEEEE with no lang selected, and with also croatian lang.
Comment 17 Hrvoje Senjan 2014-05-30 15:25:40 UTC
Created attachment 86916 [details]
screenshot
Comment 18 Martin Flöser 2014-05-30 15:32:27 UTC
where is that coming from? general serach of lxr doesn't find it, so I rather 
doubt it's in our sources.

@Hrvoje: any chance to figure out which package contains the string?
Comment 19 Thomas Lübking 2014-05-30 15:33:56 UTC
Interesting, it's not "EEEEEEEEEEEEEEEEo 1" but just "EEEEEEEEE" for you.
Since it should be "Área de trabalho %1" for pt_BR, that means the first 16 bytes are overridden with "E", ie. sth.'s bleeding in here.

What about "Desktop 2"?
"EEEEEEEEE", resp. "EEEEEEEEEEEEEEEEo 2" or some realy word?
Comment 20 Hrvoje Senjan 2014-05-30 16:09:34 UTC
(In reply to comment #18)
> @Hrvoje: any chance to figure out which package contains the string?

will try

(In reply to comment #19)
> What about "Desktop 2"?
> "EEEEEEEEE", resp. "EEEEEEEEEEEEEEEEo 2" or some realy word?

as per screenshot, every additional desktop created has 'Desktop $number'
Comment 21 Thomas Lübking 2014-05-30 16:21:15 UTC
I don't think this string will be anywhere - it's rather some data bleeding into the read config value.

virtualdesktop.cpp:334

- QString s = group.readEntry(QStringLiteral("Name_%1").arg(i), i18n("Desktop %1", i));
+ QString s = i18n("Desktop %1", i);
+ qDebug() << "i18n: << s;
+ s = group.readEntry(QStringLiteral("Name_%1").arg(i), s); 
+ qDebug() << "value: << s << s.toUtf8() << s.toUtf8().data();

That junk should either come from i18n(), group.readEntry() or is ultimately applied by
m_rootInfo->setDesktopName(i, s.toUtf8().data());

If the above debug outs are sane, it's writing the data onto the root window.
Comment 22 Hrvoje Senjan 2014-05-30 16:25:24 UTC
additional observation:
if i remove [Desktops] group (while e.g. kwin4 is running),  restart kwin5, and start kscmshell5 desktop,  it will just write in
Number=1
in kwinrc (and kcm correctly has Desktop 1)
Comment 23 Hrvoje Senjan 2014-05-30 16:52:40 UTC
(In reply to comment #21)
> If the above debug outs are sane, it's writing the data onto the root window.

i18n: "Desktop 1"
value: "Desktop 1" "Desktop 1" Desktop 1
Comment 24 Hrvoje Senjan 2014-05-30 17:09:38 UTC
as it 'works elsewhere', attaching compiler command line for kdeinit_kwin target:

/usr/bin/c++   -DKCOREADDONS_LIB -DKDE_DEFAULT_DEBUG_AREA=1212 -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_DISABLE_DEPRECATED_BEFORE=0 -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_QML_LIB -DQT_QUICK_LIB -DQT_SCRIPT_LIB -DQT_WIDGETS_LIB -DQT_X11EXTRAS_LIB -DQT_XML_LIB -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=500 -Dkdeinit_kwin_EXPORTS -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -std=c++0x -fno-exceptions -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -O2 -g -DNDEBUG -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -I....

packages are built in release mode (but OBS adding -g makes it ~relwithdebinfo)
Comment 25 Luiz Angelo De Luca 2014-05-30 21:03:17 UTC
I noticed that if I add more desktops in systemsettings, all comes with the correct translation. The problem is only when profile is generated.
Comment 26 Thomas Lübking 2014-05-30 21:45:23 UTC
can someone try to inject a flush before deleting the string?

kwindowsystem.git, netwm.cpp:948

void NETRootInfo::setDesktopName(int desktop, const char *desktopName)
{
...
xcb_change_property(p->conn, XCB_PROP_MODE_REPLACE, p->root, net_desktop_names,
                        UTF8_STRING, 8, proplen, (const void *) prop);
+ xcb_flush(p->conn); 
delete [] prop;
}
Comment 27 Hrvoje Senjan 2014-05-31 01:35:37 UTC
no change
Comment 28 Thomas Lübking 2014-05-31 10:19:27 UTC
Hmmm ... on read?
What's the output of "xprop -root _NET_DESKTOP_NAMES"?
Comment 29 Hrvoje Senjan 2014-05-31 19:17:25 UTC
also good,
_NET_DESKTOP_NAMES(UTF8_STRING) = "Desktop 1"
Comment 30 Thomas Lübking 2014-05-31 20:59:27 UTC
eeewwww....

kwindowsystem.git,  netwm.cpp:358
        if (data) {
            const QByteArray ba = QByteArray::fromRawData(data, data[len - 1] ? len : len - 1);
            list = ba.split('\0');
+            if (list.count() == 1) {
+               QByteArray deepCopy(list.at(1).constData());
+                list.clear();
+                list << deepCopy;
+            }
        }
Comment 31 Hrvoje Senjan 2014-05-31 21:34:24 UTC
[KCrash Handler]
#5  data (this=0xbabababababababa) at /usr/include/qt5/QtCore/qarraydata.h:63
#6  data (this=0xbabababababababa) at /usr/include/qt5/QtCore/qarraydata.h:211
#7  constData (this=0x2234f18) at /usr/include/qt5/QtCore/qbytearray.h:451
#8  get_stringlist_reply (c=<optimized out>, cookie=..., cookie@entry=..., type=<optimized out>) at /home/hrvoje/Src/local/kwindowsystem/src/netwm.cpp:362
#9  0x00007f9127181618 in NETRootInfo::update (this=<optimized out>, properties=..., properties2=...) at /home/hrvoje/Src/local/kwindowsystem/src/netwm.cpp:2325
#10 0x00007f912718332c in NETRootInfo::NETRootInfo (this=0x2238b90, connection=<optimized out>, supportWindow=52428807, wmName=0x7f912a63e9ff "KWin", properties=..., windowTypes=..., states=..., properties2=..., actions=..., screen=0, doActivate=true) at /home/hrvoje/Src/local/kwindowsystem/src/netwm.cpp:698
#11 0x00007f912a4f38c9 in RootInfo (scr=0, actions=..., properties2=..., states=..., types=..., properties=..., name=0x7f912a63e9ff "KWin", w=52428807, this=0x2238b90) at /usr/src/debug/kwin-4.95.0~20140530~0bf9ed5/netinfo.cpp:143
#12 KWin::RootInfo::create () at /usr/src/debug/kwin-4.95.0~20140530~0bf9ed5/netinfo.cpp:128
#13 0x00007f912a4cf787 in KWin::Workspace::init (this=this@entry=0x216cfa0) at /usr/src/debug/kwin-4.95.0~20140530~0bf9ed5/workspace.cpp:264
#14 0x00007f912a4d13b6 in KWin::Workspace::Workspace (this=0x216cfa0, restore=<optimized out>) at /usr/src/debug/kwin-4.95.0~20140530~0bf9ed5/workspace.cpp:232
#15 0x00007f912a5016cb in operator() (__closure=<synthetic pointer>) at /usr/src/debug/kwin-4.95.0~20140530~0bf9ed5/main.cpp:271
#16 call (arg=<optimized out>, f=...) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:502
#17 call<QtPrivate::List<>, void> (arg=<optimized out>, f=...) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:559
#18 QtPrivate::QFunctorSlotObject<KWin::Application::start()::__lambda8, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=<optimized out>, this_=<optimized out>, r=<optimized out>, a=<optimized out>, ret=<optimized out>) at /usr/include/qt5/QtCore/qobject_impl.h:200
#19 0x00007f9122061283 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib64/libQt5Core.so.5
#20 0x00007f9127163952 in KSelectionOwner::Private::claimSucceeded (this=0x20b6760) at /home/hrvoje/Src/local/kwindowsystem/src/kselectionowner.cpp:180
#21 0x00007f9127164169 in KSelectionOwner::filterEvent (this=0x20b6540, ev_P=<optimized out>) at /home/hrvoje/Src/local/kwindowsystem/src/kselectionowner.cpp:398
#22 0x00007f912202fbe0 in QAbstractEventDispatcher::filterNativeEvent(QByteArray const&, void*, long*) () from /usr/lib64/libQt5Core.so.5
#23 0x00007f91144eb078 in QXcbConnection::handleXcbEvent(xcb_generic_event_t*) () from /usr/lib64/qt5/plugins/platforms/libqxcb.so
#24 0x00007f91144ec3eb in QXcbConnection::processXcbEvents() () from /usr/lib64/qt5/plugins/platforms/libqxcb.so
#25 0x00007f9122062406 in QObject::event(QEvent*) () from /usr/lib64/libQt5Core.so.5
#26 0x00007f9122cd2ecc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib64/libQt5Widgets.so.5
#27 0x00007f9122cd7c46 in QApplication::notify(QObject*, QEvent*) () from /usr/lib64/libQt5Widgets.so.5
#28 0x00007f9122032825 in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib64/libQt5Core.so.5
#29 0x00007f9122034677 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib64/libQt5Core.so.5
#30 0x00007f9122087694 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5
#31 0x00007f911453b0fd in QUnixEventDispatcherQPA::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt5/plugins/platforms/libqxcb.so
#32 0x00007f912203073b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/libQt5Core.so.5
#33 0x00007f9122037d96 in QCoreApplication::exec() () from /usr/lib64/libQt5Core.so.5
#34 0x00007f912a503a95 in kdemain (argc=3, argv=0x7fff553db588) at /usr/src/debug/kwin-4.95.0~20140530~0bf9ed5/main.cpp:554
#35 0x00007f912a0f2b05 in __libc_start_main () from /lib64/libc.so.6
#36 0x00000000004008de in _start () at ../sysdeps/x86_64/start.S:122
Comment 32 Thomas Lübking 2014-05-31 21:57:23 UTC
Sorry, i'm stupid - ".at(0)" will certainly work MUCH better ;-)
Comment 33 Hrvoje Senjan 2014-05-31 22:02:56 UTC
not only that, but i have now a recognizable name - 'Desktop 1' ;-)
Comment 34 Thomas Lübking 2014-05-31 22:33:44 UTC
Ok, let's fix the bug status then - this is not "minor" at all.

----------

The problem here is that QByteArray::fromRawData() is "implicitly shared" with the provided POD and that QByteArray::split() will basically just "return QList<QByteArray>() << *this;" if the BA doesn't contain the split parameter ("\0"), so you get a QBA List that only contains the QBA with the shared POD ... which is freed before the return.
So we need an explicit deep copy of the QBA in the list instead.

Some compiler/parameter combo apparently does not only free() but also EEEEEEEEEEEEEEEE the first 16 bytes of the freed data, but the data is in general invalid and can take any content any time.
Comment 35 Hrvoje Senjan 2014-06-01 01:44:31 UTC
(In reply to comment #34)
> Some compiler/parameter combo apparently does not only free() but also
> EEEEEEEEEEEEEEEE the first 16 bytes of the freed data, but the data is in
> general invalid and can take any content any time.

tried building (w/o patch) kwindowsystem:
omitting any 'custom' flag
building in debug mode
-> EEEEEEEEEE

i wonder is it something in Qt setup then?
Comment 36 Thomas Lübking 2014-06-01 06:41:41 UTC
could be hardcoded/patched into glibc then - do we have any non-suse eeeeeeeeeets?

(just to cause no irritation in this thread:
bug is clearly in kwindowsystem. whatever whoever does on free'd memory is just fine)
Comment 37 Hrvoje Senjan 2014-07-24 23:05:43 UTC
one new note (maybe not unexpected);
if i add
[Desktops]
Number=2
to /etc/xdg/kwinrc, and test with a clean config, both desktops are correctly named
Comment 38 Hrvoje Senjan 2014-11-28 17:51:06 UTC
i can't reproduce anymore with current master + Qt 5.4
Comment 39 Justin Zobel 2021-03-09 05:54:08 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.
Comment 40 henriquemuzzi9 2024-04-21 15:32:23 UTC
Comment on attachment 86883 [details]
Localization section in systemsettings

sadsgrhtk,n
Comment 41 henriquemuzzi9 2024-04-21 15:33:27 UTC
Created attachment 168749 [details]
aDSFDHNM

XAFD