* * * * *

    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 [1] 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 [2]—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() [3], 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 (Common
Gateway Interface) [4] 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() [5], 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.

[1] gopher://gopher.conman.org/0Phlog:2015/06/05.2
[2] gopher://gopher.conman.org/0Phlog:2004/12/05.2
[3] https://github.com/spc476/mod_blog/blob/3e0662eea842754d8ec9bc922112670f23091384/src/cgi_main.c#L374
[4] http://en.wikipedia.org/wiki/Common_Gateway_Interface
[5] https://github.com/spc476/mod_blog/commit/3e0662eea842754d8ec9bc922112670f23091384

Email author at [email protected]