[pjsip] Access violation in pj_ioqueue_poll() - anybody see what I might be missing?

Rebecca McFarland rebecca.mcfarland at hotmail.com
Tue Oct 26 13:38:41 CDT 2010

I had a console app with HTTP code based on the httpdemo.c in samples.  Everything was working fine, but I wanted to pull it into a windows app.
I took this chunk from getURL() and pulled it into a new function, loop_http():
while (pj_http_req_is_running(http_req)) {
pj_time_val delay = {0, 50};
pj_ioqueue_poll(ioqueue, &delay);
pj_timer_heap_poll(timer_heap, NULL);
And pulled this code into another function, cleanup_http():
I then called the initial code from getURL() before my windows event loop, and added loop_http() into my windows event loop.
If I run the code with loop_http() still in getURL() (so it never hits the windows event loop), everything is fine.  If I run it with the windows event loop calling loop_http(), I eventually get an access violation in pj_ioqueue_poll 
at the line 
ptr = pj_pool_allocate_find(pool, size);
  MyEXE.exe!pj_pool_create_block(pj_pool_t * pool=0x00fd3e00, unsigned int size=2560)  Line 61 + 0x15 bytes C
  MyEXE.exe!pj_pool_allocate_find(pj_pool_t * pool=0x00fd3e00, unsigned int size=2048)  Line 138 + 0xd bytes C
> MyEXE.exe!pj_pool_alloc(pj_pool_t * pool=0x00fd3e00, unsigned int size=2048)  Line 62 + 0xd bytes C
  MyEXE.exe!http_req_start_sending(pj_http_req * hreq=0x00fd4254)  Line 874 + 0x14 bytes C
  MyEXE.exe!http_on_connect(pj_activesock_t * asock=0x00fd3e64, int status=0)  Line 198 + 0x9 bytes C
  MyEXE.exe!ioqueue_on_connect_complete(pj_ioqueue_key_t * key=0x00fd2490, int status=0)  Line 845 + 0x10 bytes C
  MyEXE.exe!ioqueue_dispatch_write_event(pj_ioqueue_t * ioqueue=0x00fd1edc, pj_ioqueue_key_t * h=0x00fd2490)  Line 271 + 0x10 bytes C
  MyEXE.exe!pj_ioqueue_poll(pj_ioqueue_t * ioqueue=0x00fd1edc, const pj_time_val * timeout=0x002bfab4)  Line 905 + 0x17 bytes C
  MyEXE.exe!loop_http()  Line 276 + 0x10 bytes C
  MyEXE.exe!WinMain(HINSTANCE__ * hInstance=0x00d00000, HINSTANCE__ * hPrevInstance=0x00000000, char * szCmdLine=0x00423305, int iCmdShow=1)  Line 283 C
  MyEXE.exe!__tmainCRTStartup()  Line 578 + 0x35 bytes C
  MyEXE.exe!WinMainCRTStartup()  Line 403 C
  [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] 

I am not doing anything special with pool code, but something appears to be overwriting pool->factory->policy, because block_alloc was initially set and then ends up being set to a null pointer.  I've tried breakpoints in pj_ioqueue_poll() and even in some of the pool.c functions, but I am not finding what is being called that clears that out.  I am sure I am just missing something obvious that is right in front of my face, because that's how these things usually are.
Does anyone have any ideas or any places that I could put a breakpoint in the pool code (or anywhere else) where I might catch the place where the memory is being reset/overwritten?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20101026/6e4e5746/attachment.html>

More information about the pjsip mailing list