我对 SDL2 比较陌生,但我为某些东西编写了一个快速而肮脏的程序。它在我的笔记本电脑上运行良好,但是当我连接到我的服务器并尝试使用 SSH 上的 X 隧道对其进行测试时,我瞬间看到了一个窗口的轮廓,然后出现以下错误:
X Error of failed request: BadRequest (invalid request code or no such operation)
Major opcode of failed request: 130 (MIT-SHM)
Minor opcode of failed request: 1 (X_ShmAttach)
Serial number of failed request: 202
Current serial number in output stream: 203
其他 X 程序工作正常吗?甚至其他 SDL2 程序也是如此。
在网上查看,我得到的结果是OpenGL问题,但我的程序根本不使用OpenGL。或者,至少,它不应该,因为我的其他SDL2 程序运行良好,并且实际上并没有使用任何太复杂的东西,只是表面和位平面。无论如何,我尝试了这些解决方案,可惜没有任何效果......
有趣的是,当我通过 valgrind 运行它时,我得到了这个,并且不是上面的错误:
==29836== Warning: invalid file descriptor 1024 in syscall close()
==29836== Warning: invalid file descriptor 1025 in syscall close()
==29836== Warning: invalid file descriptor 1026 in syscall close()
==29836== Warning: invalid file descriptor 1027 in syscall close()
==29836== Use --log-fd=<number> to select an alternative log fd.
==29836== Warning: invalid file descriptor 1028 in syscall close()
==29836== Warning: invalid file descriptor 1029 in syscall close()
接下来是堆摘要,好像程序停止了,但它继续运行......然后过了一会儿,程序开始运行?当我关闭它时,它显示其他堆总结...
这是完整的日志,以防有帮助。
kit@KitServ:~/git/video-compress$ ./a.out a.vid
X Error of failed request: BadRequest (invalid request code or no such operation)
Major opcode of failed request: 130 (MIT-SHM)
Minor opcode of failed request: 1 (X_ShmAttach)
Serial number of failed request: 202
Current serial number in output stream: 203
kit@KitServ:~/git/video-compress$ valgrind ./a.out a.vid
==29814== Memcheck, a memory error detector
==29814== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==29814== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==29814== Command: ./a.out a.vid
==29814==
==29836== Warning: invalid file descriptor 1024 in syscall close()
==29836== Warning: invalid file descriptor 1025 in syscall close()
==29836== Warning: invalid file descriptor 1026 in syscall close()
==29836== Warning: invalid file descriptor 1027 in syscall close()
==29836== Use --log-fd=<number> to select an alternative log fd.
==29836== Warning: invalid file descriptor 1028 in syscall close()
==29836== Warning: invalid file descriptor 1029 in syscall close()
==29836==
==29836== HEAP SUMMARY:
==29836== in use at exit: 12,828,426 bytes in 56,137 blocks
==29836== total heap usage: 119,755 allocs, 63,618 frees, 53,804,810 bytes allocated
==29836==
==29836== LEAK SUMMARY:
==29836== definitely lost: 0 bytes in 0 blocks
==29836== indirectly lost: 0 bytes in 0 blocks
==29836== possibly lost: 728 bytes in 18 blocks
==29836== still reachable: 12,827,698 bytes in 56,119 blocks
==29836== of which reachable via heuristic:
==29836== newarray : 832 bytes in 16 blocks
==29836== suppressed: 0 bytes in 0 blocks
==29836== Rerun with --leak-check=full to see details of leaked memory
==29836==
==29836== For lists of detected and suppressed errors, rerun with: -s
==29836== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
^C==29814==
==29814== HEAP SUMMARY:
==29814== in use at exit: 10,225,041 bytes in 7,548 blocks
==29814== total heap usage: 156,304 allocs, 148,756 frees, 124,528,896 bytes allocated
==29814==
==29814== LEAK SUMMARY:
==29814== definitely lost: 1,168 bytes in 15 blocks
==29814== indirectly lost: 171,414 bytes in 776 blocks
==29814== possibly lost: 218,440 bytes in 503 blocks
==29814== still reachable: 9,834,019 bytes in 6,254 blocks
==29814== of which reachable via heuristic:
==29814== newarray : 832 bytes in 16 blocks
==29814== suppressed: 0 bytes in 0 blocks
==29814== Rerun with --leak-check=full to see details of leaked memory
==29814==
==29814== For lists of detected and suppressed errors, rerun with: -s
==29814== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
kit@KitServ:~/git/video-compress$
如果它有帮助的话,这是有问题的程序。