You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Dennis Geurts (JIRA)" <ji...@apache.org> on 2009/10/27 09:32:59 UTC

[jira] Created: (FELIX-1812) deadlock on System.exit()

deadlock on System.exit()
-------------------------

                 Key: FELIX-1812
                 URL: https://issues.apache.org/jira/browse/FELIX-1812
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: felix-2.0.1
            Reporter: Dennis Geurts


A deadlock occurs if System.exit() is called during startup of the Apache Framework.

additional information:

We call System.exit() during the BundleActivator.start(BundleContext) method. 

I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (FELIX-1812) deadlock on System.exit()

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls resolved FELIX-1812.
-------------------------------

       Resolution: Fixed
    Fix Version/s: felix-2.2.0

As a side effect, FELIX-1816 makes it possible again to call System.exit inside an activator.start method while the framework is still in the STARTING state. However, the framework will not be shutdown when the jvm exits.

Please close this issue if the current trunk works for you.

> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.1
>            Reporter: Dennis Geurts
>            Assignee: Karl Pauls
>             Fix For: felix-2.2.0
>
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (FELIX-1812) deadlock on System.exit()

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls reopened FELIX-1812:
-------------------------------


Reopen this issue as closer investigation releated to FELIX-1816 indicates a different result. 

> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.1
>            Reporter: Dennis Geurts
>            Assignee: Karl Pauls
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-1812) deadlock on System.exit()

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard S. Hall updated FELIX-1812:
-----------------------------------

    Fix Version/s:     (was: felix-2.0.3)
                   felix-3.0.0

> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.1
>            Reporter: Dennis Geurts
>            Assignee: Karl Pauls
>             Fix For: felix-3.0.0
>
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (FELIX-1812) deadlock on System.exit()

Posted by "Dennis Geurts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dennis Geurts reopened FELIX-1812:
----------------------------------


I'm reopening this is issue because I think one should be able to call System.exit / SystemBundle.stop anytime.

Furthermore: 
- As mentioned in a previous comment by karlp: "this is something one should never do": I wonder why, I haven't 
  found any clue in the spec that validates this remark. This btw also immediately disqualifies calling System.exit in the constructor of a service,
  if you are using the dependency manager, the init, start, stop, destroy callbacks. If you use a ServiceTracker, his callbacks are also 
  "out of bounds". It becomes less and less clear to me where one will be able to call System.exit such that it _immediately_ stops the java process

- If I replace the System.exit call with the more osgi-friendly call: SystemBundle.stop() the same deadlock occurs.
  the spec is more clear about this: It poses no restrictions as to where one is 'allowed' to call this method. Also the spec
  says the following: 
     1. The system bundle enters the STOPPING state.
     (great, I like that!)

     2. All ACTIVE bundles are stopped as described in the Bundle.stop method, except that their persistently recorded state indicates that they must be restarted 
     when the Framework is next started...
     (this is exactly the behavior I want: all bundles that have been started up to that moment must stop, and bundle that haven't been started yet do not get started)

- Doing this asynchronously does not prevent other bundles from being started. This is something I definitely do not want.





> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.1
>            Reporter: Dennis Geurts
>            Assignee: Karl Pauls
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (FELIX-1812) deadlock on System.exit()

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls closed FELIX-1812.
-----------------------------

    Resolution: Invalid
      Assignee: Karl Pauls

Looking at the stacktrace it looks to me like you are calling System.exit() inside the Activator.start() method of one of your bundles. This is just nothing you should ever do but if so, then you basically have two options to make this work without the deadlock. 

1) You can disable the shutdown hook we have in our launcher by using -Dfelix.shutdown.hook=false

2) Do the call to System.exit() asynchronously i.e., fork another thread inside your activator to do the deed.

I will close this issue as invalid for now. Please reopen in case you disagree

> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.1
>            Reporter: Dennis Geurts
>            Assignee: Karl Pauls
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (FELIX-1812) deadlock on System.exit()

Posted by "Dennis Geurts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dennis Geurts closed FELIX-1812.
--------------------------------


Excellent, this is what I want. 

As a sidenote:

Calling System.exit() during activation of a bundle is not something we do regularly ;-). In this specific case, the bundle calling
System.exit() is part of a more elaborate licensing scheme. If we detect a situation where no valid license can be obtained, we really
_do_ want to (be able to) exit the java process immediately. It is therefore sub-optimal to say the least to delay the exit until after the complete framework
has come up, or to delegate this to another thread (for obvious reasons).

Great that this functionality has become been made  available!

> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.1
>            Reporter: Dennis Geurts
>            Assignee: Karl Pauls
>             Fix For: felix-2.2.0
>
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-1812) deadlock on System.exit()

Posted by "Dennis Geurts (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dennis Geurts updated FELIX-1812:
---------------------------------

    Attachment: Activator.java
                trace.log
                felix-framework-2.0.1.tar.gz

Please find a configured felix framework for reproduction. It should be possible to untar it, enter the expanded directory, then run using 'java -jar bin/felix.jar'

trace.log contains the stacktrace.
Activator.java is the source file, included in the net.luminis.launchtest bundle

> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.1
>            Reporter: Dennis Geurts
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-1812) deadlock on System.exit()

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard S. Hall updated FELIX-1812:
-----------------------------------

    Fix Version/s: framework-3.2.0
                       (was: framework-3.0.0)

> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-2.0.1
>            Reporter: Dennis Geurts
>            Assignee: Karl Pauls
>             Fix For: framework-3.2.0
>
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (FELIX-1812) deadlock on System.exit()

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls reopened FELIX-1812:
-------------------------------


I re-open this issue as I really don't like the solution (and it makes various other cases fail). I will have to get back to this and fix it correctly by introducing timeouts or something. The result for this case would be the same I imagine but for now i will rollback.

> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.1
>            Reporter: Dennis Geurts
>            Assignee: Karl Pauls
>             Fix For: felix-2.2.0
>
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-1812) deadlock on System.exit()

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770845#action_12770845 ] 

Karl Pauls commented on FELIX-1812:
-----------------------------------

If you want calls to System.exit from a bundleactivator.start to work then you will have to disable the shutdown hook if you are using our launcher. This has nothing to do with the framework but with the shutdownhook in the launcher and that can be disabled. 

If you are seeing a deadlock in a call to systembundle.stop then this is an issue but it is not related to the shutdown hook and the system.exit. Please create a new issue and attach a stacktrace on that one where it shows that systembundle.stop does deadlock when called during startup from a bundleactivator.start and I will look into it. It can not be the same stacktrace as with the system.exit (as that is not being called anymore right :-)



> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.1
>            Reporter: Dennis Geurts
>            Assignee: Karl Pauls
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (FELIX-1812) deadlock on System.exit()

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-1812?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls closed FELIX-1812.
-----------------------------

    Resolution: Invalid

> deadlock on System.exit()
> -------------------------
>
>                 Key: FELIX-1812
>                 URL: https://issues.apache.org/jira/browse/FELIX-1812
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.1
>            Reporter: Dennis Geurts
>            Assignee: Karl Pauls
>         Attachments: Activator.java, felix-framework-2.0.1.tar.gz, trace.log
>
>
> A deadlock occurs if System.exit() is called during startup of the Apache Framework.
> additional information:
> We call System.exit() during the BundleActivator.start(BundleContext) method. 
> I will include a stacktrace and an example felix framework for reproduction.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.