Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi/single.tcl segfaults #30

Open
wusspuss opened this issue Jan 28, 2025 · 3 comments
Open

multi/single.tcl segfaults #30

wusspuss opened this issue Jan 28, 2025 · 3 comments

Comments

@wusspuss
Copy link

#0  0x0000555555663410 in ?? ()
#1  0x00007ffff77539ba in curl_multi_info_read () from /usr/lib/libcurl.so.4
#2  0x00007ffff7b06175 in curlMultiGetInfo (interp=0x55555556a9a0, 
    curlMultiHandlePtr=0x5555556e6860) at ./generic/multi.c:389
#3  0x00007ffff7b05e1f in curlMultiObjCmd (clientData=0x5555556aadf0, 
    interp=0x55555556a9a0, objc=2, objv=0x5555555786c0)
    at ./generic/multi.c:187
#4  0x00007ffff7e3a7e9 in TclNRRunCallbacks (
    interp=interp@entry=0x55555556a9a0, result=0, rootPtr=0x0)
    at /usr/src/debug/tcl/tcl8.6.16/generic/tclBasic.c:4541
#5  0x00007ffff7e3a874 in Tcl_EvalObjv (interp=interp@entry=0x55555556a9a0, 
    objc=objc@entry=2, objv=objv@entry=0x5555555786c0, 
    flags=flags@entry=2097168)
    at /usr/src/debug/tcl/tcl8.6.16/generic/tclBasic.c:4260
#6  0x00007ffff7e3c974 in TclEvalEx (interp=interp@entry=0x55555556a9a0, 
    script=0x5555555c2ee1 "$curlMultiHandle getinfo]\"\n\nputs -nonewline \"Removing the easy handle: \"\nputs [$curlMultiHandle removehandle $curlEasyHandle]\n\nputs -nonewline \"Cleanup the multi handle handle: \"\nputs [$curlMultiHandl"..., numBytes=<optimized out>, flags=flags@entry=0, line=42, 
    clNextOuter=<optimized out>, 
    outerScript=0x5555555c2b40 "package require TclCurl\n\nproc Perform {multiHandle} {\n    if {[catch {$multiHandle active} activeTransfers]} {\n        puts \"Error checking active transfers: $activeTransfers\"\n        return -1\n    }\--T--Type <RET> for m--Type <RET>--Type <R--Type <R--T--T--T--Type--Type--T--T--T--T--Type--Type--Type--T--T--T--T--T--T--T--T--T--Type <RET--Type <RET> for more, q to quit, c to continue without paging--c
n"...) at /usr/src/debug/tcl/tcl8.6.16/generic/tclBasic.c:5409
#7  0x00007ffff7f15df8 in TclSubstTokens (interp=interp@entry=0x55555556a9a0, tokenPtr=<optimized out>, tokenPtr@entry=0x555555578098, count=1, tokensLeftPtr=tokensLeftPtr@entry=0x0, 
    line=<optimized out>, line@entry=42, clNextOuter=<optimized out>, clNextOuter@entry=0x0, 
    outerScript=0x5555555c2b40 "package require TclCurl\n\nproc Perform {multiHandle} {\n    if {[catch {$multiHandle active} activeTransfers]} {\n        puts \"Error checking active transfers: $activeTransfers\"\n        return -1\n    }\n"...) at /usr/src/debug/tcl/tcl8.6.16/generic/tclParse.c:2298
#8  0x00007ffff7e3c82d in TclEvalEx (interp=interp@entry=0x55555556a9a0, 
    script=0x5555555c2b40 "package require TclCurl\n\nproc Perform {multiHandle} {\n    if {[catch {$multiHandle active} activeTransfers]} {\n        puts \"Error checking active transfers: $activeTransfers\"\n        return -1\n    }\n"..., numBytes=<optimized out>, flags=flags@entry=0, line=42, line@entry=1, clNextOuter=clNextOuter@entry=0x0, 
    outerScript=0x5555555c2b40 "package require TclCurl\n\nproc Perform {multiHandle} {\n    if {[catch {$multiHandle active} activeTransfers]} {\n        puts \"Error checking active transfers: $activeTransfers\"\n        return -1\n    }\n"...) at /usr/src/debug/tcl/tcl8.6.16/generic/tclBasic.c:5297
#9  0x00007ffff7f00553 in Tcl_FSEvalFileEx (interp=interp@entry=0x55555556a9a0, pathPtr=pathPtr@entry=0x5555555a7260, encodingName=<optimized out>)
    at /usr/src/debug/tcl/tcl8.6.16/generic/tclIOUtil.c:1827
#10 0x00007ffff7f08ca5 in Tcl_MainEx (argc=<optimized out>, argc@entry=2, argv=argv@entry=0x7fffffffe4f8, appInitProc=appInitProc@entry=0x555555555160 <Tcl_AppInit>, interp=0x55555556a9a0)
    at /usr/src/debug/tcl/tcl8.6.16/generic/tclMain.c:403
#11 0x000055555555504b in main (argc=2, argv=0x7fffffffe4f8) at /usr/src/debug/tcl/tcl8.6.16/unix/tclAppInit.c:91

I did build tclcurl-fa with --enable-symbols so not sure where that ?? could be coming from. I get this error on archlinux, both with tclcurl built locally and with kitcreator's tclkits.

curl 8.11.1-3
tcl 8.6.16-1
@bovine
Copy link
Member

bovine commented Jan 29, 2025

This is using the unmodified version of the tests/multi/single.tcl script? Do you have a webserver running locally that can serve http://127.0.0.1/index.html?

Is this with the current master branch, or the another released version of this repo?

Does this package work for you otherwise in your development work?

@wusspuss
Copy link
Author

wusspuss commented Jan 29, 2025

This is using the unmodified version of the tests/multi/single.tcl script?

Yes.

Do you have a webserver running locally that can serve http://127.0.0.1/index.html?

Yes, but it segfauls with and without a server, it segfaults if I give it a remote url too

Is this with the current master branch

Yes.

Does this package work for you otherwise in your development work?

No. This is the first time I tried the package - I discovered it segfaulting in my code first.

My own example to make it segfault:

package require TclCurl
set m [curl::multiinit]
set h [curl::init]

$h configure -url https://api.ipify.org?format=json
$m addhandle $h
# $m methods work fine until you call $m perform
puts "active: [$m getinfo]"

while {1} {
    set r [$m perform]
    if {$r<=0} {
	break
    }
}
# the $h methods don't segfault
puts "code: [$h getinfo httpcode]"
# $m active doesn't segfault
puts "active: [$m active]"
# This will segfault
puts [$m getinfo]
# So will seemingly any other method of $m, like
$m removehandle $h

Also I poked around with the C code a bit - I made it print the output of curl_multi_get_handles before removing the handle - it turned out empty after you call perform. I'm not too familiar with curl, but afaik that's not how that's supposed to be, the handle is supposed to be manually removed.

@bovine
Copy link
Member

bovine commented Jan 29, 2025

We do have another ticket #12 that points out other issues with this test file, which might actually be the same underlying issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants