问题描述
因此,我遵循https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html中的ncurses指南 当我尝试运行已编译的代码时,它会中止陷阱退出:6 我写的代码
#include <ncurses.h> //Including the NCurses library
int main(){
initscr(); // Initializing the NCurses
printw("Hello world"); // Printing Hello world
refresh(); // displaying the Window's content on terminal
getch(); // Pausing the program until a key is pressed
endwin(); // Freeing the Terminal from NCurses
return 0;
}
程序错误
SomeTry(17615,0x118bf35c0) malloc: *** error for object 0xf000000000000000: pointer being freed was not allocated
SomeTry(17615,0x118bf35c0) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6
lldb的输出:
SomeTry(17433,0x10010b5c0) malloc: *** error for object 0x14: pointer being freed was not allocated
SomeTry(17433,0x10010b5c0) malloc: *** set a breakpoint in malloc_error_break to debug
Process 17433 stopped
* thread #1,queue = 'com.apple.main-thread',stop reason = signal SIGABRT
frame #0: 0x00007fff579c82c6 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
-> 0x7fff579c82c6 <+10>: jae 0x7fff579c82d0 ; <+20>
0x7fff579c82c8 <+12>: movq %rax,%rdi
0x7fff579c82cb <+15>: jmp 0x7fff579c2457 ; cerror_nocancel
0x7fff579c82d0 <+20>: retq
Target 0: (SomeTry) stopped.
感谢您提供有关此错误的帮助
我尝试过的东西:
removing printw and refresh and getch from the code and compiling and
running it still no luck and also only kept initscr in the main function
and I think it's because of initscr not being able to allocate the memory
but why and how I can resolve them is the question.
我使用的软件:
cmake 3.18.2
llvm Apple LLVM version 10.0.1 (clang-1001.0.46.4)
macOS 10.14.5
ncurses 6.1 from conan-center
conan package manager 1.28.1
解决方法
如果任何人都有相同的问题,请检查您要从柯南安装的版本。 ncurses 6.1出现了此问题,并将其升级到ncurses 6.2已解决