Tkhtml on 64-bit Windows crashes unexpectantly

115 views
Skip to first unread message

Bob C

unread,
Apr 19, 2021, 7:09:35 PM4/19/21
to tkhtml3
Hello,

I understand that tkhtml is pretty much dead, but I am hoping that there is someone here that could give me some help. I have been using the tkhtml3 binaries from ActiveState teapot. Tkhtml works perfectly on 64-bit Linux and 32-bit Windows, but on 64-bit Windows I can't load any HTML. I am using tcl/tk 8.6. I can open tclsh and run:

% package require Tkhtml
% html .h

Everything works fine up to this point. Then I run the following:

% .h parse "<p>test</p>"

The parse command causes the program to hang for a few seconds, and then tclsh crashes without any error codes.
This seems to happen on any 64-bit Tcl 8.6 Windows machine I try, which is quite unfortunate because there are an awful lot of people out there that use 64-bit Windows. I encounter this problem in both ActiveTcl and Python's Tcl. Does anyone happen to know of any solutions or workarounds?

Thank you all very much.

jemptymethod

unread,
Apr 19, 2021, 7:14:14 PM4/19/21
to tkhtml3
Not the "answer" you're looking for but the incompatibility with 64-bit Windows is why I abandoned my "Deskml" project (a platform for creating desktop applications from web technologies like Adobe AIR, or Electron) a decade ago.

C Y

unread,
Apr 19, 2021, 9:26:38 PM4/19/21
to tkh...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "tkhtml3" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tkhtml3+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tkhtml3/4a6d2054-2eac-4971-ace2-40e0baf98764n%40googlegroups.com.

Bob C

unread,
Apr 20, 2021, 11:45:27 AM4/20/21
to tkhtml3
Thank you very much starseeker!
Looking at that message, it seems that it is indeed possible to fix this error by 'explicitly casting all pointers initialized with zero to their appropriate type.' Do you happen to know how to do that? I don't really know how to code C.

AJ Sahukar

unread,
Apr 21, 2021, 7:05:26 AM4/21/21
to tkh...@googlegroups.com
Bob C,

With what Starseeker provided below, you're almost certainly on the right track.

The problem in my experience with this code is that there are places where the code assumes only 32-bit pointers when setting them to '0', resulting in a pointer whose lower 32bits are indeed zero but whose upper 32bits might not be.

A pattern you can look for in failing code tends to look something like:
if (badptr)
{
   // Do something assuming the pointer is valid
}
Check that pointer's address in a debugger or print the address using printf and you're likely to see non-zero values in the upper 32-bits.

Good luck.

Dan Kennedy

unread,
Apr 21, 2021, 7:08:45 AM4/21/21
to tkh...@googlegroups.com


On 21/4/64 09:09, AJ Sahukar wrote:
Bob C,

With what Starseeker provided below, you're almost certainly on the right track.

The problem in my experience with this code is that there are places where the code assumes only 32-bit pointers when setting them to '0', resulting in a pointer whose lower 32bits are indeed zero but whose upper 32bits might not be.

A pattern you can look for in failing code tends to look something like:
if (badptr)
{
   // Do something assuming the pointer is valid
}
Check that pointer's address in a debugger or print the address using printf and you're likely to see non-zero values in the upper 32-bits.


I'm not sure, but I don't think that's the most common case.

I think it's probably "Tcl_AppendResult()" calls you need to look for. Any time a literal "0" or "NULL" is passed to that, change it to "(char*)0" or "(char*)NULL".

Dan.



Bob C

unread,
Apr 21, 2021, 8:06:41 PM4/21/21
to tkhtml3
Hello,

Thank you Dan for the insights.
I have just tried replacing '0' and 'NULL' with '(char*)0' or '(char*)NULL' in all 'Tcl_AppendResult' calls in the source code, but with no avail.
Curiously enough, it seems to take less time for tclsh to crash after calling 'parse' with these changes. Not quite sure what that means.
Do you happen to have any other ideas?

Perhaps adding '(char*)' (replacing 'char' with whatever data type is expected by the function) before '0' and 'NULL' in all function calls (not just 'Tcl_AppendResult' calls) would get me somewhere. It would take a while though.

AJ Sahukar

unread,
Apr 22, 2021, 10:09:59 PM4/22/21
to tkh...@googlegroups.com
Very true, it may not be

However, it was the case in two changes I made to address crashes in 64-bit that worked in 32-bit.

FWIW
Message has been deleted

Bob C

unread,
Apr 27, 2021, 11:05:39 AM4/27/21
to tkhtml3
I have tried the suggestions in this thread and in groups.google.com/g/tkhtml3/c/_O5xXFT66G8, but only ended up with a segmentation fault when compiling. I probably did something wrong (more likely, many things wrong). I mostly use Python and HTML/CSS, so C is certainly not my strong-point. Some people in this group seem to have solved this issue at some point in the past. Does anyone happen to have a copy of the edited/working 64-bit Windows Tkhtml source code? Comparing that to the standard source code would make it a whole lot easier to figure out what is actually causing issues.

Thanks!

C Y

unread,
May 6, 2021, 2:13:00 PM5/6/21
to tkhtml3
We have a version bundled with BRL-CAD with some changes - I don't know if it will work outside our software (we don't normally build it stand-alone), but you can take a look here:

On Tuesday, April 27, 2021, 11:13:43 AM EDT, Bob C <b34hy5...@gmail.com> wrote:


I have tried the suggestions in this thread and in groups.google.com/g/tkhtml3/c/_O5xXFT66G8, but only ended up with a segmentation fault when compiling. I probably did something wrong (more likely, many things wrong). I mostly use Python and HTML/CSS, so C is certainly not my strong-point. Some people in this group seem to have solved this issue at some point in the past. Does anyone happen to have a copy of the edited/working 64-bit Windows Tkhtml source code? Comparing that to the standard source code would make it a whole lot easier to figure out what is actually causing issues.

Thanks!

--
You received this message because you are subscribed to the Google Groups "tkhtml3" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tkhtml3+u...@googlegroups.com.
To view this discussion on the web visit

Bob C

unread,
May 10, 2021, 1:02:54 PM5/10/21
to tkhtml3
Starseeker, I cannot possibly thank you enough.

I merged the altered files from github.com/BRL-CAD/brlcad/tree/main/src/other/tkhtml/src with those in the standard Tkhtml source code and built Tkhtml using mingw. The dll produced works perfectly on 64-bit Windows platforms.

Thank you very much!

Edward HD

unread,
Jun 10, 2025, 8:15:39 PMJun 10
to tkhtml3
Reply all
Reply to author
Forward
0 new messages