This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [commit/windows] Add thread ID in SuspendThread error warning message.


On Mon, Jun 24, 2013 at 04:34:21PM -0700, Joel Brobecker wrote:
>> >That's interesting. I have the following patch in AdaCore's tree
>> >which I have been uhming and ahming about. Would it apply to your
>> >situation as well?
>> >
>> >-                   warning (_("SuspendThread failed. (winerr %u)"),
>> >-                            (unsigned) err);
>> >-                   return NULL;
>> >+                   /* If SuspendThread failed with error 5 (access
>> >+                      denied), then ignore the error.  It's unclear
>> >+                      where this comes from and how to prevent it.
>> >+                      But in the meantime, ignoring it seems to allow
>> >+                      us to inspect the thread (including fetching
>> >+                      registers) without apparent ill effect.  */
>> >+                   if (err != 5)
>> >+                     {
>> >+                       warning (_("SuspendThread (tid=0x%x) failed."
>> >+                                  " (winerr %d)"),
>> >+                                (unsigned) id, (unsigned) err);
>> >+                       return NULL;
>> >+                     }
>> 
>> That's basically what I'm doing in the Cygwin release:
>> 
>>                 if (SuspendThread (th->h) == (DWORD) -1)
>>                   {
>>                     DWORD err = GetLastError ();
>> -                   warning (_("SuspendThread failed. (winerr %u)"),
>> -                            (unsigned) err);
>> +                   /* Can get a ERROR_INVALID_HANDLE if the main thread has
>> +                      exited. */
>> +                   if (err != ERROR_INVALID_HANDLE)
>> +                     warning (_("SuspendThread(%p) failed. (winerr %u)"),
>> +                              (void *) th->h, (unsigned) err);
>>                     return NULL;
>>                   }
>>                 th->suspended = 1;
>
>That's interesting again. If I read MSDN right, ERROR_INVALID_HANDLE
>is 6, whereas I ignore the error for code 5 (access denied). I say
>that it's interesting, because the report we had was for the error
>you ignore.

I have only seen an invalid handle error and I think it makes sense
since it's possible that the thread has disappeared when this function
is called.  I thought it happened when the main thread exits before
some other thread.

>Someone was able to reproduce this issue consistently, and I wish
>they had more time to help me investigate this. If we had more
>details on the two error cases, I would not mind checking in
>a merge of both our changes.

I think adding the tid is a good idea so if you want to merge the
two that's fine with me.  I've been meaning to dust off my changes
and submit them for approval anyway so you'd save me that step.

cgf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]