Re: Library reload?

364 views
Skip to first unread message

Steven Venter

unread,
May 29, 2013, 7:00:57 AM5/29/13
to andro...@googlegroups.com

I don't think so as the apk contains a statically linked library containing all other libraries.


On Tuesday, May 28, 2013 4:56:05 PM UTC+2, Stanislav Bardyuk wrote:
Hi,

I'm using third-party native library that causes Fatal signal 11 (SIGSEGV) from time to time and closes current activity.
But after the activity is restarted native methods does not function properly, which causes additional crashes.

Is there any way reload native library after crash, so at least the application should not be restarted to continue.
At least that would be temporary workaround until the problems in native library are resolved.
 
Thanks.


David Turner

unread,
May 30, 2013, 7:43:22 AM5/30/13
to andro...@googlegroups.com
On Tue, May 28, 2013 at 4:56 PM, Stanislav Bardyuk <kod...@gmail.com> wrote:
Hi,

I'm using third-party native library that causes Fatal signal 11 (SIGSEGV) from time to time and closes current activity.

Unless you have installed a specific signal handler, a SIGSEGV will not only "close the current activity" but immediately kill the current process.
When the activity is restarted, a new process is loaded. Do you always reload your third-party native library (e.g. in a static { ... } class initialization block), or do this under certain circumstances. If the latter, that could explain what's happening here (i.e. the activity is restarted in a way that you didn't foresee).
 
But after the activity is restarted native methods does not function properly, which causes additional crashes.

Is there any way reload native library after crash, so at least the application should not be restarted to continue.
At least that would be temporary workaround until the problems in native library are resolved.
 
Thanks.



--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Stanislav Bardyuk

unread,
May 30, 2013, 7:59:03 AM5/30/13
to andro...@googlegroups.com

Unless you have installed a specific signal handler, a SIGSEGV will not only "close the current activity" but immediately kill the current process.
When the activity is restarted, a new process is loaded. Do you always reload your third-party native library (e.g. in a static { ... } class initialization block), or do this under certain circumstances. If the latter, that could explain what's happening here (i.e. the activity is restarted in a way that you didn't foresee).

Nope I don't have any signal handlers in my code.
Actually native library is loaded in previous activity (parent to the one that crashes), as it does some initialization stuff.

So in situation when native lib crashes and current process is terminated, if the activity is started once again and System.loadLibrary() is called every time, it will reload the lib?
What if there was no crash but the activity was restarted?

David Turner

unread,
May 30, 2013, 8:17:36 AM5/30/13
to andro...@googlegroups.com
On Thu, May 30, 2013 at 1:59 PM, Stanislav Bardyuk <kod...@gmail.com> wrote:

Unless you have installed a specific signal handler, a SIGSEGV will not only "close the current activity" but immediately kill the current process.
When the activity is restarted, a new process is loaded. Do you always reload your third-party native library (e.g. in a static { ... } class initialization block), or do this under certain circumstances. If the latter, that could explain what's happening here (i.e. the activity is restarted in a way that you didn't foresee).

Nope I don't have any signal handlers in my code.
Actually native library is loaded in previous activity (parent to the one that crashes), as it does some initialization stuff.


I guess that's the root of the problem. You're restarting a process directly to the second activity, the first one hasn't been created in this new process, hence your library was never loaded.
 
So in situation when native lib crashes and current process is terminated, if the activity is started once again and System.loadLibrary() is called every time, it will reload the lib?

Yes, that's the purpose of System.loadLibrary(), of course you better be sure that this happens "every time" it's needed.
 
What if there was no crash but the activity was restarted?

Then the library is still loaded in memory. 

Stanislav Bardyuk

unread,
May 30, 2013, 8:20:48 AM5/30/13
to andro...@googlegroups.com
Thanks for your reply.
Now it seems I understand how this works.

Stanislav Bardyuk

unread,
May 30, 2013, 8:23:59 AM5/30/13
to andro...@googlegroups.com
And it does work as I wanted.
If loadLibrary() is called every time, even after native crash it works after being restarted.
Thanks for your help!
Reply all
Reply to author
Forward
0 new messages