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

TID in the files and on the stack trace not matching #872

Open
amandeepgautam opened this issue Nov 8, 2022 · 5 comments
Open

TID in the files and on the stack trace not matching #872

amandeepgautam opened this issue Nov 8, 2022 · 5 comments

Comments

@amandeepgautam
Copy link

amandeepgautam commented Nov 8, 2022

In the stack trace, we see something like this:

*** SIGSEGV (@0x149d) received by PID 22298 (TID 0x36087700) from PID 5277; stack trace: ***

In the files, we see:
I1107 17:38:43.965498 22378 xx.cc:nnn]

22378 is supposed to be the thread id and so is: 0x36087700. I skimmed over the code and seems like 2 different functions are used to compute the values:

(a)

pthread_t id = pthread_self();

(b)
pid_t GetTID() {

What is the relation between the two? How do I know which TID caused the crash?

@sergiud
Copy link
Collaborator

sergiud commented Nov 8, 2022

The difference is expected as per gettid documentation:

The thread ID returned by this call is not the same thing as a POSIX thread ID (i.e., the opaque value returned by pthread_self(3)).

The answer to your question depends on how you intend to identify your threads.

@amandeepgautam
Copy link
Author

@sergiud I want to look at which thread caused the crash. Is there a way to know that?
Out of curiosity, why not call the same function at both places?

@sergiud
Copy link
Collaborator

sergiud commented Nov 8, 2022

I want to look at which thread caused the crash. Is there a way to know that?

I'm not sure I understand what are you asking given you have two IDs at your disposal. Choose the one that suits your tooling.

Out of curiosity, why not call the same function at both places?

This is likely an inconsistency that arose over time. You are welcome to provide a fix.

@amandeepgautam
Copy link
Author

I'm not sure I understand what are you asking given you have two IDs at your disposal. Choose the one that suits your tooling.

@sergiud We have a stack trace of the crash with an ID: 0x36087700. I want to see the log files and see what this thread was doing before crashing. In a multi-threaded env. this can be really helpful.

This is likely an inconsistency that arose over time. You are welcome to provide a fix.

Which function is preferable: GetTID or pthread_self? I will see if I can fix it.

@sergiud
Copy link
Collaborator

sergiud commented Nov 9, 2022

For consistency and information gain both functions should be used.

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

Successfully merging a pull request may close this issue.

2 participants