phuslu / log

Fastest structured logging
MIT License
672 stars 44 forks source link

Disabling compiler optimization and linting breaks phuslu #74

Closed riccardopinosio closed 4 months ago

riccardopinosio commented 4 months ago

Hello,

with the latest release (102) when I build my project with

go build -gcflags="all=-N -l" -o ./test

disabling compiler optimization and linting, the logger breaks at compile time with:

Build Error: ...
github.com/phuslu/log.(*Logger).header: nosplit stack over 792 byte limit
github.com/phuslu/log.(*Logger).header<1>
    grows 1848 bytes, calls sync.(*Pool).Get<1>
        grows 8 bytes, calls runtime.morestack<0>
        1064 bytes over limit
    grows 1848 bytes, calls runtime.gcWriteBarrier2<1>
        grows 8 bytes, calls gcWriteBarrier<22>
            grows 128 bytes, calls runtime.wbBufFlush<0>
                grows 8 bytes, calls runtime.wbBufFlush<1>
                    grows 24 bytes, calls runtime.puintptr.ptr<1>
                    1224 bytes over limit
                    grows 24 bytes, calls runtime.(*wbBuf).discard<1>
                    1224 bytes over limit
                    grows 24 bytes, calls runtime.systemstack<0>
                        grows 16 bytes, calls gosave_systemstack_switch<22>
                            grows 8 bytes, calls runtime.abort<0>
                            1248 bytes over limit
                        grows 16 bytes, calls indirect
                            grows 8 bytes, calls runtime.morestack<0>
                            1248 bytes over limit
                        grows 8 bytes, calls indirect
                            grows 8 bytes, calls runtime.morestack<0>
                            1240 bytes over limit
    grows 1848 bytes, calls runtime.convT<1>
        grows 8 bytes, calls runtime.morestack<0>
        1064 bytes over limit
    grows 1848 bytes, calls runtime.gcWriteBarrier2<1>
        grows 8 bytes, calls gcWriteBarrier<22>
            grows 128 bytes, calls runtime.wbBufFlush<0>
                grows 8 bytes, calls runtime.wbBufFlush<1>
                    grows 24 bytes, calls runtime.puintptr.ptr<1>
                    1224 bytes over limit
                    grows 24 bytes, calls runtime.(*wbBuf).discard<1>
                    1224 bytes over limit
                    grows 24 bytes, calls runtime.systemstack<0>
                        grows 16 bytes, calls gosave_systemstack_switch<22>
                            grows 8 bytes, calls runtime.abort<0>
[...]

I suspect it's due to commit: https://github.com/phuslu/log/commit/83324964c7f62b20d0100b098580d706440bbf89

Note this breaks debugging with vscode and delve. Previous version of phuslu (101) works fine.

RJKeevil commented 4 months ago

This also breaks in Goland 2024.2, same issue

phuslu commented 4 months ago

Oops, I screwed it up. Just now I revert the commit and released/tagged v1.0.103, so sorry!

riccardopinosio commented 4 months ago

Yep I can confirm it works with 1.0.103 :)