XP Pro, SP2.

In threadex.c

static void _callthreadstartex(void)
{
    _ptiddata ptd;           /* pointer to thread's _tiddata struct */

    /* must always exist at this point */
    ptd = _getptd();

    /*
        * Guard call to user code with a _try - _except statement to
        * implement runtime errors and signal support
        */
    __try {
            _endthreadex (
                ( (unsigned (__CLR_OR_STD_CALL *)(void 
*))(((_ptiddata)ptd)->_initaddr) )
    /******* Debugger Points Here *******/            ( 
((_ptiddata)ptd)->_initarg ) ) ;
    }
    __except ( _XcptFilter(GetExceptionCode(), GetExceptionInformation()) )
    {
            /*
                * Should never reach here
                */
            _exit( GetExceptionCode() );

    } /* end of _try - _except */

}

"Unhandled exception at 0x02024ceb in pgadmin3.exe 0xC0000005; access violation 
writing
location 0x00000000
Installed from executeable on www.pgadmin.org. 

Beta 2 certainly is much better than Beta 1.


Disassembly view:
$LN9:
78132850 C3               ret              
$LN6:
78132851 8B 65 E8         mov         esp,dword ptr [ebp-18h] 
   298:     {
   299:             /*
   300:                 * Should never reach here
   301:                 */
   302:             _exit( GetExceptionCode() );
78132854 FF 75 E4         push        dword ptr [ebp-1Ch] 
78132857 E8 DE F1 FF FF   call        _exit (78131A3Ah) 
$LN12:
7813285C CC               int         3    
   202: *       void *ptd       = pointer to _tiddata structure for this thread
   203: *
   204: *Exit:
   205: *       Never returns - terminates thread!
   206: *
   207: *Exceptions:
   208: *
   209: 
*******************************************************************************/
   210: 
   211: static unsigned long WINAPI _threadstart (
   212:         void * ptd
   213:         )
   214: {
   215:         _ptiddata _ptd;                  /* pointer to per-thread data 
*/
   216: 
   217:         /* Initialize FlsGetValue function pointer */
   218:         __set_flsgetvalue();
7813285D E8 76 03 00 00   call        __set_flsgetvalue (78132BD8h) 
   219: 
   220:         /*
   221:          * Check if ptd is initialised during THREAD_ATTACH call to dll 
mains
   222:          */
   223:         if ( (_ptd = (_ptiddata)__fls_getvalue(__get_flsindex())) == 
NULL)
78132862 E8 6B 03 00 00   call        __get_flsindex (78132BD2h) 
78132867 50               push        eax  
78132868 E8 50 03 00 00   call        __fls_getvalue (78132BBDh) 
7813286D 85 C0            test        eax,eax 
7813286F 75 20            jne         $LN7 (78132891h) 
   224:         {
   225:             /*
   226:              * Stash the pointer to the per-thread data stucture in TLS
   227:              */
   228:             if ( !__fls_setvalue(__get_flsindex(), ptd) )
78132871 FF 74 24 04      push        dword ptr [esp+4] 
78132875 E8 58 03 00 00   call        __get_flsindex (78132BD2h) 
7813287A 50               push        eax  
7813287B E8 82 03 00 00   call        __fls_setvalue (78132C02h) 
78132880 85 C0            test        eax,eax 
78132882 75 29            jne         $LN7+1Ch (781328ADh) 
   229:             {
   230:                 ExitThread(GetLastError());
78132884 FF 15 64 40 19 78 call        dword ptr [EMAIL PROTECTED] (78194064h)] 
7813288A 50               push        eax  
7813288B FF 15 5C 40 19 78 call        dword ptr [EMAIL PROTECTED] (7819405Ch)] 
   231:             }
   232:         }
   233:         else
   234:         {
   235:             _ptd->_initaddr = ((_ptiddata) ptd)->_initaddr;
78132891 8B 4C 24 04      mov         ecx,dword ptr [esp+4] 
78132895 8B 51 54         mov         edx,dword ptr [ecx+54h] 
78132898 89 50 54         mov         dword ptr [eax+54h],edx 
   236:             _ptd->_initarg =  ((_ptiddata) ptd)->_initarg;
7813289B 8B 51 58         mov         edx,dword ptr [ecx+58h] 
7813289E 89 50 58         mov         dword ptr [eax+58h],edx 
   237:             _ptd->_thandle =  ((_ptiddata) ptd)->_thandle;
781328A1 8B 51 04         mov         edx,dword ptr [ecx+4] 
   238: #if defined (_M_CEE) || defined (MRTDLL)
   239:             _ptd->__initDomain=((_ptiddata) ptd)->__initDomain;
   240: #endif  /* defined (_M_CEE) || defined (MRTDLL) */
   241:             _freefls(ptd);
781328A4 51               push        ecx  
781328A5 89 50 04         mov         dword ptr [eax+4],edx 
781328A8 E8 FA 04 00 00   call        _freefls (78132DA7h) 
   242:             ptd = _ptd;
   243:         }
   244: 
   245:         /*
   246:          * Call fp initialization, if necessary
   247:          */
   248: #ifndef MRTDLL
   249: #ifdef CRTDLL
   250:         _fpclear();
