c++ - app -> extension crash on callback invocation -


i have marmalade extension , sample app passes c-callback function extension, happens whenever extension tries call function, crashes mysterious message:

exception type: exc_bad_access (sigsegv) exception codes: kern_invalid_address @ 0x00000008 crashed thread: 0

although, before call function print it's address , it's different , seems valid. marmalade restrictions or doing wrong?

p.s: worth notice compile marmalade extension clang (not gcc) , works fine, callbacks... although used default marmalade gcc before , had same issue.

sample app:

class cdemoapp { public:     static cdemoapp* getinstance() {         static cdemoapp instance;         return &instance;     }      void setup()     {         app = createapp();         window = createwindow();         app->addwindow(window);         view = createview("canvas");          button = createbutton();          button->seteventhandler("click", (void*)null, cdemoapp::onbutton1click);          view->addchild(button);         window->setchild(view);          app->showwindow(window);     }      void run() {         app->run();     }      static void onsdkinit(const char* err, void* context) {         printf("done.\n");     }      static bool onbutton1click(void* data, cbutton* button) {         if(!s3emyextdidinitialize()) {             // crash happens here.             // extension doesn't perform ops, calls callback dummy arguments             s3emyextdoinitialize(app_id, app_secret, cdemoapp::onsdkinit, null);         }          return true;     }  private:     cdemoapp() {};  private:     cappptr app;     cwindowptr window;     cviewptr view;     cbuttonptr button; };  // main entry point application int main() {     if(!s3emyextavailable())     {         s3edebugerrorshow(s3e_message_continue, "my extension not found");         return 0;     }      cdemoapp::getinstance()->setup();     cdemoapp::getinstance()->run();      return 0; } 

the function s3emyextdoinitialize exposed extension looks that:

typedef void (*my_callback)(const char* error, void* context); void s3emyextdoinitialize_platform(const char* appid, const char* appsecret, my_callback callback, void* context) {      callback(null, null);  } 

well, apparently there's no way pass function pointer app extension directly, marmalade offers own callbacks system should utilized things work.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -