From 2ef36c8edb60b8da26aeb9947f6d2cdd1d4bf6c1 Mon Sep 17 00:00:00 2001 From: dkf Date: Mon, 17 Aug 2015 18:22:18 +0000 Subject: [818a1a51e4] Apply fixes from Andreas Seltenreich (reported to us by Tom Lane) for handling low memory situations. Should not be reachable in Tcl due to ckalloc() panic policy. --- generic/regc_nfa.c | 1 + generic/regcomp.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/generic/regc_nfa.c b/generic/regc_nfa.c index 2de7e14..1d572c3 100644 --- a/generic/regc_nfa.c +++ b/generic/regc_nfa.c @@ -49,6 +49,7 @@ newnfa( nfa = (struct nfa *) MALLOC(sizeof(struct nfa)); if (nfa == NULL) { + ERR(REG_ESPACE); return NULL; } diff --git a/generic/regcomp.c b/generic/regcomp.c index 77f2f20..d23076b 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -982,6 +982,7 @@ parseqatom( NOERR(); assert(v->nextvalue > 0); atom = subre(v, 'b', BACKR, lp, rp); + NOERR(); subno = v->nextvalue; atom->subno = subno; EMPTYARC(lp, rp); /* temporarily, so there's something */ @@ -1129,6 +1130,7 @@ parseqatom( */ t = subre(v, '.', COMBINE(qprefer, atom->flags), lp, rp); + NOERR(); t->left = atom; atomp = &t->left; @@ -1142,6 +1144,7 @@ parseqatom( assert(top->op == '=' && top->left == NULL && top->right == NULL); top->left = subre(v, '=', top->flags, top->begin, lp); + NOERR(); top->op = '.'; top->right = t; -- cgit v0.12 From 74cd974b89d05dd8159d85d730e6aadaa34b3e27 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 19 Aug 2015 15:23:25 +0000 Subject: Fix [00189c4afcb9e2586301d711f71383e48817a72d|00189c4afc]: Allow semi-static UCRT build on Windows with VC 14.0 --- generic/tclMain.c | 3 +++ win/makefile.vc | 22 ++++++++++++++++++++-- win/rules.vc | 7 +++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/generic/tclMain.c b/generic/tclMain.c index 5e5109b..b2206f8 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -28,7 +28,10 @@ * source directory to make their own modified versions). */ +#if defined _MSC_VER && _MSC_VER < 1900 +/* isatty is always defined on MSVC 14.0, but not necessarily as CRTIMPORT. */ extern CRTIMPORT int isatty(int fd); +#endif static Tcl_Obj *tclStartupScriptPath = NULL; static Tcl_Obj *tclStartupScriptEncoding = NULL; diff --git a/win/makefile.vc b/win/makefile.vc index 1f957ea..24a92ba 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -70,7 +70,7 @@ the build instructions. # Sets where to install Tcl from the built binaries. # C:\Progra~1\Tcl is assumed when not specified. # -# OPTS=loimpact,msvcrt,static,staticpkg,symbols,threads,profile,unchecked,none +# OPTS=loimpact,msvcrt,static,staticpkg,symbols,threads,profile,unchecked,ucrt,none # Sets special options for the core. The default is for none. # Any combination of the above may be used (comma separated). # 'none' will over-ride everything to nothing. @@ -94,6 +94,11 @@ the build instructions. # unchecked = Allows a symbols build to not use the debug # enabled runtime (msvcrt.dll not msvcrtd.dll # or libcmt.lib not libcmtd.lib). +# ucrt= Uses ucrt.lib and libvcruntime.lib, which +# ensures Tcl will run on machines with only the subset +# of the C runtime that is part of the operating system. +# If omitted, builds with VC 14.0 or later will require +# the full C runtime redistributable. # # STATS=compdbg,memdbg,none # Sets optional memory and bytecode compiler debugging code added @@ -438,7 +443,13 @@ cdebug = -Zi -WX $(DEBUGFLAGS) cwarn = $(WARNINGS) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\ -!if $(MSVCRT) +!if $(UCRT) +!if $(DEBUG) && !$(UNCHECKED) +crt = -MDd +!else +crt = -MT +!endif +!elseif $(MSVCRT) !if $(DEBUG) && !$(UNCHECKED) crt = -MDd !else @@ -480,6 +491,10 @@ lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug) lflags = $(lflags) -profile !endif +!if $(UCRT) && !($(DEBUG) && !$(UNCHECKED)) +lflags = $(lflags) -nodefaultlib:libucrt.lib +!endif + !if $(ALIGN98_HACK) && !$(STATIC_BUILD) ### Align sections for PE size savings. lflags = $(lflags) -opt:nowin98 @@ -504,6 +519,9 @@ baselibs = kernel32.lib user32.lib ws2_32.lib baselibs = $(baselibs) bufferoverflowU.lib !endif !endif +!if $(UCRT) && !($(DEBUG) && !$(UNCHECKED)) +baselibs = $(baselibs) ucrt.lib +!endif #--------------------------------------------------------------------- # TclTest flags diff --git a/win/rules.vc b/win/rules.vc index 78a167a..9247c59 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -223,6 +223,7 @@ LOIMPACT = 0 TCL_USE_STATIC_PACKAGES = 0 USE_THREAD_ALLOC = 0 UNCHECKED = 0 +UCRT = 0 !else !if [nmakehlp -f $(OPTS) "static"] !message *** Doing static @@ -302,6 +303,12 @@ UNCHECKED = 1 UNCHECKED = 0 !endif !endif +!if [nmakehlp -f $(OPTS) "ucrt"] && $(VCVERSION) >= 1900 +!message *** Doing UCRT +UCRT = 1 +!else +UCRT = 0 +!endif #---------------------------------------------------------- # Figure-out how to name our intermediate and output directories. -- cgit v0.12 From 811b14e555c23a063e1c1d0b17627a0484624234 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 21 Aug 2015 10:40:48 +0000 Subject: Eliminate some (harmless) compiler warnings. No functional change. --- generic/tclThread.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/generic/tclThread.c b/generic/tclThread.c index 087d735..17071e5 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.c @@ -24,7 +24,7 @@ typedef struct { int num; /* Number of objects remembered */ int max; /* Max size of the array */ - char **list; /* List of pointers */ + void **list; /* List of pointers */ } SyncObjRecord; static SyncObjRecord keyRecord = {0, 0, NULL}; @@ -35,8 +35,8 @@ static SyncObjRecord condRecord = {0, 0, NULL}; * Prototypes of functions used only in this file. */ -static void ForgetSyncObject(char *objPtr, SyncObjRecord *recPtr); -static void RememberSyncObject(char *objPtr, +static void ForgetSyncObject(void *objPtr, SyncObjRecord *recPtr); +static void RememberSyncObject(void *objPtr, SyncObjRecord *recPtr); /* @@ -94,7 +94,7 @@ Tcl_GetThreadData( result = ckalloc((size_t) size); memset(result, 0, (size_t) size); *keyPtr = (Tcl_ThreadDataKey)result; - RememberSyncObject((char *) keyPtr, &keyRecord); + RememberSyncObject(keyPtr, &keyRecord); } result = * (void **) keyPtr; #endif /* TCL_THREADS */ @@ -153,10 +153,10 @@ TclThreadDataKeyGet( static void RememberSyncObject( - char *objPtr, /* Pointer to sync object */ + void *objPtr, /* Pointer to sync object */ SyncObjRecord *recPtr) /* Record of sync objects */ { - char **newList; + void **newList; int i, j; @@ -178,7 +178,7 @@ RememberSyncObject( if (recPtr->num >= recPtr->max) { recPtr->max += 8; - newList = (char **) ckalloc(recPtr->max * sizeof(char *)); + newList = (void **) ckalloc(recPtr->max * sizeof(char *)); for (i=0,j=0 ; inum ; i++) { if (recPtr->list[i] != NULL) { newList[j++] = recPtr->list[i]; @@ -214,7 +214,7 @@ RememberSyncObject( static void ForgetSyncObject( - char *objPtr, /* Pointer to sync object */ + void *objPtr, /* Pointer to sync object */ SyncObjRecord *recPtr) /* Record of sync objects */ { int i; @@ -248,7 +248,7 @@ void TclRememberMutex( Tcl_Mutex *mutexPtr) { - RememberSyncObject((char *)mutexPtr, &mutexRecord); + RememberSyncObject(mutexPtr, &mutexRecord); } /* @@ -276,7 +276,7 @@ Tcl_MutexFinalize( TclpFinalizeMutex(mutexPtr); #endif TclpMasterLock(); - ForgetSyncObject((char *) mutexPtr, &mutexRecord); + ForgetSyncObject(mutexPtr, &mutexRecord); TclpMasterUnlock(); } @@ -303,7 +303,9 @@ void TclMutexUnlockAndFinalize( Tcl_Mutex *mutexPtr) { +#ifdef TCL_THREADS Tcl_Mutex mutex; +#endif TclpMasterLock(); TclpMutexLock(); #ifdef TCL_THREADS @@ -338,7 +340,7 @@ void TclRememberCondition( Tcl_Condition *condPtr) { - RememberSyncObject((char *) condPtr, &condRecord); + RememberSyncObject(condPtr, &condRecord); } /* @@ -366,7 +368,7 @@ Tcl_ConditionFinalize( TclpFinalizeCondition(condPtr); #endif TclpMasterLock(); - ForgetSyncObject((char *) condPtr, &condRecord); + ForgetSyncObject(condPtr, &condRecord); TclpMasterUnlock(); } -- cgit v0.12 From 03fb986ef80ace8909712934c47c86a26a75d027 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 25 Aug 2015 09:39:16 +0000 Subject: Removed "ucrt" as configureable option: If building with VC2014, it's the recommended way to build Tcl. --- win/makefile.vc | 19 ++++--------------- win/rules.vc | 7 ------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/win/makefile.vc b/win/makefile.vc index 24a92ba..267f53f 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -70,7 +70,7 @@ the build instructions. # Sets where to install Tcl from the built binaries. # C:\Progra~1\Tcl is assumed when not specified. # -# OPTS=loimpact,msvcrt,static,staticpkg,symbols,threads,profile,unchecked,ucrt,none +# OPTS=loimpact,msvcrt,static,staticpkg,symbols,threads,profile,unchecked,none # Sets special options for the core. The default is for none. # Any combination of the above may be used (comma separated). # 'none' will over-ride everything to nothing. @@ -94,11 +94,6 @@ the build instructions. # unchecked = Allows a symbols build to not use the debug # enabled runtime (msvcrt.dll not msvcrtd.dll # or libcmt.lib not libcmtd.lib). -# ucrt= Uses ucrt.lib and libvcruntime.lib, which -# ensures Tcl will run on machines with only the subset -# of the C runtime that is part of the operating system. -# If omitted, builds with VC 14.0 or later will require -# the full C runtime redistributable. # # STATS=compdbg,memdbg,none # Sets optional memory and bytecode compiler debugging code added @@ -443,13 +438,7 @@ cdebug = -Zi -WX $(DEBUGFLAGS) cwarn = $(WARNINGS) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\ -!if $(UCRT) -!if $(DEBUG) && !$(UNCHECKED) -crt = -MDd -!else -crt = -MT -!endif -!elseif $(MSVCRT) +!if $(MSVCRT) !if $(DEBUG) && !$(UNCHECKED) crt = -MDd !else @@ -491,7 +480,7 @@ lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug) lflags = $(lflags) -profile !endif -!if $(UCRT) && !($(DEBUG) && !$(UNCHECKED)) +!if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 lflags = $(lflags) -nodefaultlib:libucrt.lib !endif @@ -519,7 +508,7 @@ baselibs = kernel32.lib user32.lib ws2_32.lib baselibs = $(baselibs) bufferoverflowU.lib !endif !endif -!if $(UCRT) && !($(DEBUG) && !$(UNCHECKED)) +!if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 baselibs = $(baselibs) ucrt.lib !endif diff --git a/win/rules.vc b/win/rules.vc index 9247c59..78a167a 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -223,7 +223,6 @@ LOIMPACT = 0 TCL_USE_STATIC_PACKAGES = 0 USE_THREAD_ALLOC = 0 UNCHECKED = 0 -UCRT = 0 !else !if [nmakehlp -f $(OPTS) "static"] !message *** Doing static @@ -303,12 +302,6 @@ UNCHECKED = 1 UNCHECKED = 0 !endif !endif -!if [nmakehlp -f $(OPTS) "ucrt"] && $(VCVERSION) >= 1900 -!message *** Doing UCRT -UCRT = 1 -!else -UCRT = 0 -!endif #---------------------------------------------------------- # Figure-out how to name our intermediate and output directories. -- cgit v0.12 From 4b8109368625d2b5d9c74f7f2375925b57860efa Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 25 Aug 2015 11:29:58 +0000 Subject: Fix [0df7a1ec2674a76a]: unix/tclUnixFile.c: return value of call to TclpGetCwd in TclpFindExecutable is not checked, variable cwd is used uninitialized. --- unix/tclUnixFile.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index c5f75a7..0a2099c 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -155,6 +155,11 @@ TclpFindExecutable( goto done; } + if (TclpGetCwd(NULL, &cwd) == NULL) { + TclSetObjNameOfExecutable(Tcl_NewObj(), NULL); + goto done; + } + /* * The name is relative to the current working directory. First strip off * a leading "./", if any, then add the full path name of the current @@ -168,8 +173,6 @@ TclpFindExecutable( Tcl_DStringInit(&nameString); Tcl_DStringAppend(&nameString, name, -1); - TclpGetCwd(NULL, &cwd); - Tcl_DStringFree(&buffer); Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&cwd), Tcl_DStringLength(&cwd), &buffer); -- cgit v0.12