781328AD E8 3D 69 01 00   call        _fpclear (781491EFh) 
   251: #else  /* CRTDLL */
   252:         if (_FPmtinit != NULL &&
   253:             _IsNonwritableInCurrentImage((PBYTE)&_FPmtinit))
   254:         {
   255:             (*_FPmtinit)();
   256:         }
   257: #endif  /* CRTDLL */
   258: #endif  /* MRTDLL */
   259: 
   260: #if defined (_M_CEE) || defined (MRTDLL)
   261:         DWORD domain=0;
   262:         if(!_getdomain(&domain))
   263:         {
   264:             ExitThread(0);
   265:         }
   266:         if(domain!=_ptd->__initDomain)
   267:         {
   268:             /* need to transition to caller's domain and startup there*/
   269:             ::msclr::call_in_appdomain(_ptd->__initDomain, 
_callthreadstart);
   270: 
   271:             return 0L;
   272:         }
   273: #endif  /* defined (_M_CEE) || defined (MRTDLL) */
   274: 
   275:         _callthreadstart();
781328B2 E8 65 FF FF FF   call        _callthreadstart (7813281Ch) 
$LN8:
781328B7 CC               int         3    
     1: /***
     2: *thread.c - Begin and end a thread
     3: *
     4: *       Copyright (c) Microsoft Corporation. All rights reserved.
     5: *
     6: *Purpose:
     7: *       This source contains the _beginthread() and _endthread()
     8: *       routines which are used to start and terminate a thread.
     9: *
    10: 
*******************************************************************************/
    11: 
    12: 
    13: #include <cruntime.h>
    14: #include <oscalls.h>
    15: #include <internal.h>
    16: #include <mtdll.h>
    17: #include <msdos.h>
    18: #include <malloc.h>
    19: #include <process.h>
    20: #include <stddef.h>
    21: #include <rterr.h>
    22: #include <dbgint.h>
    23: #include <errno.h>
    24: #if defined (_M_CEE) || defined (MRTDLL)
    25: #include <msclr\appdomain.h>
    26: #endif  /* defined (_M_CEE) || defined (MRTDLL) */
    27: 
    28: #pragma warning(disable:4439)   // C4439: function with a managed 
