Saturday, June 06, 2015
I'm lucky in that I run the server, so I can do this type of debugging
As I was unable to reproduce the issue on the development system, but it was all too easy to reproduce on server, I had no choice but to debug on the server. It's not an ideal situation but in this case, as I run the server in question and the appropriate software tools are installed, I figured I might as well debug on the server.
The approach I took is one I've been using for a long time—insert this bit of code:
volatile int g_debug = 1; while(g_debug) ;
into the proper code path (in this case,
the program was crashing in
cmd_cgi_post_show()
,
which is the function called when I want to preview a post from the web interface).
Then I can submit the data,
the web server will spawn mod_blog
,
and the infinite loop will give me a chance to attach the debugger to it
(setting up a fake web environment to debug
CGI programs is a pain).
And from there,
it was pretty straightforward to isolate the issue by setting breakpoints and examining memory.
The issue ended up being multiple calls to free()
,
and I suppose the difference in behavior between the development system and server can be attributed to the different versions of the standard C library.
Yes,
in an ideal world,
there would be no difference between the two,
but this isn't an ideal world and I have to make do with what I have.