The most strange bugs have the strangest solutions. Just an hour ago I was trying to debug a queueConstructor (it returns a malloc'd pointer to a queue data structure), right after I finished implementing the operations for a stack data structure. Malloc was inexplicably causing the program to hang (I don't know if it's a segfault, I was using Windows). printfing around the constructor and inside it didn't work. I had included all the libraries I needed to, syntax was good, no warnings, I even changed the declarations from int
var to int var.
It turns out the problem was that in main() just before I called queueConstructor, I added the item 633346 as an integer element in my stack data structure. Whether this overflowed the integer, I don't know. But I don't know why it would stop malloc for a different data structure stored in a different variable from working (perhaps it was occupying some memory that my queue wanted?).
This isn't the first time bugs like this happen, and as a novice programmer I really wish tools were better, or I knew how to use the tools. GDB available via CodeBlocks wasn't helpful.