Bug 4294 - some modules aren't deactivated
: some modules aren't deactivated
Status: RESOLVED FIXED
: GSI C
Authentication
: 4.0.1
: PC All
: P3 normal
: 4.0.5
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2006-03-15 23:45 by
Modified: 2008-08-11 15:19 (History)


Attachments
only call activate from once call when not already activated (525 bytes, patch)
2006-03-16 21:56, Sam Meder
Details
patch(100% thread safe) (930 bytes, patch)
2006-03-16 23:33, Tatsuhiko Inoue
Details


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2006-03-15 23:45:08
First call of gss_acquire_cred() activates GLOBUS_GSI_GSSAPI_MODULE.
But last call of gss_release_cread() doesn't deactivates GLOBUS_GSI_GSSAPI_MODULE.

Thus, some modules aren't deactivated when gss_aquire_cred() is used.
------- Comment #1 From 2006-03-16 07:16:11 -------
First off a question:

Do you explicitly call globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE) and 
globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE) around these GSSAPI calls?

If not then this is expected behavior and there is nothing we can do about it (since without explicit 
activation/deactivation we can't know the scope of your GSSAPI usage), if yes then I'm not sure what is 
happening and we will have to investigate.

/Sam
------- Comment #2 From 2006-03-16 21:03:46 -------
Yes, I explicitly call globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE) and 
globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE).

But gss_acquire_cred() calls globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE),
using globus_thread_once().

Therefore, globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE) is called twice,
but globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE) is called once.

Thus globus_l_gsi_gssapi_deactivate() is not called in
globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE).
------- Comment #3 From 2006-03-16 21:50:47 -------
You're right, this was actually changed due to bug 1740. Can you try the
attached patch to see if it helps? 
(might not be 100% thread safe, but should make it work unless you do module
activiation from separate 
threads)

/Sam
------- Comment #4 From 2006-03-16 21:56:19 -------
Created an attachment (id=882) [details]
only call activate from once call when not already activated
------- Comment #5 From 2006-03-16 21:57:27 -------
To refine the threads statement: It should work unless mixing implicit and
explicit activation in different 
threads.

/Sam
------- Comment #6 From 2006-03-16 23:19:31 -------
Thank you.

I think that it is possible to make the process of that patch 100% thread-safe
with the following way.

 - globus_l_gsi_gssapi_activate() call globus_thread_once(), using the function
doing nothing.
------- Comment #7 From 2006-03-16 23:33:00 -------
Created an attachment (id=883) [details]
patch(100% thread safe)

I think that it is 100% thread safe.
------- Comment #8 From 2006-03-17 00:14:15 -------
Interesting approach, but I think that recursively calling e.g. pthread_once on
the same control variable 
will deadlock (this would happen when doing implicit activation). For example,
the glibc pthread_once 
implementation does the following:

  /* If init_routine is being called from another routine, wait until           
     it completes. */
  while ((*once_control & 3) == IN_PROGRESS) {
    pthread_cond_wait(&once_finished, &once_masterlock);
  }
  /* Here *once_control is stable and either NEVER or DONE. */
  if (*once_control == NEVER) {
    *once_control = IN_PROGRESS | fork_generation;
    pthread_mutex_unlock(&once_masterlock);
    pthread_cleanup_push(pthread_once_cancelhandler, once_control);
    init_routine();
    pthread_cleanup_pop(0);
    pthread_mutex_lock(&once_masterlock);
    WRITE_MEMORY_BARRIER();
    *once_control = DONE;
    state_changed = 1;
  }
  pthread_mutex_unlock(&once_masterlock);

  if (state_changed)
    pthread_cond_broadcast(&once_finished);

This would (I think) get stuck in the first while loop.

/Sam
------- Comment #9 From 2007-08-07 08:20:30 -------
*** Bug 4287 has been marked as a duplicate of this bug. ***
------- Comment #10 From 2007-08-07 08:34:23 -------
I think the fix for bug http://bugzilla.globus.org/globus/show_bug.cgi?id=5279
fixes the thread-safety issues in the patches. If the module is activated
explicitly before any implicit activations, then the implicit activation will
not be done.  Had I noticed this bug when fixing that issue, I might have
looked closer at this report and used one of the patches here :)

joe