Posted to tcl by dizach at Mon May 17 08:00:19 GMT 2010view raw

  1. Function wibble::getblock hangs tcl under cetrain conditions, when using Internet Explorer 8. For a discussion on this see http://wiki.tcl.tk/23626
  2.  
  3. To figure out whether this is a wibble or a tcl bug, the problem can be reproduced with the following:
  4.  
  5. Put the html code into a file 'wibble_test.html' in wibble's root directory:
  6.  
  7. <html>
  8. <head>
  9. <script>
  10. ajax = function (url,f,p,m) {
  11. // f=callback, m=method (GET|POST), p=post data
  12. var req = null;
  13. if (window.XMLHttpRequest) {
  14. req = new XMLHttpRequest();
  15. if (req.overrideMimeType) {
  16. req.overrideMimeType('application/jsonrequest');
  17. }
  18. } else if (window.ActiveXObject) {
  19. try {
  20. req = new ActiveXObject("Msxml2.XMLHTTP");
  21. } catch (e) {
  22. try {
  23. req = new ActiveXObject("Microsoft.XMLHTTP");
  24. } catch (e) {}
  25. }
  26. }
  27. req.onreadystatechange = function() {
  28. if(req.readyState == 4) {
  29. if(req.status == 200 || req.status == 304) {
  30. f(req.responseText);
  31. } else {
  32. //alert("Error: returned status code " + req.status + " " + req.statusText);
  33. }
  34. }
  35. };
  36. req.open((m?m:"GET"), url, true);
  37. if (m) {
  38. req.setRequestHeader("Content-type", "application/x-www-form-urlencoded'; charset=utf-8'");
  39. }
  40. req.send(p);
  41. };
  42. gotReply = function (h) {
  43. var el=document.createElement("p");
  44. el.innerHTML = h;
  45. element.parentNode.appendChild(el);
  46. };
  47. askWibble = function (el) {
  48. element = el;
  49. ajax("/test",gotReply,encodeURI("a=this&b=is&c=a&d=test"),"POST");
  50. el=document.createElement("p");
  51. el.innerHTML = "asking wibble...<br/>";
  52. element.parentNode.appendChild(el);
  53. };
  54. </script>
  55. </head>
  56. <body>
  57. <input type='button' value='Press this' onclick='askWibble(this)'/>
  58. </body>
  59. </html>
  60.  
  61.  
  62. Replace wibble::getblock with:
  63.  
  64. proc ::wibble::getblock {chan size} {
  65. puts stderr size=$size
  66. while {1} {
  67. set chunklet [chan read $chan $size]
  68. puts stderr "{$size - [string length $chunklet]}"
  69. set size [expr {$size - [string length $chunklet]}]
  70. append chunk $chunklet
  71. if {$size == 0} {
  72. puts stderr "return size==0"
  73. return $chunk
  74. } elseif {[chan eof $chan]} {
  75. chan close $chan
  76. puts stderr "return eof"
  77. return -level [info level]
  78. } else {
  79. puts stderr "before yield"
  80. yield
  81. puts stderr "after yield"
  82. }
  83. }
  84. }
  85.  
  86.  
  87. Add test zone proc 'mytest':
  88.  
  89. proc ::mytest {request response} {
  90. dict set response content "<tt style='color:#080'>This is Wibble. Ask me more!</tt>"
  91. dict set response header content-type text/html
  92. dict set response status "200 ok"
  93. ::wibble::sendresponse $response
  94. }
  95.  
  96.  
  97. Add test zone handler
  98.  
  99. ...
  100. # Define zone handlers.
  101.  
  102. # Add test zone handler.
  103. wibble::handle /test ::mytest
  104.  
  105. wibble::handle /vars vars
  106. ...
  107.  
  108. Run wibble and direct IE8 (only Internet Explorer has the problem) to:
  109. http://localhost:8080/wibble_test.html
  110.  
  111. Tcl hangs with 100% CPU load.