Artifacts Associated With Ticket 708d2cbe636a8bbc
Ticket change [2ce8bab56d] (rid 161847) by oehhar on 2018-03-15 08:46:58:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
I was able to reproduce the following 10 times and then, it disappeared. So I write everything I know here: I get the error "can't read "state(sock)": no such element in array" probably as backround error when doing a geturl. <verbatim> package require http package require twapi_crypto http::register https 443 [list ::twapi::tls_socket] set URL "https://accessgudid.nlm.nih.gov/api/v1/devices/lookup.xml?" append URL [http::formatQuery di 30705031060139] set hReq [http::geturl $URL -command [namespace code [list QueryCont 30705031060139]] </verbatim> Within the geturl, the http::Log logs the following: <verbatim> Using rc2 for accessgudid.nlm.nih.gov:443 </verbatim> The geturl call returns with hReq ="::http::3". Then, there are the following http logs: <verbatim> final chunk part Closing socket rc2 (no connection info) </verbatim> The callback (QueryCont) is called with argument "::http::3": The following commands are probably called (where status and cleanup are surely called): <verbatim> http::status $hReq http::error $hReq http::ncode $hReq http::data $hReq http::cleanup $hReq </verbatim> Then, the event handler is called by "http::Event rc2 ::http::3" and causes a catched error trace (line 1169): <verbatim> > can't read "state(totalsize)": no such element in array > while executing > "if { > ($state(totalsize) > 0) > && ($state(currentsize) >= $state(totalsize)) > } { > Eof $token > }" </verbatim> This error was extracted, by changing the procedure http::Finish as follows: <verbatim> proc http::Finish {token {errormsg ""} {skipCB 0}} { variable $token upvar 0 $token state global errorInfo errorCode if {$errormsg ne ""} { mainLog 2 "Socket error: $errormsg" set state(error) [list $errormsg $errorInfo $errorCode] set state(status) "error" } </verbatim> and the error stack: <verbatim> > INNER:loadArray1 > CALL:http::Event rc2 ::http::3 </verbatim> So the command mainLog was included which prints the error Trace and Stack to the console. The final error of the background error is as follows: <verbatim> > can't read "state(sock)": no such element in array > while executing > "CloseSocket $state(sock) $token" > (procedure "Finish" line 15) > invoked from within > "Finish $token $err" > (procedure "http::Event" line 167) > invoked from within > "http::Event rc2 ::http::3" </verbatim> and the error stack: <verbatim> > INNER:loadArray1 > CALL:Finish ::http::3 {can't read "state(totalsize)": no such element in array} > CALL:http::Event rc2 ::http::3 </verbatim> I personally have no clue what happens. The error line is protected by: <verbatim> if {[info exists state]} { </verbatim> so this should not happen. The state array seems empty (see http log "Closing socket rc2 (no connection info)") but "info exists state" seems to be true. The CloseSocket call (documented by the same http log) should have stopped the fileevent readable. <h2>Version Info</h2> * Windows 10 64 bit PRO GER * TCL/Tk 8.6.8 32 bit self compiled with ms-vc6 * http package version: 2.8.12 * twapi crypto version: 4.2.12 So there are two possible modifications: <h2> Protect http::Finish against unexisting state(sock) </h2> Line 215, Procedure http::Finish Check for existance of "state(sock)" before calling "CloseSocket $state(sock) $token". Thus add a : <verbatim> if {[info exists state(sock)] && ( .... the other conditions here ) } { CloseSocket $state(sock) $token } </verbatim> <h2> Protect the event handler against existing but empty state array </h2> Change in "http::Event" line 1163: <verbatim> if {[info exists state]} { </verbatim> into <verbatim> if {[info exists state(totalsize)]} { </verbatim> Sorry for the weak ticket. This took some ours to find the upper information... Harald - foundin initialized to: "8.6.8"
- is_private initialized to: "0"
- login: "oehhar"
- priority initialized to: "5 Medium"
- private_contact initialized to: "0f366eb3e9e2fcab52b8ebacd197db9047186a5f"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "oehhar"
- subsystem initialized to: "29. http Package"
- title initialized to:
http error: can't read "state(sock)": no such element in array
- type initialized to: "Bug"
Ticket change [69c29abcbf] (rid 161855) by oehhar on 2018-03-15 12:40:20:
- comment changed to:
I was able to reproduce the following 10 times and then, it disappeared. So I write everything I know here: I get the error "can't read "state(sock)": no such element in array" probably as backround error when doing a geturl. <verbatim> package require http package require twapi_crypto http::register https 443 [list ::twapi::tls_socket] set URL "https://accessgudid.nlm.nih.gov/api/v1/devices/lookup.xml?" append URL [http::formatQuery di 30705031060139] set hReq [http::geturl $URL -command [namespace code [list QueryCont 30705031060139]] </verbatim> Within the geturl, the http::Log logs the following: <verbatim> Using rc2 for accessgudid.nlm.nih.gov:443 </verbatim> The geturl call returns with hReq ="::http::3". Then, there are the following http logs: <verbatim> final chunk part Closing socket rc2 (no connection info) </verbatim> The callback (QueryCont) is called with argument "::http::3": The following commands are probably called (where status and cleanup are surely called): <verbatim> http::status $hReq http::error $hReq http::ncode $hReq http::data $hReq http::cleanup $hReq </verbatim> Then, the command QueryCont ran into an error "unknown variable" like "set UnknownVar". Then, the event handler is called by "http::Event rc2 ::http::3" and causes a catched error trace (line 1169): <verbatim> > can't read "state(totalsize)": no such element in array > while executing > "if { > ($state(totalsize) > 0) > && ($state(currentsize) >= $state(totalsize)) > } { > Eof $token > }" </verbatim> This error was extracted, by changing the procedure http::Finish as follows: <verbatim> proc http::Finish {token {errormsg ""} {skipCB 0}} { variable $token upvar 0 $token state global errorInfo errorCode if {$errormsg ne ""} { mainLog 2 "Socket error: $errormsg" set state(error) [list $errormsg $errorInfo $errorCode] set state(status) "error" } </verbatim> and the error stack: <verbatim> > INNER:loadArray1 > CALL:http::Event rc2 ::http::3 </verbatim> So the command mainLog was included which prints the error Trace and Stack to the console. The final error of the background error is as follows: <verbatim> > can't read "state(sock)": no such element in array > while executing > "CloseSocket $state(sock) $token" > (procedure "Finish" line 15) > invoked from within > "Finish $token $err" > (procedure "http::Event" line 167) > invoked from within > "http::Event rc2 ::http::3" </verbatim> and the error stack: <verbatim> > INNER:loadArray1 > CALL:Finish ::http::3 {can't read "state(totalsize)": no such element in array} > CALL:http::Event rc2 ::http::3 </verbatim> I personally have no clue what happens. The error line is protected by: <verbatim> if {[info exists state]} { </verbatim> so this should not happen. The state array seems empty (see http log "Closing socket rc2 (no connection info)") but "info exists state" seems to be true. The CloseSocket call (documented by the same http log) should have stopped the fileevent readable. <h2>Version Info</h2> * Windows 10 64 bit PRO GER * TCL/Tk 8.6.8 32 bit self compiled with ms-vc6 * http package version: 2.8.12 * twapi crypto version: 4.2.12 So there are two possible modifications: <h2> Protect http::Finish against unexisting state(sock) </h2> Line 215, Procedure http::Finish Check for existance of "state(sock)" before calling "CloseSocket $state(sock) $token". Thus add a : <verbatim> if {[info exists state(sock)] && ( .... the other conditions here ) } { CloseSocket $state(sock) $token } </verbatim> <h2> Protect the event handler against existing but empty state array </h2> Change in "http::Event" line 1163: <verbatim> if {[info exists state]} { </verbatim> into <verbatim> if {[info exists state(totalsize)]} { </verbatim> Sorry for the weak ticket. This took some ours to find the upper information... Harald - login: "oehhar"
- mimetype: "text/plain"
- comment changed to:
Ticket change [273d938e9c] (rid 161857) by oehhar on 2018-03-15 12:45:04:
- comment changed to:
I was able to reproduce the following 10 times and then, it disappeared. So I write everything I know here: I get the error "can't read "state(sock)": no such element in array" probably as backround error when doing a geturl. <verbatim> package require http package require twapi_crypto http::register https 443 [list ::twapi::tls_socket] set URL "https://accessgudid.nlm.nih.gov/api/v1/devices/lookup.xml?" append URL [http::formatQuery di 30705031060139] set hReq [http::geturl $URL -command [namespace code [list QueryCont 30705031060139]] </verbatim> Within the geturl, the http::Log logs the following: <verbatim> Using rc2 for accessgudid.nlm.nih.gov:443 </verbatim> The geturl call returns with hReq ="::http::3". Then, there are the following http logs: <verbatim> final chunk part Closing socket rc2 (no connection info) </verbatim> The callback (QueryCont) is called with argument "::http::3": The following commands are probably called (where status and cleanup are surely called): <verbatim> http::status $hReq http::error $hReq http::ncode $hReq http::data $hReq http::cleanup $hReq </verbatim> Then, the command QueryCont ran into an error "unknown variable" like "set UnknownVar". Then, the event handler is called by "http::Event rc2 ::http::3" and causes a catched error trace (line 1169): <verbatim> > can't read "state(totalsize)": no such element in array > while executing > "if { > ($state(totalsize) > 0) > && ($state(currentsize) >= $state(totalsize)) > } { > Eof $token > }" </verbatim> This error was extracted, by changing the procedure http::Finish as follows: <verbatim> proc http::Finish {token {errormsg ""} {skipCB 0}} { variable $token upvar 0 $token state global errorInfo errorCode if {$errormsg ne ""} { mainLog 2 "Socket error: $errormsg" set state(error) [list $errormsg $errorInfo $errorCode] set state(status) "error" } </verbatim> and the error stack: <verbatim> > INNER:loadArray1 > CALL:http::Event rc2 ::http::3 </verbatim> So the command mainLog was included which prints the error Trace and Stack to the console. The final error of the background error is as follows: <verbatim> > can't read "state(sock)": no such element in array > while executing > "CloseSocket $state(sock) $token" > (procedure "Finish" line 15) > invoked from within > "Finish $token $err" > (procedure "http::Event" line 167) > invoked from within > "http::Event rc2 ::http::3" </verbatim> and the error stack: <verbatim> > INNER:loadArray1 > CALL:Finish ::http::3 {can't read "state(totalsize)": no such element in array} > CALL:http::Event rc2 ::http::3 </verbatim> I personally have no clue what happens. The error line is protected by: <verbatim> if {[info exists state]} { </verbatim> so this should not happen. The state array seems empty (see http log "Closing socket rc2 (no connection info)") but "info exists state" seems to be true. The CloseSocket call (documented by the same http log) should have stopped the fileevent readable. <h2>Version Info</h2> * Windows 10 64 bit PRO GER * TCL/Tk 8.6.8 32 bit self compiled with ms-vc6 * http package version: 2.8.12 * twapi crypto version: 4.2.12 So there are two possible modifications: <h2> Protect http::Finish against unexisting state(sock) </h2> Line 215, Procedure http::Finish Check for existance of "state(sock)" before calling "CloseSocket $state(sock) $token". Thus add a : <verbatim> if {[info exists state(sock)] && ( .... the other conditions here ) } { CloseSocket $state(sock) $token } </verbatim> <h2> Protect the event handler against existing but empty state array </h2> Change in "http::Event" line 1163: <verbatim> if {[info exists state]} { </verbatim> into <verbatim> if {[info exists state(totalsize)]} { </verbatim> <h3>Report in a way an error of the callback function</h3> If the callback call fails, there is no error shown. The error state is set if there is no other error. At least, the Log function may be called in this case. So in http::Finish, line 222, this: <verbatim> if {[catch {eval $state(-command) {$token}} err] && $errormsg eq ""} { set state(error) [list $err $errorInfo $errorCode] set state(status) error } </verbatim> may be replaced by: <verbatim> if {[catch {eval $state(-command) {$token}} err]} { Log "Callback failed: $err" if {$errormsg eq ""} { set state(error) [list $err $errorInfo $errorCode] set state(status) error } } </verbatim> I personally would prefer to call bgerror... <hr /> Sorry for the weak ticket. This took some ours to find the upper information... Harald - login: "oehhar"
- mimetype: "text/plain"
- comment changed to:
Ticket change [d3b4c69c66] (rid 185200) by kjnash on 2020-07-24 18:19:44:
- icomment:
Hi Harald, Did you ever get this problem again? Best wishes, Keith Nash.
- login: "kjnash"
- mimetype: "text/plain"
- icomment:
Ticket change [54a57cca47] (rid 185258) by oehhar on 2020-07-26 13:53:34:
- icomment:
Dear Nash, no, I have not observed it again. But I suppose, I have changed my own code. I don't remember. If nobody else sees it, the bug may be closed. Thank you for looking into this, Harald
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"
- icomment:
Ticket change [e819d7fa3a] (rid 188604) by oehhar on 2020-11-16 14:16:50:
- closedate changed to: "2459170.09502744"
- closer changed to: "oehhar"
- login: "oehhar"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"