Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Debugging a problem that doesn't show up on any machine with Visual Studio installed?

Posted on 2006-07-20
8
Medium Priority
?
542 Views
Last Modified: 2013-12-14
I'm having a problem with my browser plugin in firefox.  It runs fine, but when it exits, the plugin crashes and Firefox traps the error so that the browser doesn't crash.  The problem is the crash only happens on machines which don't have Visual studio installed on so I can't exactly trace through the code.  How would I go about debugging this?

The best I can come up with is I'm including something to do with debugging in a release build, but I have no idea how I can track it down.

If you want to see it in action the plugin can be installed from http://www.buildingtogo.com/yecho/torque/dual.html

It also only happens in Firefox.  It doesn't IE doesn't crash (Or at least it never reports it).
0
Comment
Question by:GENTP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 19

Expert Comment

by:mrwad99
ID: 17148999
>> The problem is the crash only happens on machines which don't have Visual studio installed on so I can't exactly trace through the code

That means that your plugin has some dependency that is only resolved when VS is installed, like MSVC71.dll for example.  I suggest you check out the dependencies with depends (check out depends.exe, it ships with VS) of your plugin, and see where that leads you to.

HTH
0
 
LVL 5

Author Comment

by:GENTP
ID: 17149041
is depends.exe included in 2003.net or is it just in 2005?
0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 17149045
>>The problem is the crash only happens on machines which don't have Visual studio installed on so I can't
>>exactly trace through the code.

Run the Dependency Walker (www.dependencywalker.com) in "Profile" mode, the logfile that is created will already reveal a lot of issues. Apart from that install an exception filter in your plugin and check what's going on. If you have the faulting address (RVA) and a map file (generated when linking your plugin), you can find the faulting function using the following method:

Consider

#include <windows.h>
#include <stddef.h>
#include <stdio.h>

LONG
WINAPI
ExceptionHandler(LPEXCEPTION_POINTERS pe) {

    char acModule[MAX_PATH];

    MEMORY_BASIC_INFORMATION mbi;
    HMODULE hMod;

    VirtualQuery (pe->ExceptionRecord->ExceptionAddress,&mbi,sizeof(mbi));

    ptrdiff_t RVA = (char*)pe->ExceptionRecord->ExceptionAddress - (char*)mbi.AllocationBase;

    hMod = (HMODULE) mbi.AllocationBase;

    GetModuleFileName(hMod,acModule,sizeof (acModule));

    printf( "Detected Exception in %s at RVA 0x%08X\n", acModule, RVA);

    return EXCEPTION_EXECUTE_HANDLER;
}

void FaultingFunction () {

    LONG* p = NULL;
    *p = 42;
}

void main(){

    SetUnhandledExceptionFilter (ExceptionHandler);
    FaultingFunction ();
}

(compiled with "cl rvaxcept.cpp /link /map")

which prints

Detected Exception in C:\tmp\cc\rvaxcept.exe at RVA 0x00001088

The map file is

rvaxcept

Timestamp is 44660958 (Sat May 13 18:29:12 2006)

Preferred load address is 00400000

Start         Length     Name                   Class
0001:00000000 00004938H .text                   CODE
[...]

 Address         Publics by Value              Rva+Base     Lib:Object

0001:00000000       _ExceptionHandler@4        00401000 f   rvaxcept.obj
0001:0000007a       _FaultingFunction          0040107a f   rvaxcept.obj
0001:00000092       _main                      00401092 f   rvaxcept.obj
0001:000000a7       _printf                    004010a7 f   LIBC:printf.obj
0001:000000d8       _mainCRTStartup            004010d8 f   LIBC:crt0.obj
0001:000001b7       __amsg_exit                004011b7 f   LIBC:crt0.obj
[...]

You can see the 'Rva+Base' column, base is given as 'Preferred load address is 00400000'

