Bug 201291 - devel/gdb: Incorrect thread names in core file
Summary: devel/gdb: Incorrect thread names in core file
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Tijl Coosemans
Keywords: easy, needs-qa, patch
Depends on:
Reported: 2015-07-02 19:22 UTC by Eric Badger
Modified: 2015-10-20 03:49 UTC (History)
3 users (show)

See Also:
luca.pizzamiglio: maintainer-feedback+
koobs: merge-quarterly?

Patch to avoid sysctl when inferior is a core file (416 bytes, patch)
2015-07-02 19:22 UTC, Eric Badger
koobs: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Badger 2015-07-02 19:22:30 UTC
Created attachment 158261 [details]
Patch to avoid sysctl when inferior is a core file

If a core file has thread TIDs which overlap TIDs of running processes on the system analyzing the core file, the thread names of the currently running, local processes may be reported as names of threads in the core file.

The fbsd_find_lwp_name() function in fbsd-threads.c looks up thread names by sysctl, passing in a 'pid' (actually a TID) even for core files. My first thought would be to not do this unless we're debugging a live target, but I'm not sure if this is the best way to handle this. Attached a possible patch.
Comment 1 luca.pizzamiglio 2015-10-19 09:43:02 UTC
This patch works for me
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2015-10-19 09:47:42 UTC
@Luca, setting maintainer-feedback so we know the issue is not waiting on you is great. 

Additionally, we do need explicit instructions on whether you 'approve' a proposed change or not, for ports you are MAINTAINER of.

This can either be in the form of a comment:

I approve attachment <id>

Or for patches you submit, you can set the maintainer-approval flag to (+)
Comment 3 luca.pizzamiglio 2015-10-19 09:54:31 UTC
Comment on attachment 158261 [details]
Patch to avoid sysctl when inferior is a core file

Approving the attachment 158261 [details]
Please portrevision should be also bumped.
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2015-10-19 09:58:38 UTC
Protip: A complete diff against the port is preferable.

With regard to patch-* files in files/, please generate these using `make makepatch`. For more information see: https://www.freebsd.org/doc/en/books/porters-handbook/slow-patch.html
Comment 5 commit-hook freebsd_committer 2015-10-19 19:53:47 UTC
A commit references this bug:

Author: tijl
Date: Mon Oct 19 19:52:48 UTC 2015
New revision: 399717
URL: https://svnweb.freebsd.org/changeset/ports/399717

  Don't look up thread names when examining core files.  The names are only
  available when a process is running.

  PR:		201291
  Submitted by:	Eric Badger <eric@badgerio.us>
  Approved by:	luca.pizzamiglio@gmail.com (maintainer)

Comment 6 Kubilay Kocak freebsd_committer freebsd_triage 2015-10-20 03:49:14 UTC
@Tijl Benefit to MFH?