Cannot download microsoft symbols when running cdb in a windows service
Asked Answered
O

3

11

I have a .NET windows service that is calling cdb.exe to analyze crash dumps. I want to download the symbols from http://msdl.microsoft.com automatically when needed, using the argument:

-y srv*c:\symbols*http://msdl.microsoft.com/download/symbols

If I run the application as a console application, It works as expected and it downloads the needed symbols for each dump.

The problem is when I start the app as a windows service, the symbols are not downloaded and, if I turn symnoisy on, at cdb's output log I have an entry for each symbol saying that the symbol hasn't been found at http://msdl.microsoft.com

So, I've checked it using a sniffer and the funny thing is that no request is made to the microsoft symbols server when running as a service.

Googling a little, I've found that I'm not the only one with this issue and it seems that the problem is that when running an application as a windows service, it is using winHTTP library for http requests, instead of wininet, which I think is the root of the problem: http://support.microsoft.com/kb/238425

So, I don't know why, cdb is not able to connect to ms symbols server using winHTTP library and I need a way to force cdb use wininet by default.

Anyone has an idea of a workaround to this issue?

Octavalent answered 23/2, 2011 at 18:29 Comment(3)
In what account context does your service run? As SYSTEM you would have limited access to network resources. Starting with Windows 2000 there was a special account for network-related services, though ... this could already be a solution.Scheelite
This was my first thought when I found this problem. I tried to run it as Administrator and System and it didn't work. Besides, the service does some other tasks that are able to connect to internet resources.Octavalent
Thanks for posting this issue, I had the exact same issue with a service we have to get stack-traces from xbox-crash dumbs. So seemingly obscure, but pretty much the only way to start a process on startup on windows.Danaedanaher
B
14

Full answer here: https://web.archive.org/web/20150221111112/http://infopurge.tumblr.com/post/10438913681/how-does-cdb-access-the-microsoft-symbol-server

When running from a Command Prompt, cdb uses WinINet to access internet resources. When running from a Windows service, cdb uses WinHTTP to access internet resources.

For WinHTTP you need to set some registry settings to stop an attempt to use a proxy (bogusproxy) for accessing the symbol server.

You can force cdb to use WinHttp from a command line, and thus emulate what is happening within the service for test purposes by typing the following before loading cdb.

SET DBGHELP_WINHTTP=AnythingOtherThanEmpty

To disable the WinHTTP proxy for cdb and symsrv you need to set the one of the following keys in the registry.

For x32 version of cdb running on a x32 bit machine from the Windows Service environment. HKLM\Software\Microsoft\Symbol Server\NoInternetProxy DWORD 1.

For x32 version of cdb running on a x32 bit machine from a Command Prompt. HKEY_CURRENT_USER\Software\Microsoft\Symbol Server\NoInternetProxy DWORD 1.

For x32 version of cdb running on a x64 bit machine from the Windows Service environment. HKLM\Software\Wow6432Node\Microsoft\Symbol Server\NoInternetProxy DWORD 1.

For x32 version of cdb running on a x64 bit machine from a Command Prompt. HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Symbol Server\NoInternetProxy DWORD 1.

For x64 version of cdb running on a x64 bit machine from the Windows Service environment. HKLM\Software\Microsoft\Symbol Server\NoInternetProxy DWORD 1.

For x64 version of cdb running on a x64 bit machine from a Command Prompt. HKEY_CURRENT_USER\Software\Microsoft\Symbol Server\NoInternetProxy DWORD 1.

Bernetta answered 12/5, 2011 at 7:10 Comment(7)
Thank you very much for the answer. This issue was still unsolved for me. I will try it as soon as I can.Octavalent
No problem. Check out www.StackHash.com too. It might offer the functionality that you were trying to implement off the shelf.Bernetta
stackhash.com redirects to fwdservice.com which in turns returns no content. Is it still legit?Elo
Wow! And I thought that I would be the only lunatic who would want to runn cdb.exe as background service :) Thanks! Problem solved!Necessity
It is 2018 and solution still works for cdb 10.0.16299.15. Link at the top of the page no longer available (only through webarchive), but it is not really necessary to apply the fix. Thanks for the answer!Juback
Thanks for that answer. I've put these into a reg file gist.github.com/discostu105/176e7af5af9cb7aa18396538a220a82fKliber
Using the 'NoInternetProxy' fixed the issue for me when running process via task-scheduler. Thanks for the .reg file @KliberDanaedanaher
C
3

You can also do the opposite - force dbghelp.dll to use WinInet instead of WinHTTP by adding

DBGHELP_WININET=1

to the system environment. It will fix the issue in cdb.exe and other tools that use dbghelp.dll, symchk.exe for example.

Calpe answered 29/9, 2017 at 14:36 Comment(0)
B
2

The same issue arises when running from the Task Scheduler. I've tried using different accounts, to no avail, until I found this post.

I'm launching CDB from a python script (that performs all the 'magic' in getting the right prerequisites in place) and to ease the launch of python I've created a small batch script.

Adding the environment variable as described by sekogan solved the issue.

@echo off
setlocal
REM Forcing CDB to use WinInet instead of WinHTTP when running as a 
REM 'service' due to that WinHTTP uses some bogus proxy when not run from 
REM the console.
set DBGHELP_WININET=1

set PYTHONPATH=<your path>
call <path to venv>\Scripts\python.exe -m <script module> <params>

endlocal
Barite answered 31/5, 2018 at 7:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.