Add that to the faulting module RVA of 0x00001088 and you get 0x00401088, then look that up in the above (i.e. the 'nearest symbol' and you can see that it is 'FaultingFunction'

0001:0000007a       _FaultingFunction          0040107a f   rvaxcept.obj
0001:00000092       _main                      00401092 f   rvaxcept.obj

The address is between main and FaultingFunction, which starts before 0x00401088, the next function is main and starts later.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Author Comment

by:GENTP
ID: 17154072
I can't seem to run the profiler because the plugin is a dll and not an executable.  I've got it up but I don't understand the program well enough to figure out whats going on.  The only thing that really showed up was msjava.dll which in their faq says happens and it doesn't matter.  I also exported the data on the machine that crashes and the machine that works and only 2 dates on dll's are different.  Everything else is the same.

As for adding this faulting function code I'm not really understanding it.  Do I actually create the faultingfunction or is that just an example that causes a crash of some sort?

I'm also having a problem compiling it.  Probably because the initialization functions of the plugin are in a class not like an executables main function. At least I THINK thats the problem.  Maybe you can tell me otherwise:
 
C:\Projects\tge14\TGE14Plugin\engine\np3DPlugin\plugin.cpp(159): error C2664: 'SetUnhandledExceptionFilter' : cannot convert parameter 1 from 'LONG (LPEXCEPTION_POINTERS)' to 'LPTOP_LEVEL_EXCEPTION_FILTER'
        None of the functions with this name in scope match the target type

The plugin starts off in this class:
class nsPluginInstance : public nsPluginInstanceBase
{
public:
   nsPluginInstance(NPP aInstance);
   ~nsPluginInstance();

   NPBool init(NPWindow* aWindow);

I tried to put that one line in init().
0
 
LVL 5

Author Comment

by:GENTP
ID: 17154205
Nevermind the compile problem.  I got it to work.
0
 
LVL 86

Expert Comment

by:jkr
ID: 17154241
>>I can't seem to run the profiler because the plugin is a dll and not an executable.

Err, you should profile Firefox ;o)

BTW, the exception filter cannot be a class method unless it is static. Just copy&paste it from the above.
0
 
LVL 5

Author Comment

by:GENTP
ID: 17155679
Okay I ran Dependency walker on the plugin and put the results up here http://www.buildingtogo.com/yecho/exit.zip
The txt file in the zip is everything in the shutdown code.  It crashes somewhere in there, but I don't see anything.  the .dwi is the Dep. walker file for the process.  I'm not sure if that has any useful information in it though.


As for the code, I have it compiling but I can't find the option in visual studio which enables the /link command.  I found the /map commands and I think I set that part up properly.  I'm just fuzzy as to what else I need to do to get a result out of the function.

Generate Debug Info: No

Generate Map File: Yes (/MAP)
Map File Name: mappitymap.map
Map Exports: Yes (/MAPINFO:EXPORTS)
Map Lines: Yes (/MAPINFO:LINES)

What else do I have to set if anything?
0
 
LVL 86

Expert Comment

by:jkr
ID: 17156617
The link settings seem OK. What you should do is output the results accordingly (FF has no console, so the 'printf()' won't help, e.g.

LONG
WINAPI
ExceptionHandler(LPEXCEPTION_POINTERS pe) {

    char acModule[MAX_PATH];

    MEMORY_BASIC_INFORMATION mbi;
    HMODULE hMod;

    VirtualQuery (pe->ExceptionRecord->ExceptionAddress,&mbi,sizeof(mbi));

    ptrdiff_t RVA = (char*)pe->ExceptionRecord->ExceptionAddress - (char*)mbi.AllocationBase;

    hMod = (HMODULE) mbi.AllocationBase;

    GetModuleFileName(hMod,acModule,sizeof (acModule));

    char buf[1024];

    wsprintf( buf,"Detected Exception 0x%8.8x in %s at RVA 0x%08X\n", pe->ExceptionRecord.ExceptionCode,acModule, RVA);

    OutputDebugString(buf);

    return EXCEPTION_EXECUTE_HANDLER;
}

and check the results using e.g. DebugView (http://www.sysinternals.com/Utilities/DebugView.html)

The other log file does not even indicate that there was a crash.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question