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

Panic if TLS fluentd server cannot be connected #119

Open
richarticle opened this issue Jul 14, 2023 · 0 comments
Open

Panic if TLS fluentd server cannot be connected #119

richarticle opened this issue Jul 14, 2023 · 0 comments

Comments

@richarticle
Copy link

richarticle commented Jul 14, 2023

Running below code will panic if fluentd server cannot be connected.

package main

import (
    "github.com/fluent/fluent-logger-golang/fluent"
)

func main() {
    f, _ := fluent.New(fluent.Config{FluentNetwork: "tls", FluentPort: 11111, FluentHost: "127.0.0.1", Async: false})
    f.Post("tag", map[string]string{"log": "msg"})
    f.Post("tag", map[string]string{"log": "msg"})
}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x59b539]

goroutine 1 [running]:
crypto/tls.(*Conn).SetWriteDeadline(0xc00010baa8?, {0x5f3dd6?, 0x2c?, 0x0?})
        /usr/local/go/src/crypto/tls/conn.go:153 +0x19
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).write.func3(0xc000122000, 0xc0000267b0)
        /home/oliver/go/pkg/mod/github.com/fluent/[email protected]/fluent/fluent.go:606 +0x10e
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).write(0xc000122000, {0x6a8898?, 0xc0000180a8?}, 0xc0000267b0)
        /home/oliver/go/pkg/mod/github.com/fluent/[email protected]/fluent/fluent.go:611 +0xd7
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).writeWithRetry(0xc000122000, {0x6a8898, 0xc0000180a8}, 0xc000026750?)
        /home/oliver/go/pkg/mod/github.com/fluent/[email protected]/fluent/fluent.go:558 +0x5c
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).postRawData(0xc000122000?, 0x644ca5?)
        /home/oliver/go/pkg/mod/github.com/fluent/[email protected]/fluent/fluent.go:300 +0x5b
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).EncodeAndPostData(0x614720?, {0x644ca5?, 0x644c81?}, {0x3?, 0xc0000167f0?, 0x7e7da0?}, {0x614720, 0xc000026750})
        /home/oliver/go/pkg/mod/github.com/fluent/[email protected]/fluent/fluent.go:283 +0xb5
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).PostWithTime(0xc000122000, {0x644ca5?, 0x16365a5d5533203e?}, {0x638f20?, 0x1?, 0x7e7da0?}, {0x614840?, 0xc000026720})
        /home/oliver/go/pkg/mod/github.com/fluent/[email protected]/fluent/fluent.go:274 +0x4ee
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).Post(0x614840?, {0x644ca5, 0x3}, {0x614840, 0xc000026720})
        /home/oliver/go/pkg/mod/github.com/fluent/[email protected]/fluent/fluent.go:226 +0x59
main.main()
        /home/oliver/go/projects/test/main.go:9 +0xdc

In Fluent.connect(), below line assigns f.conn a *tls.Conn object instead of net.Conn interface object. Therefore, "f.conn == nil" returns false even if tls.Conn is nil.

f.conn, err = tls.DialWithDialer(
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

1 participant