Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 尽管文件指针正确,但在fclose()过程中出现SEGFULT 在物体破坏过程中持续发生; fopen之后和fclose之前的文件指针值相同; 在对象析构函数中只调用一次fclose; 对象是静态创建的,并在作用域结束时销毁 该文件仅在一个线程中处理_C++_Linux_Gcc_Memory_Segmentation Fault - Fatal编程技术网

C++ 尽管文件指针正确,但在fclose()过程中出现SEGFULT 在物体破坏过程中持续发生; fopen之后和fclose之前的文件指针值相同; 在对象析构函数中只调用一次fclose; 对象是静态创建的,并在作用域结束时销毁 该文件仅在一个线程中处理

C++ 尽管文件指针正确,但在fclose()过程中出现SEGFULT 在物体破坏过程中持续发生; fopen之后和fclose之前的文件指针值相同; 在对象析构函数中只调用一次fclose; 对象是静态创建的,并在作用域结束时销毁 该文件仅在一个线程中处理,c++,linux,gcc,memory,segmentation-fault,C++,Linux,Gcc,Memory,Segmentation Fault,文件打开: logOutFile_fd = fopen(logOutFile,"w"); if (logOutFile_fd==NULL) { /* omitted */ } 文件关闭: if (logOutFile_fd!=NULL) { fflush(logOutFile_fd); fclose(logOutFile_fd); } 我使用-g3编译并通过gdb运行,下面是完整的回溯: #0 0x00007ffff6f8d3f8 in raise () from /lib64

文件打开:

logOutFile_fd = fopen(logOutFile,"w");
if (logOutFile_fd==NULL) {
  /* omitted */
}
文件关闭:

if (logOutFile_fd!=NULL) {
  fflush(logOutFile_fd);
  fclose(logOutFile_fd);
}
我使用-g3编译并通过gdb运行,下面是完整的回溯:

#0  0x00007ffff6f8d3f8 in raise () from /lib64/libc.so.6
No symbol table info available.
#1  0x00007ffff6f8effa in abort () from /lib64/libc.so.6
No symbol table info available.
#2  0x00007ffff6fcf6f9 in __libc_message () from /lib64/libc.so.6
No symbol table info available.
#3  0x00007ffff6fd7f4a in _int_free () from /lib64/libc.so.6
No symbol table info available.
#4  0x00007ffff6fdbc1c in free () from /lib64/libc.so.6
No symbol table info available.
#5  0x00007ffff6fc52c3 in fclose@@GLIBC_2.2.5 () from /lib64/libc.so.6
No symbol table info available.
#6  0x0000000000402733 in t_netInterface::~t_netInterface (this=0x7ffff5f50cf0, __in_chrg=<optimized out>) at connect.cpp:59
No locals.
#7  0x00000000004022fc in pthreadTask (pthData=0x7fffffffe070) at client.cpp:131
        netInterface = {id = 162, currTime = {tv_sec = 0, tv_usec = 0}, dbg_time_sync = {tv_sec = 0, tv_usec = 0}, dbg_time_prev = 0, dbg_time_now = 0, 
          dbg_time_dprev = 0, dbg_time_dnow = 0, dbg_ch0_len = 0, datems = 0, timeMarkSet = {0 <repeats 12 times>}, chunk = 0, chunk_ch = 0 '\000', 
          chunk_dt = 0, chunk_H = 0 '\000', chunk_L = 0 '\000', fpd = 0x0, logOutFile = 0x0, logOutFile_fd = 0x7fffec038f30, 
          dataOutFile = 0x7fffec001c10 "(\b", dataOutFile_fd = 0x7fffec03a580, globalLogFile_fd = 0x7fffec0009d0, dir0 = 0x7fffec001d20 "(\b", sockfd = 11, 
          portno = 34000, serv_addr = {sin_family = 2, sin_port = 53380, sin_addr = {s_addr = 2717952192}, sin_zero = "\000\000\000\000\000\000\000"}, 
          poll_d = {{fd = 11, events = 1, revents = 0}}, f_ret = 0, channelBuffers = 0x7fffec000920, channelBuffIter = 0x7fffec0008e0, 
          channelDataTypeH = 1284, valSigned = 0, dbgFlag = 0, dataPath = 0x7fffec006d50 "(\b", addr_str = 0x7fffec002530 "192.168.0.162", 
          buffChar = 0x7fffec002d40 "(\b", wasConnected = 0}
        data = 0x7fffffffe070
        out_buffer = 64
        in_buffer = {0 <repeats 8192 times>}
        pid = 162
        tid = 162
        logOutFile_fd = 0x7fffec038f30
        res = 1
        rcvDataSizeBytes = 0
        retv = 0
        cc = 2003
        active = 0
        uptimeSec = 27134
        globalLogName = 0x7fffec0008c0 "x"
        globalLogFile_fd = 0x7fffec0009d0
#8  0x00007ffff7328684 in start_thread () from /lib64/libpthread.so.0
No symbol table info available.
#9  0x00007ffff705eefd in clone () from /lib64/libc.so.6
No symbol table info available.
我做错了什么?提前谢谢


编辑:我曾经尝试过将dealLocator洗牌,现在它看起来确实像是在类构造函数和析构函数之间的某个地方进行内存破坏。我将重新实现一些东西,这样问题就可以被认为是完结了。无论如何,感谢您抽出时间。

类似的fclose崩溃表明所涉及的文件数据结构已损坏,可能是由于程序中其他地方使用了无效的指针


您最好的选择可能是像

这样的内存检查工具一般来说,SEGFULT发生后会在行上报告SEGFULT,因为指令指针rip已经增加。如果没有你调用的函数的来源,我们不知道是什么导致了它。请发布您的代码。请将您的程序缩减为演示问题的最短完整程序。请把整个简短的程序复制粘贴到你的问题中。有关更多信息,请参阅。在对象销毁过程中始终发生什么对象?请发布一个。这是一个多线程应用程序吗?网络接口是如何构建和破坏的?