| Summary: | Segfault on call to TTF_OpenFontIndexRW | ||
|---|---|---|---|
| Product: | SDL_ttf | Reporter: | Dave <davebrda> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | sylvain.becker |
| Version: | 2.0.14 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | zip file with font is in build folder. physfsrwops is included in this tar. to build: cd build; cmake ..; make | ||
no familiar with physfs, but this code runs with latest version of SDL2:
int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();
SDL_RWops* rw = SDL_RWFromFile("menlo.ttf", "r");
if (rw) {
SDL_Log("ok rw");
}
TTF_Font* font = TTF_OpenFontIndexRW(rw, 1, 15, 0);
if (font) {
SDL_Log("ok font");
}
return 0;
}
will print
INFO: ok rw
INFO: ok font
I think the problem is with PHYSFSRWOPS_makeRWops because this works fine:
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <physfs.h>
int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();
PHYSFS_init(argv[0]);
PHYSFS_mount("menlo.zip", nullptr, 0);
PHYSFS_exists("menlo.ttf");
PHYSFS_File* fp = PHYSFS_openRead("menlo.ttf");
// SDL_RWops* rw = PHYSFSRWOPS_makeRWops(fp);
PHYSFS_sint64 file_size = PHYSFS_fileLength(fp);
char *buf = new char[file_size];
PHYSFS_read(fp, buf, 1, file_size);
SDL_RWops* rw = SDL_RWFromMem(buf, file_size);
TTF_Font* font = TTF_OpenFontIndexRW(rw, 1, 15, 0);
return 0;
}
Marked resolved as Invalid! |
Created attachment 2952 [details] zip file with font is in build folder. physfsrwops is included in this tar. to build: cd build; cmake ..; make SDL version is 2.0.5-4 SDL_ttf is 2.0.14-1 and PhysFS/physfsrwops is 2.0.3 (on 64 bit linux with g++) Attached please find short program reproducing the problem and data file. The code runs if I comment out the line TTF_Init();. My debugger says the segfault is happening in TTF_OpenFontIndexRW at line 426 in a call to “main_arena” but I am not finding that function.