|
2020-11-16
| ||
| 14:16 | • Closed ticket [708d2cbe63]: http error: can't read "state(sock)": ... artifact: e819d7fa3a user: oehhar | |
|
2020-07-26
| ||
| 13:53 | • Ticket [708d2cbe63]: 4 changes artifact: 54a57cca47 user: oehhar | |
|
2020-07-24
| ||
| 18:19 | • Ticket [708d2cbe63]: 3 changes artifact: d3b4c69c66 user: kjnash | |
|
2018-03-15
| ||
| 12:45 | • Ticket [708d2cbe63]: 3 changes artifact: 273d938e9c user: oehhar | |
| 12:40 | • Ticket [708d2cbe63]: 3 changes artifact: 69c29abcbf user: oehhar | |
| 08:46 | • New ticket [708d2cbe63]. artifact: 2ce8bab56d user: oehhar | |
http error: can't read "state(sock)": no such element in array
I get the error "can't read "state(sock)": no such element in array" probably as backround error when doing a geturl.
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]]
Within the geturl, the http::Log logs the following:
Using rc2 for accessgudid.nlm.nih.gov:443
The geturl call returns with hReq ="::http::3".
Then, there are the following http logs:
final chunk part Closing socket rc2 (no connection info)
The callback (QueryCont) is called with argument "::http::3":
The following commands are probably called (where status and cleanup are surely called):
http::status $hReq http::error $hReq http::ncode $hReq http::data $hReq http::cleanup $hReq
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):
> can't read "state(totalsize)": no such element in array
> while executing
> "if {
> ($state(totalsize) > 0)
> && ($state(currentsize) >= $state(totalsize))
> } {
> Eof $token
> }"
This error was extracted, by changing the procedure http::Finish as follows:
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"
}
and the error stack:
> INNER:loadArray1 > CALL:http::Event rc2 ::http::3
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:
> 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"
and the error stack:
> INNER:loadArray1
> CALL:Finish ::http::3 {can't read "state(totalsize)": no such element in array}
> CALL:http::Event rc2 ::http::3
I personally have no clue what happens.
The error line is protected by:
if {[info exists state]} {
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.
Version Info
- 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:
Protect http::Finish against unexisting state(sock)
Line 215, Procedure http::Finish
Check for existance of "state(sock)" before calling "CloseSocket $state(sock) $token".
Thus add a :
if {[info exists state(sock)] && (
.... the other conditions here )
} {
CloseSocket $state(sock) $token
}
Protect the event handler against existing but empty state array
Change in "http::Event" line 1163:
if {[info exists state]} {
into
if {[info exists state(totalsize)]} {
Report in a way an error of the callback function
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:
if {[catch {eval $state(-command) {$token}} err] && $errormsg eq ""} {
set state(error) [list $err $errorInfo $errorCode]
set state(status) error
}
may be replaced by:
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
}
}
I personally would prefer to call bgerror...
Sorry for the weak ticket. This took some ours to find the upper information... Harald
Hi Harald, Did you ever get this problem again? Best wishes, Keith Nash.
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