Bug 366164 - Plasmashell crash when plasma-nm applet exists trying to connect to a VPN
Summary: Plasmashell crash when plasma-nm applet exists trying to connect to a VPN
Status: RESOLVED FIXED
Alias: None
Product: plasma-nm
Classification: Plasma
Component: general (show other bugs)
Version: 5.7.2
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: Lukáš Tinkl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-27 13:23 UTC by whites11
Modified: 2016-09-25 12:39 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
patch that fixes this issue (930 bytes, patch)
2016-07-28 09:02 UTC, whites11
Details

Note You need to log in before you can comment on or make changes to this bug.
Description whites11 2016-07-27 13:23:49 UTC
Hello
when I try to connect to a VPN using networkmanager the whole plasmashell crashes.
The crash happens even if I have plasma-nm applet in my system and connect to the VPN using a cli tool such as nmtui or nm-cli

this is the backtrace

Thread 1 "plasmashell" received signal SIGSEGV, Segmentation fault.
0x00007fff39443179 in NetworkStatus::<lambda(const Ptr&, const Ptr&)>::operator() (__closure=<optimized out>, right=..., left=...)
    at /home/whites/Downloads/plasma-nm/src/plasma-nm-5.7.2/libs/declarative/networkstatus.cpp:168
168             return NetworkStatus::connectionTypeToSortedType(left->type()) <= NetworkStatus::connectionTypeToSortedType(right->type());

this bug is quite recent for me (and I used the VPN stuff for years).
Please ask if you need more info.

thanks

Reproducible: Always

Steps to Reproduce:
1. add the plasma-nm applet to the panel
2. open the applet and click on the "connect" button of the VPN OR try to connect to the VPN using a CLI tool such as nm-tui

Actual Results:  
plasmashell crashes (but the VPN connects successfully)

Expected Results:  
plasma should not have crashed
Comment 1 Jan Grulich 2016-07-27 14:56:48 UTC
Could you please provide complete backtrace?
Comment 2 whites11 2016-07-27 14:58:56 UTC
unluckily that's the complete backtrace.
I got it using gdb on plasmashell.
I don't know how to get a more verbose backtrace.
can you help me?
Comment 3 Lamarque V. Souza 2016-07-27 17:58:39 UTC
Do you know the compiler version used to compile Plasma NM? That can be a compiler bug.
Comment 4 whites11 2016-07-27 18:02:44 UTC
(In reply to Lamarque V. Souza from comment #3)
> Do you know the compiler version used to compile Plasma NM? That can be a
> compiler bug.

The bug First happened with the distribution packages (arch). As soon as i get back to my notebook I'll tell you my GCC version
Comment 5 Lamarque V. Souza 2016-07-27 18:12:45 UTC
Hmmm std::sort() expects the lambda to return true if left is less than right, but it returns true when they are equal too. According to this [1] that can lead to an unsorted array internally and that can lead to a crash like this one. Can you recompile the lamba to use < instead of <= and test if it solves your problem?

[1] http://stackoverflow.com/questions/7767998/should-stdsort-work-with-lambda-function-in-c0x-c11
Comment 6 whites11 2016-07-27 20:07:45 UTC
Will try asap(In reply to Lamarque V. Souza from comment #5)
> Hmmm std::sort() expects the lambda to return true if left is less than
> right, but it returns true when they are equal too. According to this [1]
> that can lead to an unsorted array internally and that can lead to a crash
> like this one. Can you recompile the lamba to use < instead of <= and test
> if it solves your problem?
> 
> [1]
> http://stackoverflow.com/questions/7767998/should-stdsort-work-with-lambda-
> function-in-c0x-c11

Will try asap
Comment 7 whites11 2016-07-28 09:02:58 UTC
Created attachment 100347 [details]
patch that fixes this issue
Comment 8 whites11 2016-07-28 09:03:44 UTC
great catch @Lamarque V. Souza
your suggestion fixes the problem for me.
I attached the patch I applied.
Comment 9 Lamarque V. Souza 2016-07-28 11:57:46 UTC
Git commit 669c25e2153c64733ed6f64c9600aa182c0eb156 by Lamarque V. Souza.
Committed on 28/07/2016 at 11:57.
Pushed by lvsouza into branch 'master'.

Fix crash when activating VPN connection.

std::sort() expects the lambda to return true if left is less than right, but
it returns true when they are equal too. According to this [1] that can lead to
an unsorted array internally and that can lead to a crash like this one.

[1] http://stackoverflow.com/questions/7767998/should-stdsort-work-with-lambda-function-in-c0x-c11

M  +1    -1    libs/declarative/networkstatus.cpp

http://commits.kde.org/plasma-nm/669c25e2153c64733ed6f64c9600aa182c0eb156
Comment 10 Lamarque V. Souza 2016-07-28 13:21:33 UTC
Git commit e6e341a5c2c1bc9292e1e67603ea52795e33fe8a by Lamarque V. Souza.
Committed on 28/07/2016 at 13:20.
Pushed by lvsouza into branch 'Plasma/5.7'.

Fix crash when activating VPN connection.

std::sort() expects the lambda to return true if left is less than right, but
it returns true when they are equal too. According to this [1] that can lead to
an unsorted array internally and that can lead to a crash like this one.

[1] http://stackoverflow.com/questions/7767998/should-stdsort-work-with-lambda-function-in-c0x-c11

M  +1    -1    libs/declarative/networkstatus.cpp

http://commits.kde.org/plasma-nm/e6e341a5c2c1bc9292e1e67603ea52795e33fe8a