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

Wayback() is causing a crash #49

Open
ram-on opened this issue Apr 4, 2024 · 2 comments
Open

Wayback() is causing a crash #49

ram-on opened this issue Apr 4, 2024 · 2 comments
Labels
enhancement New feature or request go Pull requests that update Go code help wanted Extra attention is needed

Comments

@ram-on
Copy link

ram-on commented Apr 4, 2024

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

Copy link

welcome bot commented Apr 4, 2024

Thanks for opening this issue. We should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@waybackarchiver
Copy link
Contributor

Please use is.NewArchiver instead.

@waybackarchiver waybackarchiver added enhancement New feature or request help wanted Extra attention is needed go Pull requests that update Go code labels Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go Pull requests that update Go code help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants