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

Why linkToDbNative must be called before linkToDb? #507

Open
kcudnik opened this issue Jul 22, 2021 · 5 comments
Open

Why linkToDbNative must be called before linkToDb? #507

kcudnik opened this issue Jul 22, 2021 · 5 comments
Assignees
Labels

Comments

@kcudnik
Copy link
Contributor

kcudnik commented Jul 22, 2021

According to this comment https://github.com/Azure/sonic-swss-common/blob/master/common/logger.h#L81, why? If this is public API it should not be dependent of call order. Could this method be private or this issue should be fixed in proper way.

@mikeberesford
Copy link

I'd add that if the call order is required and changing the public API isn't possible, the API should probably enforce the call order - once linkToDbNative is called, calls to linkToDb should probably result in an error instead of succeeding silently.

@kcudnik
Copy link
Contributor Author

kcudnik commented Jul 23, 2021

btw. calling linkToDbNative twiece will carash beceuse previous thread is still running when dtr is called

#0  0x00007f5d1d85920b in raise () from /lib64/libc.so.6
#1  0x00007f5d1d83b524 in abort () from /lib64/libc.so.6
#2  0x00007f5d1dc04657 in ?? () from /usr/lib64/libstdc++.so.6
#3  0x00007f5d1dc0fef6 in ?? () from /usr/lib64/libstdc++.so.6
#4  0x00007f5d1dc0ff41 in std::terminate() () from /usr/lib64/libstdc++.so.6
#5  0x00007f5d1ddf82ca in std::thread::~thread (this=<optimized out>, __in_chrg=<optimized out>) at /usr/include/c++/9.1.0/thread:139
#6  std::default_delete<std::thread>::operator() (this=0x7f5d1de5b380 <swss::Logger::getInstance()::m_logger+160>, __ptr=<optimized out>)
    at /usr/include/c++/9.1.0/bits/unique_ptr.h:81
#7  std::unique_ptr<std::thread, std::default_delete<std::thread> >::reset (__p=<optimized out>, this=0x7f5d1de5b380 <swss::Logger::getInstance()::m_logger+160>)
    at /usr/include/c++/9.1.0/bits/unique_ptr.h:399
#8  swss::Logger::linkToDbNative (dbName="syncd") at logger.cpp:152

@kcudnik
Copy link
Contributor Author

kcudnik commented Jul 23, 2021

also, why we need to create new thread every time linkToDbNative is called ?

@kcudnik
Copy link
Contributor Author

kcudnik commented Jul 24, 2021

i was looking on logger code for half day and i couldn't figure out why linkToDbNative must be called before linkToDb :(

@qiluo-msft
Copy link
Contributor

@marian-pritsak Could you help check this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants