Nearing the end of the development of my SDL2 game, I suddenly began to get crashes from TTF_RenderText_Blended. It has a perfectly good error reporting mechanism, but no, it didn’t report an error, it CRASHED with an invalid address. I tried a lot of things:
1. I demonstrated that all the parameters to it were valid. No bad pointers. Debugger can dereference them.
2. I tried deleting and reinstalling the SDL2_ttf package. Still crashing.
3. Being on a Mac, I tried using the Framework version (v. 2.24.0) vs the Homebrew-installed version. Still crashing, it seems to make no difference either way.
4. I tried putting calls to TTF_RenderText_Blended at various points rather early in my program, but to try to track down a potential memory corruption bug. Some of these worked – but it was INCONSISTENT as to how many of these it would reach before crashing!
So I finally bit the bullet and downloaded the source and added SDL_ttf.c to my project. I didn’t build the library from sources, but rather I decided to go the most direct route and just compile that source directly in with my other sources, so as to get at it with a debugger.
AND THE CRASH IS GONE!
But I’m left with a dirty, hacked build that I would rather not carry into the future. (And it somehow broke SDL_gfx, which now doesn’t draw anything.) I am mystified. Any thoughts, any insights, that might help me clean this up?