parameter must
have a __clrcall calling convention
    29: 
    30: /*
    31:  * Startup code for new thread.
    32:  */
    33: static unsigned long WINAPI _threadstart(void *);
    34: static void _callthreadstart(void);
    35: 
    36: /*
    37:  * declare pointers to per-thread FP initialization and termination 
routines.
    38:  * Note that this initialization is only done in native, not managed.
    39:  */
    40: #if !defined (MRTDLL) && !defined (CRTDLL)
    41: const _PVFV _FPmtinit;
    42: const _PVFV _FPmtterm;
    43: #endif  /* !defined (MRTDLL) && !defined (CRTDLL) */
    44: 
    45: #if defined (_M_CEE) || defined (MRTDLL)
    46: static int _getdomain(DWORD *pDomain)
    47: {
    48:     *pDomain=0;
    49:     ICLRRuntimeHost *pClrHost = NULL;
    50: 
    51:     HRESULT hr = CorBindToRuntimeEx(
    52:         NULL,                       // version of the runtime to request
    53:         NULL,                       // flavor of the runtime to request
    54:         0,                          // runtime startup flags
    55:         CLSID_CLRRuntimeHost,       // clsid of ICLRRuntimeHost
    56:         IID_ICLRRuntimeHost,        // IID of ICLRRuntimeHost
    57:         (PVOID*)&pClrHost);         // a pointer to our punk that we 
get back
    58: 
    59:     if (FAILED(hr))
    60:     {
    61:         if (pClrHost != NULL)
    62:         {
    63:             pClrHost->Release();
    64:         }
    65:         return false;
    66:     }
    67: 
    68:     DWORD domain=0;
    69:     hr=pClrHost->GetCurrentAppDomainId(&domain);
    70:     pClrHost->Release();
    71:     pClrHost=NULL;
    72:     if (FAILED(hr))
    73:     {
    74:         return false;
    75:     }
    76:     *pDomain=domain;
    77:     return true;
    78: }
    79: #endif  /* defined (_M_CEE) || defined (MRTDLL) */
    80: 
    81: /***
    82: *_beginthread() - Create a child thread
    83: *
    84: *Purpose:
    85: *       Create a child thread.
    86: *
    87: *Entry:
    88: *       initialcode = pointer to thread's startup code address
    89: *       stacksize = size of stack
    90: *       argument = argument to be passed to new thread
    91: *
    92: *Exit:
    93: *       success = handle for new thread if successful
    94: *
    95: *       failure = (unsigned long) -1L in case of error, errno and 
_doserrno
    96: *                 are set
    97: *
    98: *Exceptions:
    99: *
   100: 
*******************************************************************************/
   101: 
   102: _MCRTIMP uintptr_t __cdecl _beginthread (
   103:         void (__CLRCALL_OR_CDECL * initialcode) (void *),
   104:         unsigned stacksize,
   105:         void * argument
   106:         )
   107: {
781328B8 55               push        ebp  
781328B9 8B EC            mov         ebp,esp 
781328BB 51               push        ecx  
781328BC 53               push        ebx  
781328BD 57               push        edi  
   108:         _ptiddata ptd;                  /* pointer to per-thread data */
   109:         uintptr_t thdl;                 /* thread handle */
   110:         unsigned long err = 0L;     /* Return from GetLastError() */
   111: 
   112:         /* validation section */
   113:         _VALIDATE_RETURN(initialcode != NULL, EINVAL, -1);
781328BE 8B 7D 08         mov         edi,dword ptr [initialcode] 
781328C1 33 DB            xor         ebx,ebx 
781328C3 3B FB            cmp         edi,ebx 
781328C5 89 5D FC         mov         dword ptr [err],ebx 
781328C8 75 20            jne         _beginthread+32h (781328EAh) 
781328CA E8 E3 19 00 00   call        _errno (781342B2h) 
781328CF 53               push        ebx  
781328D0 53               push        ebx  
781328D1 53               push        ebx  
781328D2 53               push        ebx  
781328D3 53               push        ebx  
781328D4 C7 00 16 00 00 00 mov         dword ptr [eax],16h 
781328DA E8 81 5F 00 00   call        _invalid_parameter (78138860h) 
781328DF 83 C4 14         add         esp,14h 
781328E2 83 C8 FF         or          eax,0FFFFFFFFh 
781328E5 E9 81 00 00 00   jmp         error_return+1Dh (7813296Bh) 
781328EA 56               push        esi  
   114: 
   115:         /* Initialize FlsGetValue function pointer */
   116:         __set_flsgetvalue();
781328EB E8 E8 02 00 00   call        __set_flsgetvalue (78132BD8h) 
   117: 
   118:         /*
   119:          * Allocate and initialize a per-thread data structure for the 
to-
   120:          * be-created thread.
   121:          */
   122:         if ( (ptd = (_ptiddata)_calloc_crt(1, sizeof(struct _tiddata))) 
== NULL )
781328F0 68 14 02 00 00   push        214h 
781328F5 6A 01            push        1    
781328F7 E8 E7 1D 00 00   call        _calloc_crt (781346E3h) 
781328FC 8B F0            mov         esi,eax 
781328FE 3B F3            cmp         esi,ebx 
78132900 59               pop         ecx  
78132901 59               pop         ecx  
78132902 74 4A            je          error_return (7813294Eh) 
   123:         {
   124:             goto error_return;
   125:         }
   126: 
   127:         /*
   128:          * Initialize the per-thread data
   129:          */
   130: 
   131:         _initptd(ptd, _getptd()->ptlocinfo);
78132904 E8 86 04 00 00   call        _getptd (78132D8Fh) 
78132909 FF 70 6C         push        dword ptr [eax+6Ch] 
7813290C 56               push        esi  
7813290D E8 46 03 00 00   call        _initptd (78132C58h) 
   132: 
   133:         ptd->_initaddr = (void *) initialcode;
   134:         ptd->_initarg = argument;
78132912 8B 45 10         mov         eax,dword ptr [argument] 
78132915 59               pop         ecx  
78132916 59               pop         ecx  
   135: 
   136: #if defined (_M_CEE) || defined (MRTDLL)
   137:         if(!_getdomain(&(ptd->__initDomain)))
   138:         {
   139:             goto error_return;
   140:         }
   141: #endif  /* defined (_M_CEE) || defined (MRTDLL) */
   142: 
   143:         /*
   144:          * Create the new thread. Bring it up in a suspended state so 
that
   145:          * the _thandle and _tid fields are filled in before execution
   146:          * starts.
   147:          */
   148:         if ( (ptd->_thandle = thdl = (uintptr_t)
   149:               CreateThread( NULL,
   150:                             stacksize,
   151:                             _threadstart,
   152:                             (LPVOID)ptd,
   153:                             CREATE_SUSPENDED,
   154:                             (LPDWORD)&(ptd->_tid) ))
   155:              == (uintptr_t)0 )
78132917 56               push        esi  
78132918 6A 04            push        4    
7813291A 56               push        esi  
7813291B 68 5D 28 13 78   push        offset _threadstart (7813285Dh) 
78132920 FF 75 0C         push        dword ptr [stacksize] 
78132923 89 7E 54         mov         dword ptr [esi+54h],edi 
78132926 53               push        ebx  
78132927 89 46 58         mov         dword ptr [esi+58h],eax 
7813292A FF 15 6C 40 19 78 call        dword ptr [EMAIL PROTECTED] (7819406Ch)] 
78132930 8B F8            mov         edi,eax 
78132932 3B FB            cmp         edi,ebx 
78132934 89 7E 04         mov         dword ptr [esi+4],edi 
   156:         {
   157:                 err = GetLastError();
   158:                 goto error_return;
78132937 74 0C            je          _beginthread+8Dh (78132945h) 
   159:         }
   160: 
   161:         /*
   162:          * Start the new thread executing
   163:          */
   164:         if ( ResumeThread( (HANDLE)thdl ) == (DWORD)(-1) ) {
78132939 57               push        edi  
7813293A FF 15 68 40 19 78 call        dword ptr [EMAIL PROTECTED] (78194068h)] 
78132940 83 F8 FF         cmp         eax,0FFFFFFFFh 
78132943 75 23            jne         error_return+1Ah (78132968h) 
   165:                 err = GetLastError();
