Akio's Log

ソフトウェア開発、プロジェクトマネジメント、プログラミング、ランニングなどなど

Linux/gccプログラミングでのはまり事

はまってしまって解決策が見当たらない。

  • C++で作成したソースをCで呼び出す
  • C++側の処理で、mallocvectorのresizeなど、メモリ領域をどうにかしようとすると、Segmentation Faultが発生する。以下のメッセージはcoreファイルより。
  • 以前、別PJで使用したロジック(C++のソースやC言語のラッパー関数など)の使いまわしなのだが、以前のPJでは動いていた。(ちゃんとmallocやresizeが出来ていた)
  • malloc_consolidate()で検索してみると、既に解放されているアドレスに対して、再度freeをしようとすると発生してしまう、との情報があったが、それには該当しない。
  • なぜなぜ?とりあえず動的にメモリを確保せずに、固定値で逃げてみる。

#0 0x00cc4d1f in malloc_consolidate () from /lib/libc.so.6
#1 0x00cc6f03 in _int_malloc () from /lib/libc.so.6
#2 0x00cc812e in malloc () from /lib/libc.so.6
#3 0x03332b27 in operator new () from /usr/lib/libstdc++.so.6
#4 0x080571d3 in std::vector >, std::allocator > > >::_M_fill_insert (this=0xbfef4980, __position=
{_M_current = 0x0}, __n=50, __x=@0xbfec148c) at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:88
#5 0x080567c1 in CXXXXXXXXer (this=0xbfef4978, yyyy=0x805fab0, zzzz=@0xbfec14f0, max_iter_num=100) at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_vector.h:658
#6 0x08058b8c in decodeAAAAA (dddd_filename=0xbfef4a5c "./data/fffffffff", spxxxxx=0x805fab0, receive_data=0x805fa68 "??\210????Zi\226??G\235\t`", result_data=0x805fa80 "", code_length=100,
parity_length=50, max_itr_num=100, error_rate=0.050000000000000003) at .CCCCC/system.h:22
#7 0x0804ae59 in normalLdpc (option=0x805e300) at normal_ldpc.c:255
#8 0x0804a38e in main (argc=13, argv=0xbfef4d84) at main.c:338