Bug 201291

Summary: devel/gdb: Incorrect thread names in core file
Product: Ports & Packages Reporter: Eric Badger <eric>
Component: Individual Port(s)Assignee: Tijl Coosemans <tijl>
Status: Closed FIXED    
Severity: Affects Only Me CC: cs, koobs, luca.pizzamiglio
Priority: --- Keywords: easy, needs-qa, patch
Version: LatestFlags: luca.pizzamiglio: maintainer-feedback+
koobs: merge-quarterly?
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch to avoid sysctl when inferior is a core file koobs: maintainer-approval+

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 freebsd_triage 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

Log:
  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)

Changes:
  head/devel/gdb/Makefile
  head/devel/gdb/files/fbsd-threads.c
Comment 6 Kubilay Kocak freebsd_committer freebsd_triage 2015-10-20 03:49:14 UTC
@Tijl Benefit to MFH?