Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dead lock happens when calling Runtime.getRuntime().exit(0); #1328

Closed
beeender opened this issue Jul 29, 2015 · 0 comments
Closed

Dead lock happens when calling Runtime.getRuntime().exit(0); #1328

beeender opened this issue Jul 29, 2015 · 0 comments
Assignees
Labels

Comments

@beeender
Copy link
Contributor

Issue first reported on SO http://stackoverflow.com/questions/31583359/realm-and-runtime-getruntime-exit0 .

When calling Runtime.getRuntime().exit(0); with Realm opened before, finalizer won't stop running. Lock is waiting forever, process cannot exist.

Below code to reproduce this error:

Realm realm = Realm.getInstance(this);
realm.close();
Runtime.getRuntime().exit(0);

And in the logcat, infinity logs comes as below:

D/dalvikvm( 5070): GC_EXPLICIT freed 0K, 6% free 6379K/6716K, paused 2ms+3ms, total 19ms
D/dalvikvm( 5070): GC_EXPLICIT freed 0K, 6% free 6379K/6716K, paused 2ms+2ms, total 19ms
D/dalvikvm( 5070): GC_EXPLICIT freed 0K, 6% free 6379K/6716K, paused 2ms+2ms, total 18ms
@beeender beeender self-assigned this Jul 29, 2015
beeender added a commit that referenced this issue Jul 29, 2015
1. Create a service in a standalone process.
2. Make helpers to play with the service for testing.
3. Watch dog support for the testing.
4. Test case to reproduce #1328, Process is deadly locked when exit(0)
    called.
beeender added a commit that referenced this issue Jul 29, 2015
To fix #1328

When System.exit(0) called, shutdown hook will be run. There is no
guarantee in this case GC will collect everything. So a dead lock will
happen here.

Remove this part of code since the core side can ensure the integrity of
db file when other resource is not released.
beeender added a commit that referenced this issue Aug 4, 2015
1. Create a service in a standalone process.
2. Make helpers to play with the service for testing.
3. Watch dog support for the testing.
4. Test case to reproduce #1328, Process is deadly locked when exit(0)
    called.
beeender added a commit that referenced this issue Aug 4, 2015
To fix #1328

When System.exit(0) called, shutdown hook will be run. There is no
guarantee in this case GC will collect everything. So a dead lock will
happen here.

Remove this part of code since the core side can ensure the integrity of
db file when other resource is not released.
beeender added a commit that referenced this issue Aug 4, 2015
1. Create a service in a standalone process.
2. Make helpers to play with the service for testing.
3. Watch dog support for the testing.
4. Test case to reproduce #1328, Process is deadly locked when exit(0)
    called.
@beeender beeender removed the P1 label Aug 4, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant