Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2025-08-14
11:40 • Closed ticket [2570123b63]: system encoding is not protected from freeing during... artifact: 510d429b99 user: apnadkarni
2025-08-13
17:59 • Ticket [2570123b63]: 3 changes artifact: fc3258f5aa user: sebres
17:11 • New ticket [2570123b63]. artifact: 4be8979801 user: apnadkarni

system encoding is not protected from freeing during encode/decode operations

Closed / Duplicate2570123b6384460203e0456861e04454296acc78Created 1 year agoUpdated 1 year ago
Descriptionmarkdown2025-08-13 17:11:30

Inspecting code, I have doubts about potential crashes from accessing freed encodings in multithreaded environments. Several functions have code similar to below:

if (encoding == NULL) // encoding is passed by caller
   encoding = systemEncoding; // systemEncoding is GLOBAL shared by threads

Do some operations involving the encoding. 

The issue I am wondering about is that the reference count on systemEncoding is not incremented in such cases. What happens if some other thread calls encoding system and changes the systemEncoding causing the original one in use above to be freed?

Need to build a test case to verify above race condition but perhaps someone could corroborate or refute my analysis. And save me the trouble of creating the test case :-)

sebreswiki2025-08-13 17:59:20

Is not that a duplicate of [f2ff05fc84]?

apnadkarniplain2025-08-14 11:40:50
Oh, yes it is! Short term memory loss (to go with long term memory loss).

Closing as duplicate.
Log in (anonymous is fine) to add a comment.