Changeset 15131


Ignore:
Timestamp:
Dec 12, 2011, 3:52:51 AM (8 years ago)
Author:
gb
Message:

get_tcr(): on Win32, check the linear field of the presumed TCR
address, don't just return a (possibly uninitialized) address in
the TEB.

dequeue_tcr(): set tcr->linear to NULL on x8632, too.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/thread_manager.c

    r15095 r15131  
    8787  /* What if the suspend count is > 1 at this point ?  I don't think
    8888     that that matters, but I'm not sure */
    89   pcontext->ContextFlags = CONTEXT_ALL;
     89  pcontext->ContextFlags = CONTEXT_FULL;
    9090  rc = GetThreadContext(hthread, pcontext);
    9191  if (rc == 0) {
     
    788788  TCR_AUX(next)->prev = prev;
    789789  TCR_AUX(tcr)->prev = TCR_AUX(tcr)->next = NULL;
    790 #ifdef X8664
     790#ifdef X86
    791791  tcr->linear = NULL;
    792792#endif
     
    19001900  TCR *current = current_tcr;
    19011901#elif defined(WIN_32)
    1902   TCR *current = (TCR *)((char *)NtCurrentTeb() + TCR_BIAS);
     1902  TCR *current = ((TCR *)((char *)NtCurrentTeb() + TCR_BIAS))->linear;
    19031903#else
    19041904  void *tsd = (void *)tsd_get(lisp_global(TCR_KEY));
     
    20202020      return false;
    20212021    }
    2022     pcontext->ContextFlags = CONTEXT_ALL;
     2022    pcontext->ContextFlags = CONTEXT_FULL;
    20232023    rc = GetThreadContext(hthread, pcontext);
    20242024    if (rc == 0) {
     
    20272027    where = (pc)(xpPC(pcontext));
    20282028
     2029    if ((where >= restore_windows_context_start) &&
     2030        (where < restore_windows_context_end) &&
     2031        (tcr->valence != TCR_STATE_LISP)) {
     2032      Bug(NULL, "Forgot about this case ...");
     2033    }
    20292034    if (tcr->valence == TCR_STATE_LISP) {
    20302035      if ((where >= restore_windows_context_start) &&
     
    20612066          ResumeThread(hthread);
    20622067          SEM_WAIT_FOREVER(TCR_AUX(tcr)->suspend);
    2063           SuspendThread(hthread);
    2064           /* The thread is either waiting for its resume semaphore to
    2065              be signaled or is about to wait.  Signal it now, while
    2066              the thread's suspended. */
    2067           SEM_RAISE(TCR_AUX(tcr)->resume);
    2068           pcontext->ContextFlags = CONTEXT_ALL;
    2069           GetThreadContext(hthread, pcontext);
     2068          pcontext = NULL;
    20702069        }
    20712070      }
     
    21942193    HANDLE hthread = (HANDLE)(TCR_AUX(tcr)->osid);
    21952194
     2195
     2196    TCR_AUX(tcr)->suspend_context = NULL;
    21962197    if (context) {
    2197       context->ContextFlags = CONTEXT_ALL;
    2198       TCR_AUX(tcr)->suspend_context = NULL;
    2199       SetThreadContext(hthread,context);
     2198      if (tcr->valence == TCR_STATE_LISP) {
     2199        rc = SetThreadContext(hthread,context);
     2200        if (! rc) {
     2201          Bug(NULL,"SetThreadContext");
     2202          return false;
     2203        }
     2204      }
    22002205      rc = ResumeThread(hthread);
    22012206      if (rc == -1) {
    2202         wperror("ResumeThread");
     2207        Bug(NULL,"ResumeThread");
    22032208        return false;
    22042209      }
     2210      return true;
     2211    } else {
     2212      SEM_RAISE(TCR_AUX(tcr)->resume);
    22052213      return true;
    22062214    }
Note: See TracChangeset for help on using the changeset viewer.