78132945 FF 15 64 40 19 78 call        dword ptr [EMAIL PROTECTED] (78194064h)] 
7813294B 89 45 FC         mov         dword ptr [err],eax 
   166:                 goto error_return;
   167:         }
   168: 
   169:         /*
   170:          * Good return
   171:          */
   172:         return(thdl);
   173: 
   174:         /*
   175:          * Error return
   176:          */
   177: error_return:
   178:         /*
   179:          * Either ptd is NULL, or it points to the no-longer-necessary 
block
   180:          * calloc-ed for the _tiddata struct which should now be freed 
up.
   181:          */
   182:         _free_crt(ptd);
7813294E 56               push        esi  
7813294F E8 7E 21 00 00   call        free (78134AD2h) 
   183: 
   184:         /*
   185:          * Map the error, if necessary.
   186:          */
   187:         if ( err != 0L )
78132954 39 5D FC         cmp         dword ptr [err],ebx 
78132957 59               pop         ecx  
78132958 74 09            je          error_return+15h (78132963h) 
   188:                 _dosmaperr(err);
7813295A FF 75 FC         push        dword ptr [err] 
7813295D E8 76 19 00 00   call        _dosmaperr (781342D8h) 
78132962 59               pop         ecx  
   189: 
   190:         return( (uintptr_t)(-1) );
