Overview
| Artifact ID: | 69c29abcbff4a45769e038c23078c97d5ca19068d3fe78357e437e9f2727a1f4 |
|---|---|
| Ticket: | 708d2cbe636a8bbc4175dd83e18c0355c2fa1dc7
http error: can't read "state(sock)": no such element in array |
| User & Date: | oehhar on 2018-03-15 12:40:20 |
Changes
- 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"