| Ticket UUID: | 4b22d84a6236ed01b4ba300556dc4f4c78214ee0 | ||
| Title: | Core Dump when setting const with non-existent namespace | ||
| Type: | Bug | Created on: | 2026-01-11 00:18:40 |
| Submitter: | sheckandar | Assigned to: | nobody |
| Subsystem: | 07. Variables | Severity: | Important |
| Priority: | 5 Medium | Last modified: | 2026-03-14 13:08:28 |
| Status: | Closed | Closed by: | stu |
| Resolution: | Fixed | Closed on: | 2026-03-14 13:08:28 |
| Version: | 9.0.3 | ||
| Description: | ||||
|
System: Red Hat 8.10
If a namespace in question already exists, there are no issues. | ||||
| User Comments: | ||||
stu added on 2026-03-13 11:35:56:
Index: generic/tclExecute.c
--- generic/tclExecute.c.orig
+++ generic/tclExecute.c
@@ -4214,6 +4214,11 @@ TEBCresume(
TRACE("\"%.30s\" \"%.30s\" => ", O2S(part1Ptr), O2S(objPtr));
varPtr = TclObjLookupVarEx(interp, part1Ptr, NULL, 0, NULL,
/*createPart1*/1, /*createPart2*/0, &arrayPtr);
+ if (!varPtr) {
+ /* Maybe use TCL_LEAVE_ERR_MSG in the lookup call? */
+ msgPart = "problem!";
+ goto constError;
+ }
doConst:
if (TclIsVarConstant(varPtr)) {
TRACE_APPEND("already constant\n");
stu added on 2026-03-13 11:36:54:
There should be a test for this as well. apnadkarni added on 2026-03-13 14:26:51:
Proposed fix in [ba4d418633]. stu added on 2026-03-13 17:32:53:
Not "goto constError;" or even "goto gotError;" ? That seems to be the normal exit route. apnadkarni added on 2026-03-13 18:03:19:
@stu, which line are you referring to? It does do "goto gotError". stu added on 2026-03-13 18:28:06:
Ok, so the link in your message isn't or is only part of the fix. These are the changes I thought I'd see [cfc42afaa005ed5d]. stu added on 2026-03-13 18:29:36:
Also, looks like the code in that file does: if (!varPtr) not: if (varPtr == NULL) stu added on 2026-03-13 18:37:36:
Also, if TCL_LEAVE_ERR_MSG is being used, isn't there a way to get that result and put it into msgPart, which should probably be set anyway? Also also, "variable not found" isn't the right error. In the testcase, the error returned is "parent namespace doesn't exist" - who knows what other errors could be returned? I think the way to go is to put the interp result err string into msgPart then jump to constError. apnadkarni added on 2026-03-14 02:33:10:
I don't want to jump to constError because it uses other variables whose status I do not know on the jump to doConst (remember varPtr was not set) and I do not want to trace backward to jump points. "variable not found" is only used if the interpreter does not already have an error message. If it does, it is preserved (which again, is not the case with constError). Setting msgPart is not trivial because it expects a static string. Pointing it to content of interp result requires more book keeping. Also note constError is only used in that code block for errors related to arrays. Otherwise gotError is used (see the line 3692 in the last code block before constError. I do not use ! with pointers. Stylistic choice. Shrug. stu added on 2026-03-14 13:08:28:
TclExecute.c has 4 "if (varPtr == NULL)" 8 "if (!varPtr)" *not-too-impressed-shrug* | ||||
