From nobody@FreeBSD.org  Tue Jan 12 11:01:08 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 167911065670
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Jan 2010 11:01:08 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 062A68FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Jan 2010 11:01:08 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0CB17kN038764
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Jan 2010 11:01:07 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o0CB174V038763;
	Tue, 12 Jan 2010 11:01:07 GMT
	(envelope-from nobody)
Message-Id: <201001121101.o0CB174V038763@www.freebsd.org>
Date: Tue, 12 Jan 2010 11:01:07 GMT
From: Luca Pizzamiglio <luca.pizzamiglio@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: pmcstat segmentation fault with Intel Core CPU
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         142742
>Category:       i386
>Synopsis:       [patch] pmcstat segmentation fault with Intel Core CPU
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jkoshy
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 12 11:10:00 UTC 2010
>Closed-Date:    Tue Jan 12 17:05:17 UTC 2010
>Last-Modified:  Tue Jan 12 17:10:04 UTC 2010
>Originator:     Luca Pizzamiglio
>Release:        7-STABLE
>Organization:
>Environment:
FreeBSD pcXX.xxxx.de 7.2-STABLE FreeBSD 7.2-STABLE #0 r2462M: Tue Dec 22 12:31:48 CET 2009     root@pcXX.xxxx.de:/usr/obj/usr/home/prog/svnsys/src_7stable/sys/BW7Dev  i386
>Description:
pmcstat utility crashes with a segmentation fault.
I've analyzed the problem that resides in the libpmc library.

For INTEL CORE architecture (PMC_CPU_INTEL_CORE), initialization of the pmc_class_table[] array of lib/libpmc/libpmc.c is not completed and this causes the segmentation fault during the use of the pmcstat utility.

The CPU I'm using now has the follow level 1 CPUID:
cpuid level 0x1: 0x000006ec 0x00010800 0x0000c109 0xafe9fbff
that means:
Family 0x600 and Model 0x0e


>How-To-Repeat:
Running pmcstat with an INTEL CORE CPU.
The problem appears both in sampling and counting mode.
>Fix:
I propose a patch to solve this problem: I've tested a bit and seems to work. 

This patch corrects the set up of the pmc_class_table[] array of lib/libpmc/libpmc.c when a PMC_CPU_INTEL_CORE CPU is recognized.



Patch attached with submission follows:

--- lib/libpmc/libpmc.c.orig	2010-01-11 16:43:47.000000000 +0100
+++ lib/libpmc/libpmc.c	2010-01-11 16:43:59.000000000 +0100
@@ -2507,6 +2507,7 @@
 		break;
 	case PMC_CPU_INTEL_CORE:
 		PMC_MDEP_INIT(core);
+		pmc_class_table[n] = &core_class_table_descr;
 		break;
 	case PMC_CPU_INTEL_CORE2:
 	case PMC_CPU_INTEL_CORE2EXTREME:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->jkoshy 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Tue Jan 12 14:00:56 UTC 2010 
Responsible-Changed-Why:  
Joseph, 
can you please check this issue? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=142742 
State-Changed-From-To: open->closed 
State-Changed-By: jkoshy 
State-Changed-When: Tue Jan 12 17:04:14 UTC 2010 
State-Changed-Why:  
Fixed in [202157]; thank you for the patch! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=142742 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: i386/142742: commit references a PR
Date: Tue, 12 Jan 2010 17:04:05 +0000 (UTC)

 Author: jkoshy
 Date: Tue Jan 12 17:03:55 2010
 New Revision: 202157
 URL: http://svn.freebsd.org/changeset/base/202157
 
 Log:
   Bug fix: add a missing initializer.
   
   Submitted by:	Luca Pizzamiglio <luca.pizzamiglio at gmail dot com>
   PR:		i386/142742
 
 Modified:
   head/lib/libpmc/libpmc.c
 
 Modified: head/lib/libpmc/libpmc.c
 ==============================================================================
 --- head/lib/libpmc/libpmc.c	Tue Jan 12 16:40:13 2010	(r202156)
 +++ head/lib/libpmc/libpmc.c	Tue Jan 12 17:03:55 2010	(r202157)
 @@ -2543,6 +2543,7 @@ pmc_init(void)
  		break;
  	case PMC_CPU_INTEL_CORE:
  		PMC_MDEP_INIT(core);
 +		pmc_class_table[n] = &core_class_table_descr;
  		break;
  	case PMC_CPU_INTEL_CORE2:
  	case PMC_CPU_INTEL_CORE2EXTREME:
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
