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

Fix: decoder parse panic recover #2

Merged
merged 1 commit into from
Apr 5, 2022
Merged

Conversation

MakingL
Copy link
Contributor

@MakingL MakingL commented Mar 31, 2022

Hi, I found there is a mistake of Decoder panic recover.

How To Reproduction

You panic in Decoder Parser, where panic("just test panic") is added for test on purpose.

func (dec *Decoder) Parse(cb func(object model.RedisObject) bool) (err error) {
	defer func() {
		if err2 := recover(); err2 != nil {
			err = fmt.Errorf("panic: %v", err2)
		}
	}()
	panic("just test panic")
	err = dec.checkHeader()
	if err != nil {
		return err
	}
	return dec.parse(cb)
}

and run cmd go test parser_test.go, there will show you info:

--- FAIL: TestToJson (0.01s)
    parser_test.go:103: error occurs during parse memory, err: panic: just test panic
    parser_test.go:103: error occurs during parse quicklist, err: panic: just test panic
    parser_test.go:103: error occurs during parse easily_compressible_string_key, err: panic: just test panic
    parser_test.go:103: error occurs during parse empty_database, err: panic: just test panic
    parser_test.go:103: error occurs during parse hash, err: panic: just test panic
    parser_test.go:103: error occurs during parse hash_as_ziplist, err: panic: just test panic
    parser_test.go:103: error occurs during parse integer_keys, err: panic: just test panic
    parser_test.go:103: error occurs during parse intset_16, err: panic: just test panic
    parser_test.go:103: error occurs during parse intset_32, err: panic: just test panic
    parser_test.go:103: error occurs during parse intset_64, err: panic: just test panic
    parser_test.go:103: error occurs during parse keys_with_expiry, err: panic: just test panic
    parser_test.go:103: error occurs during parse linkedlist, err: panic: just test panic
    parser_test.go:103: error occurs during parse multiple_databases, err: panic: just test panic
    parser_test.go:103: error occurs during parse non_ascii_values, err: panic: just test panic
    parser_test.go:103: error occurs during parse parser_filters, err: panic: just test panic
    parser_test.go:103: error occurs during parse rdb_version_5_with_checksum, err: panic: just test panic
    parser_test.go:103: error occurs during parse rdb_version_8_with_64b_length_and_scores, err: panic: just test panic
    parser_test.go:103: error occurs during parse regular_set, err: panic: just test panic
    parser_test.go:103: error occurs during parse regular_sorted_set, err: panic: just test panic
    parser_test.go:103: error occurs during parse sorted_set_as_ziplist, err: panic: just test panic
    parser_test.go:103: error occurs during parse uncompressible_string_keys, err: panic: just test panic
    parser_test.go:103: error occurs during parse ziplist_that_compresses_easily, err: panic: just test panic
    parser_test.go:103: error occurs during parse ziplist_that_doesnt_compress, err: panic: just test panic
    parser_test.go:103: error occurs during parse ziplist_with_integers, err: panic: just test panic
    parser_test.go:103: error occurs during parse zipmap_that_compresses_easily, err: panic: just test panic
    parser_test.go:103: error occurs during parse zipmap_that_doesnt_compress, err: panic: just test panic
    parser_test.go:103: error occurs during parse zipmap_with_big_values, err: panic: just test panic
    parser_test.go:103: error occurs during parse zipmap_big_len, err: panic: just test panic
--- FAIL: TestMemoryProfile (0.00s)
    parser_test.go:142: error occurs during parse cases/memory.rdb, err: panic: just test panic
--- FAIL: TestToAof (0.00s)
    parser_test.go:180: error occurs during parse cases/memory.rdb, err: panic: just test panic
--- FAIL: TestFindLargestKeys (0.00s)
    parser_test.go:223: FindLargestKeys failed: panic: just test panic
    parser_test.go:39: line number is not equal
    parser_test.go:236: result is not equal of cases/memory.rdb
--- FAIL: TestFlameGraph (0.00s)
    parser_test.go:255: FindLargestKeys failed: panic: just test panic
    parser_test.go:259: Get "http://localhost:18888/flamegraph": dial tcp 127.0.0.1:18888: connect: connection refused
FAIL
FAIL    command-line-arguments  0.099s
FAIL

@HDT3213 HDT3213 merged commit 46388c9 into HDT3213:master Apr 5, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants