This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Plasmoids as separate processes

28

Votes
41
13
Tags: plasma plasma plasma
(comma "," separated)
The User
KDE Developer
Posts
647
Karma
0
OS
KJS ~ Javascript ~ ECMAScript ~ QtScript
KJS != QtScript
It's not bad to have Script-Plasmoids. But C++ is simply faster.
With signal() we could prevent a crash of the whole application with little overhead. That's a better solution then scripting or multiple processes. And it could also show a KCrash-message for reporting the Bug. Should there be an own thread for this idea?

Last edited by The User on Mon Apr 27, 2009 5:58 pm, edited 1 time in total.
User avatar
Ignacio Serantes
Registered Member
Posts
453
Karma
1
OS
HappySmileMan wrote: got is here.


I read some of the posts, very interesting but this from Aaron Seigo shines:

"the above applies only to scripted plugins, not C++ plugins. C++ can crash the
application, but the plasma shell restarts itself."

So scripted plugins are safe but C++ not then, why we must use C++ to doing a stupid plasmoid that can be writen in javascript? I supposed that writing code in C++ must be "cool" regardless of the number of memory leaks and the quality of the programmer. Please note that I pretend to be sarcastic ;).

On the other side, "but the plasma shell restarts itself" as a solution is... well..., I have no words. I'm considering use the same argument with my customers ;).
customer: Ignacio, your program crash and I lost all my open invoice.
me: Yes, but the programs restarts again with an empty invoice. I do not understand why you complaints.

I think that I will stop using plasmoids written in C++ with exception of Panel and Folder View. The last was not very stable in the past but now it seems to be rock solid, at least I can use nepomuk without a plasma crash :).

Last edited by Ignacio Serantes on Tue Apr 28, 2009 7:58 am, edited 1 time in total.


Ignacio Serantes, proud to be a member of KDE forums since 2008-Nov.
The User
KDE Developer
Posts
647
Karma
0
OS
Hey Ignacio! (and all the others)
It's possible to stop a crash!
I'll say Python but it could be any scripting language in this example:
A common error is a "division by zero". In Python you'll gett a "ZeroDivisionError". The execution can't be continued. It's like a crash on script-level. Maybe more often than divisions by zero you have SIGSEGV, null-pointer-dereference. This means a unbound reference to some data was used to access some data. It's like sending a letter without specifying the adress. In Python you can also try to dereference the "None"-reference. You'll get an error because the None-type can't be used for anything. Again the Python-Plasmoid will crash but the process will survive. In C++ you would get SIGSEGV.
But!
In C there is a function signal() (try `man signal`). You can specify the code executed after a SIGSEGV or anything else. And there is a second error-concept (not signals) in C++ called exceptions. Also a "thrown" exception will roll back the execution until causes SIGABORT. But exceptions can be stopped. When the applicatiiion receives a signal you can throw an exception. In another location in the program the exception can be handled, e.g. in Corona. So the crash would be stopped but Corona could also show a KCrash-dialog for reporting the bug and could remove the Plasmoid. Plasma would continue running.

The User

Edit:
C++-Hackers, try it!
Somebody gave me the information and a few minutes ago I could write some code using those exceptions. It's pretty simple:
Code: Select all
#include                                     
#include                                     
#include                                   
using namespace std;                                   

struct seg_error : public runtime_error
{                                     
  int key;                             
  seg_error(string message = "", int _key = 0) : runtime_error(message), key(_key)
  {}
};

void segmentationFault(int key) throw(seg_error)
{
        throw seg_error("Segmentation Fault! Error key is: ", key);
}

int main()
{
        signal(SIGSEGV, segmentationFault);
        try
        {
                int *x = 0;
                cout << *x;  // Impossible, crash!
        }
        catch(seg_error e)
        {
                cout << e.what() << e.key << endl;
        }
        cout << "still alive..." << endl;
        return 0;
}


So you can execute it:
Code: Select all
g++ -o catchsigsegv ./catchsigsegv.cpp -fnon-call-exceptions -fasynchronous-unwind-tables -funwind-tables
./catchsigsegv

Last edited by The User on Mon Apr 27, 2009 9:37 pm, edited 1 time in total.
User avatar
Ignacio Serantes
Registered Member
Posts
453
Karma
1
OS
The User wrote:Hey Ignacio! (and all the others)
It's possible to stop a crash!


I'm not C, or C++ programmer so I can't evaluate if this is true or not but, if it's possible I wonder why Plasma don't implement a mecanism like this. Well, it has the wonderful restart but a second option don't sounds bad ;).


Ignacio Serantes, proud to be a member of KDE forums since 2008-Nov.
User avatar
redsteakraw
Registered Member
Posts
12
Karma
0
OS
I think there is a compromise; allot of the C++ plasmoids are stable now so running them as a separate process would be a waste of resources. I think the ideal solution is to have a separate process (as Option) called plasma-unstable that holds all plasmoids that aren't scripts and aren't considered stable. This will allow the user to add new unstable plasmoids without crashing plasma as a whole.
The User
KDE Developer
Posts
647
Karma
0
OS
But a Process-Plasmoid would need ugly code without bringing new features...
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
It would probably be best to implement the exception handling at the KDE Libs or Qt level instead of in each application.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
The User
KDE Developer
Posts
647
Karma
0
OS
I have created an idea-thread: [KDELibs] Catch Crashes in Modular Applications

Last edited by The User on Tue Apr 28, 2009 12:16 pm, edited 1 time in total.
User avatar
waldelf
Registered Member
Posts
333
Karma
0
OS

Plasmoids as separate processes

Sat Oct 31, 2009 10:18 pm
plasma definitely should not crash because of a single plasmoid... but.. i don't think a single process for every plasmoid is a good solution.. (in fact it sounds somehow horrible to me)

there has to be another professional way ..


Kubuntu 12.04 x64 | KDE SC 4.8
Nvidia 8800 GTS | Core2Duo E6600 | 4 GB RAM
User avatar
Madman
Registered Member
Posts
593
Karma
1
OS

Plasmoids as separate processes

Sat Oct 31, 2009 11:18 pm
Like, "Make the plasmoids more stable before including them in a default install", perhaps?

In fact, I find I get very, VERY few plasma crashes as of late... I can't remember the last plasma crash I had, and that's something of a feat.


Madman, proud to be a member of KDE forums since 2008-Oct.
User avatar
TheBlackCat
Registered Member
Posts
2945
Karma
8
OS

Plasmoids as separate processes

Sun Nov 01, 2009 1:02 am
Aaron has said that this is infeasible and won't happen.


Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot]