提升血清代码崩溃

时间:2016-05-06 13:31:49

标签: c++ serialization boost

我的程序崩溃在boost::archive::text_oarchive ar(ofs)函数上。我的升级版本是1.58,操作系统是Ubuntu 16.04

void saveToFile()
{
    string fileName ("/tmp/test.txt") ;

    ofstream ofs(fileName.c_str());
    if (ofs.good())
    {
            boost::archive::text_oarchive ar(ofs);
            ar & fileName;
            return;
    }
 }

 int main(int argc, char *argv[])
 {
      saveToFile();
      return 0;
 }

这是堆栈跟踪。

    #0  0x00007f85e9252418 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
    #1  0x00007f85e925401a in __GI_abort () at abort.c:89
    #2  0x00007f85e929472a in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7f85e93ad6b0 "*** Error in `%s': %s: 0x%s ***\n")
        at ../sysdeps/posix/libc_fatal.c:175
    #3  0x00007f85e929cf4a in malloc_printerr (ar_ptr=<optimized out>, ptr=<optimized out>, str=0x7f85e93aa48f "free(): invalid pointer", action=3)
        at malloc.c:5007
    #4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3868
    #5  0x00007f85e92a0abc in __GI___libc_free (mem=<optimized out>) at malloc.c:2969
    #6  0x00000000004082fe in saveToFile () at main.cpp:56
    #7  0x00000000004083b0 in main (argc=4, argv=0x7ffc120a4fa8) at main.cpp:68

0 个答案:

没有答案