(这是在ffmpeg-devel列表上被问到的,但算在了离题的地方,所以把它贴在这里)。
ffmpeg.c加载多个.c,这些.c使用log.c的av_log -> av_log_default_callback函数,该函数使用fput;
void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
{
...
snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent);
... call to colored_fputs屏幕输出:
static void colored_fputs(int level, const char *str){
...
fputs(str, stderr);
// this causes sigsegv just by fopen()
FILE * xFile;
xFile = fopen('yarr', 'w');
//fputs(str, xFile);fclose(xFile); // compile me. BOOM!
av_free(xFile); // last idea that came, using local free() version to avoid re-creatio每次,当fopen被放入代码中时,它都会给出一个未知原因的分段错误。为什么这样的事情会发生在这里?可能是因为阻塞了主I/O?
在这种情况下,应该调查的一般“拦截器”是什么?Pthread(包含在某个地方的代码中)?
发布于 2010-09-11 09:15:56
fopen接受字符串作为参数,您为它提供了char字面量
xFile = fopen('yarr', 'w');应该是
xFile = fopen("yarr", "w");
if(xFile == NULL) {
perror("fopen failed");
return;
}编译器应该已经对此进行了警告,因此请确保您已经打开了警告标志(请记住阅读并修复它们)
https://stackoverflow.com/questions/3689381
复制相似问题