Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7892685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:55:55+00:00 2026-06-03T06:55:55+00:00

My plugin code crashes when I call the NPN_GetValue. Basically I created a scriptable

  • 0

My plugin code crashes when I call the NPN_GetValue. Basically I created a scriptable object which has a ‘getDevice’ method that can return a device array to JavaScript. Below is the code snippet.

static bool mainNPObjectInvoke(NPObject *obj, NPIdentifier identifier, const NPVariant *args, uint32_t argCount, NPVariant *result)
{
    printf("create main object");
    MainNPObject *mainObject = (MainNPObject *)obj;

    if (identifier == methodIdentifiers[METHOD_ID_GET_DEVICES])
    {
        NPObject *windowObj = NULL;
        browser->getvalue(mainObject->npp, NPNVWindowNPObject, &windowObj);
        // it crashed here
    ....
    }
}

I created the MainNPObject instance with below method.

NPObject *createMainNPObject(NPP npp)
{
    MainNPObject *object = (MainNPObject *)browser->createobject(npp, &mainNPClass);
    object->npp = npp;

    theMainObject = object;

    return (NPObject *)object;
}

The createMainNPObject is called in the plugin function I provided to browser.

NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
{
    PluginObject *obj = instance->pdata;

    switch (variable) {
        case NPPVpluginCoreAnimationLayer:
            if (!obj->rootLayer)
                setupLayerHierarchy(obj);

            *(CALayer **)value = obj->rootLayer;

            return NPERR_NO_ERROR;

        case NPPVpluginScriptableNPObject:

            if (!obj->mainObject)
            {
                obj->mainObject = createMainNPObject(instance);
            }
 ....
}

And the allocate function is as below.

static NPObject *mainNPObjectAllocate(NPP npp, NPClass *class)
{
    initializeIdentifiers();

    MainNPObject *mainObject = malloc(sizeof(MainNPObject));
    mainObject->deviceManager = [[DeviceManager alloc] init];

    return (NPObject *)mainObject;
}

Definition of MainNPObject:

typedef struct
{
    NPObject *npobject;
    NPP npp;
    DeviceManager *deviceManager;
} MainNPObject;

By debugging the code, I found that the system raised an EXC_BAD_ACCESS when calling the browser->getValue and it looks like the npp pointer is invalid.

0x00007fff83f82dab  <+0019>  je     0x7fff83f82db9 <_ZN6WebKit14NetscapePlugin7fromNPPEP4_NPP+33>
0x00007fff83f82dad  <+0021>  incl   0x8(%rax)

Can someone help me out?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:55:56+00:00Added an answer on June 3, 2026 at 6:55 am

    Hmm; not seeing anything obvious. Try adding another parameter (an int?) to your structure and set it during allocate or immediately afterwords, then later on check to see if it’s still the value you set before you call getvalue. See if your struct is somehow getting corrupt. That happened to me once when I was casting the NPObject funny in a non-obvious way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some plugin code in a dll that is called by a host
In my plugin code I would like to perform a WP_Query (or similar) which
How can I make this plugin code accept default options? // Utility if (
Below is the plugin code that i have tried to reuse from an old
I have some old C# plugin code that was implemented strictly with Reflection. In
I`ve created simple hello world-like plugin which draws red box. Аfter embedding into xulrunner
I've installed a plugin (Code Contract Editor Extensions by Microsoft) which displays all code
My problem: JavaScript calls into the plugin, which forks a thread that opens a
What are good ways of dealing with the issues surrounding plugin code that interacts
I have some plugin code that is supposed to look up the number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.