Skip to content

memory leak if binding failed #1390

Description

@zouyonghao

Describe the bug (描述bug)
memory leak when binding failed

To Reproduce (复现方法)
bind a used port

Expected behavior (期望行为)

Versions (各种版本)
OS: Ubuntu 18.04
Compiler: clang + ASan
brpc: 0.9.0
protobuf: 3.0.0

Additional context/screenshots (更多上下文/截图)

E0428 03:47:30.283096 117030 /home/zyh/incubator-brpc/src/brpc/server.cpp:956] Fail to listen 0.0.0.0:8301
E0428 03:47:30.283232 117030 /home/zyh/braft/example/atomic/server.cpp:508] Fail to start Server


=================================================================
==117030==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 56 byte(s) in 1 object(s) allocated from:
    #0 0x6d14ad in operator new(unsigned long) (/home/zyh/braft/example/atomic/atomic_server+0x6d14ad)
    #1 0xca1961 in brpc::Server::StartInternal(in_addr const&, brpc::PortRange const&, brpc::ServerOptions const*) /home/zyh/incubator-brpc/src/brpc/server.cpp:783
    #2 0xca330e in brpc::Server::Start(butil::EndPoint const&, brpc::ServerOptions const*) /home/zyh/incubator-brpc/src/brpc/server.cpp:1063
    #3 0xca34b2 in brpc::Server::Start(int, brpc::ServerOptions const*) /home/zyh/incubator-brpc/src/brpc/server.cpp:1081
    #4 0x6d5038 in main /home/zyh/braft/example/atomic/server.cpp:507:16
    #5 0x7fa2b2449bf6 in __libc_start_main /build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:310

SUMMARY: AddressSanitizer: 56 byte(s) leaked in 1 allocation(s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugthe code does not work as expected

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions