Re: [PATCH] stdio initialization
Christopher Faylor wrote: On Mon, Nov 10, 2003 at 10:09:52AM -0500, Christopher Faylor wrote: On Mon, Nov 10, 2003 at 03:03:06PM +0100, Thomas Pfaff wrote: Christopher Faylor wrote: On Mon, Nov 10, 2003 at 12:23:35PM +0100, Thomas Pfaff wrote: Attached patch fixes the memory leak reported by Arash Partow by initializing stdio during startup and setting __sdidinit from thread local clib appropriately. Thomas 2003-11-10 Thomas Pfaff <[EMAIL PROTECTED]> * dcrt0.cc: Add prototype for __sinit. (dll_crt0_1): Initialize stdio. The above two things are already done in dcrt0.cc. Why are you adding additional prototypes and going to additional work? Ouch. I should have stayed in bed today. But the rest of your patch looks ok, I think, doesn't it? Actually, on poking around a little, I wonder if we should be calling _reclaim_reent to get back all of the stuff allocated in the REENT structure? It might be better to call _reclaim_reent instead of (*_REENT->__cleanup) (_REENT). I will check tommorow. Thomas
Re: [PATCH] stdio initialization
On Mon, Nov 10, 2003 at 10:09:52AM -0500, Christopher Faylor wrote: >On Mon, Nov 10, 2003 at 03:03:06PM +0100, Thomas Pfaff wrote: >>Christopher Faylor wrote: >>>On Mon, Nov 10, 2003 at 12:23:35PM +0100, Thomas Pfaff wrote: >>> Attached patch fixes the memory leak reported by Arash Partow by initializing stdio during startup and setting __sdidinit from thread local clib appropriately. Thomas 2003-11-10 Thomas Pfaff <[EMAIL PROTECTED]> * dcrt0.cc: Add prototype for __sinit. (dll_crt0_1): Initialize stdio. >>> >>> >>>The above two things are already done in dcrt0.cc. Why are you adding >>>additional prototypes and going to additional work? >>> >> >>Ouch. I should have stayed in bed today. > >But the rest of your patch looks ok, I think, doesn't it? Actually, on poking around a little, I wonder if we should be calling _reclaim_reent to get back all of the stuff allocated in the REENT structure? cgf
Re: [PATCH] stdio initialization
Christopher Faylor wrote: On Mon, Nov 10, 2003 at 03:03:06PM +0100, Thomas Pfaff wrote: Christopher Faylor wrote: On Mon, Nov 10, 2003 at 12:23:35PM +0100, Thomas Pfaff wrote: Attached patch fixes the memory leak reported by Arash Partow by initializing stdio during startup and setting __sdidinit from thread local clib appropriately. Thomas 2003-11-10 Thomas Pfaff <[EMAIL PROTECTED]> * dcrt0.cc: Add prototype for __sinit. (dll_crt0_1): Initialize stdio. The above two things are already done in dcrt0.cc. Why are you adding additional prototypes and going to additional work? Ouch. I should have stayed in bed today. But the rest of your patch looks ok, I think, doesn't it? After i removed the tomatoes from my eyes and looked again: Yes, it does. I will commit to CVS in about 4 hours when i am at home. Thomas
Re: [PATCH] stdio initialization
On Mon, Nov 10, 2003 at 03:03:06PM +0100, Thomas Pfaff wrote: >Christopher Faylor wrote: >>On Mon, Nov 10, 2003 at 12:23:35PM +0100, Thomas Pfaff wrote: >> >>>Attached patch fixes the memory leak reported by Arash Partow by >>>initializing stdio during startup and setting __sdidinit from thread >>>local clib appropriately. >>> >>>Thomas >>> >>>2003-11-10 Thomas Pfaff <[EMAIL PROTECTED]> >>> >>> * dcrt0.cc: Add prototype for __sinit. >>> (dll_crt0_1): Initialize stdio. >> >> >>The above two things are already done in dcrt0.cc. Why are you adding >>additional prototypes and going to additional work? >> > >Ouch. I should have stayed in bed today. But the rest of your patch looks ok, I think, doesn't it? cgf
Re: [PATCH] stdio initialization
Christopher Faylor wrote: On Mon, Nov 10, 2003 at 12:23:35PM +0100, Thomas Pfaff wrote: Attached patch fixes the memory leak reported by Arash Partow by initializing stdio during startup and setting __sdidinit from thread local clib appropriately. Thomas 2003-11-10 Thomas Pfaff <[EMAIL PROTECTED]> * dcrt0.cc: Add prototype for __sinit. (dll_crt0_1): Initialize stdio. The above two things are already done in dcrt0.cc. Why are you adding additional prototypes and going to additional work? Ouch. I should have stayed in bed today. Thomas
Re: [PATCH] stdio initialization
On Mon, Nov 10, 2003 at 12:23:35PM +0100, Thomas Pfaff wrote: >Attached patch fixes the memory leak reported by Arash Partow by >initializing stdio during startup and setting __sdidinit from thread >local clib appropriately. > >Thomas > >2003-11-10 Thomas Pfaff <[EMAIL PROTECTED]> > > * dcrt0.cc: Add prototype for __sinit. > (dll_crt0_1): Initialize stdio. The above two things are already done in dcrt0.cc. Why are you adding additional prototypes and going to additional work? 2003-10-02 Christopher Faylor <[EMAIL PROTECTED]> * dcrt0.cc (dll_crt0_1): Call newlib __sinit routine to ensure that stdio buffers are initialized to avoid thread initialization races. cgf
[PATCH] stdio initialization
Attached patch fixes the memory leak reported by Arash Partow by initializing stdio during startup and setting __sdidinit from thread local clib appropriately. Thomas 2003-11-10 Thomas Pfaff <[EMAIL PROTECTED]> * dcrt0.cc: Add prototype for __sinit. (dll_crt0_1): Initialize stdio. * thread.cc (pthread::exit): Cleanup on thread exit. (__reent_t::init_clib): Set thread local clib __sdidinit var appropriately. diff -urp src.org/dcrt0.cc src/dcrt0.cc --- src.org/dcrt0.cc2003-11-10 12:10:07.279150400 +0100 +++ src/dcrt0.cc2003-11-10 12:10:57.641568000 +0100 @@ -76,6 +76,10 @@ unsigned NO_COPY _cygwin_testing_magic; char NO_COPY almost_null[1]; + +extern "C" void __sinit (struct _reent *s); + + extern "C" { /* This is an exported copy of environ which can be used by DLLs @@ -640,6 +644,9 @@ dll_crt0_1 () pthread::init_mainthread (); } + /* Initialize stdio */ + __sinit (_impure_ptr); + #ifdef DEBUGGING strace.microseconds (); #endif diff -urp src.org/thread.cc src/thread.cc --- src.org/thread.cc 2003-11-10 12:09:51.376283200 +0100 +++ src/thread.cc 2003-11-10 12:10:57.771755200 +0100 @@ -377,6 +377,9 @@ pthread::exit (void *value_ptr) mutex.unlock (); } + if (_REENT->__cleanup) +(*_REENT->__cleanup) (_REENT); + if (InterlockedDecrement (&MT_INTERFACE->threadcount) == 0) ::exit (0); else @@ -1878,6 +1881,7 @@ __reent_t::init_clib (struct _reent& var var._stdin = _GLOBAL_REENT->_stdin; var._stdout = _GLOBAL_REENT->_stdout; var._stderr = _GLOBAL_REENT->_stderr; + var.__sdidinit = _GLOBAL_REENT->__sdidinit; _clib = &var; };