Chat freely about anything...

User avatar
By captain_morgan
#40747 I'm curious if there are any know issues with calling a function pointer from an event callback. In this case I'm trying to call from a `espconn_regist_recvcb` callback. In my `user_main` I can check the memory address of the actual function, and the pointer to it and they match. 0x40244eb4. I then pass a pointer to the structure that contains it to another function, the pointer is saved in a reference in that library. I can check the value of this pointer, it matches the address of the actual struct, 0x3ffffac0 and the function pointer still points to the correct address. 0x40244eb4.

Now my tcp_recv_cb gets call on the arrive of a packet and I would expect that function pointer to still point at 0x40244eb4... nope, it's now 3. Simply.... 3.

I know it's hard to judge without seeing code, I'm working on a reduced test case but maybe someone can explain some nuance of calling function pointers from other function pointers I've missed.
User avatar
By captain_morgan
#40756 I've made a minimal test case showing it's still happening.

https://gist.github.com/morganrallen/61 ... 6308fa58ec

The style of the code is directly inspired by SpriteTM's libesphttpd callback work flow. In that code, the espconn_recv_callback passes to another function but essentially call the cgi function pointer within the context
of the tcp callback. I cannot figure out where my code differs. Halp!