Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
Ubuntu 15.10
$ cordova -v
6.1.1$ nodejs -v
v6.2.0
Description
I'm working on an (ubuntu) plugin that is thread-safe but was causing segfaults everytime I'd (asynch) load a new page or component.
Trying to run it under gdb, I found that as long as I avoided moving around there were no issues, but every load of a new page or (html) popup would spawn a new thread and somehow re-init my plugin (which is stateful and needs to stay alive).
The traces looked like so:
======================== snip ========================
[New Thread 0x7fffcf8a9700 (LWP 26618)]
Debug: Enable plugin "com.example.MyPlugin"
Debug: Enable plugin "File"
Debug: Enable plugin "Notification"
Debug: Enable plugin "com.cordova.Device"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/logo.png"
[Thread 0x7fffcf8a9700 (LWP 26618) exited]
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/cordova.js"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/cordova_plugins.js"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/pageA.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/pageB.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/index.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/libcoreplugins.so"
[New Thread 0x7fffcf8a9700 (LWP 26619)]
[Thread 0x7fffcf8a9700 (LWP 26619) exited]
Debug: Enable plugin "com.example.MyPlugin"
Debug: Enable plugin "File"
Debug: Enable plugin "Notification"
Debug: Enable plugin "com.cordova.Device"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/logo.png"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/cordova.js"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/cordova_plugins.js"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/pageA.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/pageB.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/index.html"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/libcoreplugins.so"
[New Thread 0x7fffcf8a9700 (LWP 26621)]
Debug: Enable plugin "com.example.MyPlugin"
Debug: Enable plugin "File"
Debug: Enable plugin "Notification"
Debug: Enable plugin "com.cordova.Device"
Debug: Testing "/path/to/project/platforms/ubuntu/native/prefix/www/logo.png"
[Thread 0x7fffcf8a9700 (LWP 26621) exited]
Program received signal SIGSEGV, Segmentation fault.
======================== /snip ========================
I tracked down the reason for all the (redundant?) "Enable plugin" events to initPlugins() calls in loadFinished() (in the Ubuntu package/src/cordova.cpp):
void Cordova::loadFinished(bool ok) {
Q_UNUSED(ok)
initPlugins();
}
I'm not certain what the purpose of this call is, as the init already happens in Cordova::appLoaded().
In any case, I've disabled the call and loadFinished() and my plugin is both persistent and has stopped causing segfaults.
Is there a reason to keep this initPlugins() call in loadFinished()? If so, could we add some kind of
virtual bool loadOnlyOnce()
{ return false;}to the CPlugin base class so we can check for and skip plugins that override it? Or is there some other technique I'm not aware of?
Thanks,
Pat Deegan