views:

1041

answers:

3

From what I gather, Google Chrome can run browser plugins written using NPAPI.

I've written one that does its job just fine in Firefox, but makes Chrome crash and burn as soon as you embed it on a page. I don't even have to call any of my methods, embedding is enough to cause a crash.

How do I debug this? I tried attaching the debugger to chrome but the stack traces I get are deep down in Chrome itself and like I said, none of "my" actual code is being run, but supposedly just the NPAPI init code.

I'd appreciate some pointers.

+2  A: 

Chrome is open-source... have you tried downloading the source and building it? That way, you at least can point your IDE to the source code tree and have it auto-attach when it crashes, which can give you a bit more information as to what happened.

This won't solve your bug, of course, but it might help you report one to the Chrome team. As you very well know, the plugin API is fairly new to Chrome, and it's possible that the bug is theirs and not yours.

Nik Reiman
+4  A: 

The Chromium dev docs describe some tricks for attaching Visual Studio to Chrome processes: Chromium Developer Documentation > Debugging Chromium.

Some problems you might be facing with an NPAPI plugin in Chrome:

  • Your plugin will be running in a separate process from the Chrome UI. (You probably know this already :)
  • If multiple instances of your plugin are loaded (in the same HTML page or in different Chrome tabs), your plugin instances will be running in the same process together. If you have global variables, your plugin instances might be stomping on each other.
  • Chrome uses DEP (Data Execution Protection), but Firefox does not. If you are using ATL or other JITted code tricks, DEP can crash your plugin.
cpeterso
Firefox 3 and up use DEP
Taxilian
+2  A: 

As it turns out, part of the initialization code from the old NPAPI plugin example I was using caused the crash. I'm sorry to say I solved this quite a while back and can't seem to locate the specific modifications I made to fix it in the version control history. Anyway, my problem is fixed and was caused by me being stupid and blindly trusting the example code.

korona