添加计数器时Perflib 2崩溃(来自Perfmon) [英] Perflib 2 crashes when adding a counter (from Perfmon)

查看:286
本文介绍了添加计数器时Perflib 2崩溃(来自Perfmon)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++应用程序(在Win32下),我需要提供性能计数器信息。我使用Perflib v2,所以创建了一个由CTRPP处理的清单。



我的提供者然后调用PerfAutoInitialize和PerfCreateInstance没有错误。



当我去添加计数器在Perfmon ,我的应用程序崩溃。通过反汇编进行跟踪显示了perflib工作线程中调用内部函数(pcwum.dll)PerfpAddOrRemoveCounter的代码。这调用PerfpValidateCounter,它返回一个地址edi;此地址无效,当调用者解除引用时,应用程序崩溃。



如果我重新启动提供程序,计数器在Perfmon中仍然可见,

清单如下

 < instrumentationManifest xsi:schemaLocation =http:// schemas .microsoft.com / win / 2004/08 / events eventman.xsd
xmlns:win =http://manifests.microsoft.com/win/2004/08/windows/events
xmlns :xsi =http://www.w3.org/2001/XMLSchema-instance
xmlns:xs =http://www.w3.org/2001/XMLSchema
xmlns:trace =http://schemas.microsoft.com/win/2004/08/events/trace>
< instrumentation>
< counters xmlns =http://schemas.microsoft.com/win/2005/12/counters>
< provider callback =custom
applicationIdentity =TPerfStatsCollector.exe
providerName =TPerfstatscollector
providerType =userMode
providerGuid ={33d68436 -4cf9-4f58-9976-44b048b072f3}
symbol =symbolGUID>
< counterSet guid ={381300a5-3be6-46d8-8615-12d8b259aae4}
uri =A.AxPServer.Counters.Basic
name =基本计数器
description =这些是样本计数器
instances =Single
symbol =setGUID>
< counter id =1
uri =A.AxPServer.Counters.Basic.Session
name =Sessions
description =会话数
type =perf_counter_rawcount
detailLevel =standard
defaultScale =1>
< / counter>
< / counterSet>
< / provider>
< / counters>
< / instrumentation>
< / instrumentationManifest>


解决方案

这是一个64/32位的问题,我意识到,我正在构建一个32位提供程序运行在64位操作系统。所有工作正常,当这被矫直了。


I have a C++ application (under Win32) for which I need to provide performance counter information. I'm using Perflib v2, so have created a manifest which is processed by CTRPP.

My provider then calls PerfAutoInitialize and PerfCreateInstance with no errors.

When I go to add the counter in Perfmon, my application crashes. Tracing through the disassembly shows the code in the perflib worker thread calling the internal function (pcwum.dll) PerfpAddOrRemoveCounter. This calls on to PerfpValidateCounter which returns an address in edi; this address is invalid and when caller dereferences it, the application crashes.

If I restart my provider, the counter is still visible in Perfmon and increments correctly.

Manifest follows

<instrumentationManifest xsi:schemaLocation="http://schemas.microsoft.com/win/2004/08/events eventman.xsd"
     xmlns:win="http://manifests.microsoft.com/win/2004/08/windows/events"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:trace="http://schemas.microsoft.com/win/2004/08/events/trace">
  <instrumentation>
    <counters xmlns="http://schemas.microsoft.com/win/2005/12/counters">
      <provider callback = "custom"
        applicationIdentity = "TPerfStatsCollector.exe"
            providerName = "TPerfstatscollector"
        providerType = "userMode"
        providerGuid = "{33d68436-4cf9-4f58-9976-44b048b072f3}"
        symbol = "symbolGUID">
        <counterSet guid = "{381300a5-3be6-46d8-8615-12d8b259aae4}"
          uri = "A.AxPServer.Counters.Basic"
          name = "Basic counters"
          description = "These are the sample counters"
          instances = "Single"
          symbol = "setGUID">
          <counter id = "1"
            uri = "A.AxPServer.Counters.Basic.Session"
            name = "Sessions"
            description = "Number of sessions"
            type = "perf_counter_rawcount"
            detailLevel = "standard"
            defaultScale = "1">            
          </counter>
        </counterSet>
      </provider>
   </counters>
  </instrumentation>
</instrumentationManifest>

解决方案

My bad. This was a 64/32 bit issue and I realised that I was building a 32 bit provider to run on a 64 bit OS. All works fine when this was straightened out.

这篇关于添加计数器时Perflib 2崩溃(来自Perfmon)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