78132963 83 C8 FF         or          eax,0FFFFFFFFh 
78132966 EB 02            jmp         error_return+1Ch (7813296Ah) 
   166:                 goto error_return;
   167:         }
   168: 
   169:         /*
   170:          * Good return
   171:          */
   172:         return(thdl);
78132968 8B C7            mov         eax,edi 
7813296A 5E               pop         esi  
7813296B 5F               pop         edi  
7813296C 5B               pop         ebx  
   191: }
7813296D C9               leave            
7813296E C3               ret              
--- f:\rtm\vctools\crt_bld\self_x86\crt\src\threadex.c -------------------------
   373: *       Never returns!
   374: *
   375: *Exceptions:
   376: *
   377: 
*******************************************************************************/
   378: 
   379: void __cdecl _endthreadex (
   380:         unsigned retcode
   381:         )
   382: {
   383:         _ptiddata ptd;           /* pointer to thread's _tiddata struct 
*/
   384: 
   385:         /*
   386:          * Call fp termination, if necessary
   387:          */
   388: #ifdef CRTDLL
   389:         _fpclear();
7813296F E8 7B 68 01 00   call        _fpclear (781491EFh) 
   390: #else  /* CRTDLL */
   391:         if (_FPmtterm != NULL &&
   392:             _IsNonwritableInCurrentImage((PBYTE)&_FPmtterm))
   393:         {
   394:             (*_FPmtterm)();
   395:         }
   396: #endif  /* CRTDLL */
   397: 
   398:         ptd = _getptd_noexit();
78132974 E8 93 03 00 00   call        _getptd_noexit (78132D0Ch) 
   399: 
   400:         if (ptd) {
78132979 85 C0            test        eax,eax 
7813297B 74 07            je          _endthreadex+15h (78132984h) 
   401:             /*
   402:              * Free up the _tiddata structure & its subordinate buffers
   403:              *      _freeptd() will also clear the value for this thread
   404:              *      of the FLS variable __flsindex.
   405:              */
   406:             _freeptd(ptd);
7813297D 50               push        eax  
7813297E E8 45 05 00 00   call        _freeptd (78132EC8h) 
78132983 59               pop         ecx  
   407:         }
   408: 
   409:         /*
   410:          * Terminate the thread
   411:          */
   412:         ExitThread(retcode);
78132984 FF 74 24 04      push        dword ptr [esp+4] 
78132988 FF 15 5C 40 19 78 call        dword ptr [EMAIL PROTECTED] (7819405Ch)] 
$LN5:
7813298E CC               int         3    
   319:             /* need to transition to caller's domain and startup there*/
   320:             ::msclr::call_in_appdomain(_ptd->__initDomain, 
_callthreadstartex);
   321: 
   322:             return 0L;
   323:         }
   324: #endif  /* defined (_M_CEE) || defined (MRTDLL) */
   325: 
   326:         _callthreadstartex();
   327: 
   328:         /*
   329:          * Never executed!
   330:          */
   331:         return(0L);
   332: }
   333: 
   334: static void _callthreadstartex(void)
   335: {
7813298F 6A 0C            push        0Ch  
78132991 68 B8 4B 1B 78   push        offset ___rtc_tzz+84h (781B4BB8h) 
78132996 E8 DD 60 00 00   call        __SEH_prolog4 (78138A78h) 
   336:     _ptiddata ptd;           /* pointer to thread's _tiddata struct */
   337: 
   338:     /* must always exist at this point */
   339:     ptd = _getptd();
7813299B E8 EF 03 00 00   call        _getptd (78132D8Fh) 
   340: 
   341:     /*
   342:         * Guard call to user code with a _try - _except statement to
   343:         * implement runtime errors and signal support
   344:         */
   345:     __try {
781329A0 83 65 FC 00      and         dword ptr [ebp-4],0 
   346:             _endthreadex (
   347:                 ( (unsigned (__CLR_OR_STD_CALL *)(v




--
Open WebMail Project (http://openwebmail.org)


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to