archive.is
archive.is copied to clipboard
Wayback() is causing a crash
Bug Report
Current Behavior The below code is causing the the program to crash:
package main
import (
"context"
"fmt"
"net/url"
"time"
is "github.com/wabarc/archive.is"
)
func main() {
wbrc := &is.Archiver{}
url, _ := url.Parse(`https://gnu.org`)
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
println("Archiving...")
if result, err := wbrc.Wayback(ctx, url); err != nil {
fmt.Printf("ERROR: %v\n", err)
} else {
fmt.Printf("Success: %v\n", result)
}
}
The TTY output:
Archiving...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x5e326e]
goroutine 1 [running]:
net/http.(*Client).deadline(0x40bea7?)
/usr/lib/go-1.21/src/net/http/client.go:194 +0xe
net/http.(*Client).do(0x0, 0xc000182100)
/usr/lib/go-1.21/src/net/http/client.go:608 +0x209
net/http.(*Client).Do(...)
/usr/lib/go-1.21/src/net/http/client.go:590
github.com/wabarc/archive%2eis.(*Archiver).Do(0xc000199ef0, 0xc000182100)
/home/ramon/src/go/pkg/mod/github.com/wabarc/[email protected]/is.go:97 +0x74
github.com/wabarc/archive%2eis.(*Archiver).getSubmitID(0x4?, {0x6e41b5, 0x12})
/home/ramon/src/go/pkg/mod/github.com/wabarc/[email protected]/is.go:213 +0x38b
github.com/wabarc/archive%2eis.(*Archiver).getValidDomain.func1({0x919fa0?, 0x7, 0x0?})
/home/ramon/src/go/pkg/mod/github.com/wabarc/[email protected]/is.go:241 +0x8c
github.com/wabarc/archive%2eis.(*Archiver).getValidDomain(0xc000199ef0, 0xc000199e58)
/home/ramon/src/go/pkg/mod/github.com/wabarc/[email protected]/is.go:252 +0x83
github.com/wabarc/archive%2eis.(*Archiver).archive(0xc000199ef0, {0x75d2b0, 0xc0001920e0}, 0xc000199e58, 0x439114?)
/home/ramon/src/go/pkg/mod/github.com/wabarc/[email protected]/is.go:136 +0x6e
github.com/wabarc/archive%2eis.(*Archiver).Wayback(0x6e199d?, {0x75d2b0?, 0xc0001920e0?}, 0xc0000061a0?)
/home/ramon/src/go/pkg/mod/github.com/wabarc/[email protected]/is.go:113 +0x3b
main.main()
/home/ramon/src/go/src/test/main.go:33 +0xc8
exit status 2
Expected behavior/code The code should not crash.
Environment
- github.com/wabarc/archive.is v1.4.0
- go1.21.1 linux/amd64
- Ubuntu 23.10
Possible Solution N/A
Additional context/Screenshots N/A
Thanks for opening this issue. We should be by to give feedback soon. In the meantime, please check out the contributing guidelines.
Please use is.NewArchiver instead.