[pgsql-jp: 37950] Re: libpqがスレッドセーフかを調べる

河本陽一 komoto.yoichi @ kcc.co.jp
2007年 1月 16日 (火) 16:54:09 JST


こうもとです。

TANIDA Yutaka さんの書いたこと:
> libpqのスレッドセーフ機能は7.4で追加なので、7.3のlibpqは常にスレッドセー
> フではない、が正解です。

 7.4の変更点の以下の行はそういうことだったのですね。

> libpqとecpgがスレッドセーフになるconfigureのオプション、--enable-thread-safetyが追加になりました。


 7.4の入った別の環境で動作させて見ましたが、そこでもメモリチェック
で異常となりました。
 [pgsql-jp: 37948]と同じ方法で実行していますが、エラーの内容も少し
変わりました。
 スレッドセーフになっていないということでしょうか・・・。

#諸事情でソースからPostgreSQLをインストールできません。
#fork()するの大変だなぁ。

新環境
OS     : RHES4
Kernel : 2.6.9-42.ELsmp on an x86_64
DB     : PostgreSQL 7.4.13
rpm    : postgresql-7.4.13-2.RHEL4.1

実行結果
----------------------------------------------------------------
$ valgrind --leak-check=full ./a.out
==26472== Memcheck, a memory error detector.
==26472== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==26472== Using LibVEX rev 1658, a library for dynamic binary translation.
==26472== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==26472== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
==26472== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==26472== For more details, rerun with: -v
==26472==
==26472== Thread 2:
==26472== Invalid read of size 8
==26472==    at 0x3BA023463E: (within /usr/lib64/libkrb5.so.3.2)
==26472==    by 0x3BA0235A34: (within /usr/lib64/libkrb5.so.3.2)
==26472==    by 0x3B9D60863A: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D608E9A: fe_getauthname (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60AE13: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60AEF7: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60BC8A: PQconnectStart (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60BCD5: PQconnectdb (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x40070D: fDb (in /opt/MMGT_TOOL/src/a.out)
==26472==    by 0x3B9D806109: start_thread (in /lib64/tls/libpthread-2.3.4.so)
==26472==    by 0x3B9CDC68C2: clone (in /lib64/tls/libc-2.3.4.so)
==26472==  Address 0x28 is not stack'd, malloc'd or (recently) free'd
==26472==
==26472== Process terminating with default action of signal 11 (SIGSEGV)
==26472==  Access not within mapped region at address 0x28
==26472==    at 0x3BA023463E: (within /usr/lib64/libkrb5.so.3.2)
==26472==    by 0x3BA0235A34: (within /usr/lib64/libkrb5.so.3.2)
==26472==    by 0x3B9D60863A: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D608E9A: fe_getauthname (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60AE13: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60AEF7: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60BC8A: PQconnectStart (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60BCD5: PQconnectdb (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x40070D: fDb (in /opt/MMGT_TOOL/src/a.out)
==26472==    by 0x3B9D806109: start_thread (in /lib64/tls/libpthread-2.3.4.so)
==26472==    by 0x3B9CDC68C2: clone (in /lib64/tls/libc-2.3.4.so)
==26472==
==26472== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 1)
==26472== malloc/free: in use at exit: 193,266 bytes in 328 blocks.
==26472== malloc/free: 350 allocs, 22 frees, 201,737 bytes allocated.
==26472== For counts of detected errors, rerun with: -v
==26472== searching for pointers to 328 not-freed blocks.
==26472== checked 105,376,848 bytes.
==26472==
==26472== Thread 1:
==26472==
==26472== 5 bytes in 1 blocks are definitely lost in loss record 3 of 34
==26472==    at 0x4904B7E: malloc (vg_replace_malloc.c:149)
==26472==    by 0x3BA0233341: krb5_cc_resolve (in /usr/lib64/libkrb5.so.3.2)
==26472==    by 0x3BA0233676: krb5_cc_default (in /usr/lib64/libkrb5.so.3.2)
==26472==    by 0x3B9D608618: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D608E9A: fe_getauthname (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60AE13: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60AEF7: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60BC8A: PQconnectStart (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60BCD5: PQconnectdb (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x40070D: fDb (in /opt/MMGT_TOOL/src/a.out)
==26472==    by 0x3B9D806109: start_thread (in /lib64/tls/libpthread-2.3.4.so)
==26472==    by 0x3B9CDC68C2: clone (in /lib64/tls/libc-2.3.4.so)
==26472==
==26472==
==26472== 2,720 bytes in 10 blocks are possibly lost in loss record 22 of 34
==26472==    at 0x49060FD: calloc (vg_replace_malloc.c:279)
==26472==    by 0x3B9C90D262: _dl_allocate_tls (in /lib64/ld-2.3.4.so)
==26472==    by 0x3B9D806706: pthread_create@@GLIBC_2.2.5 (in /lib64/tls/libpthread-2.3.4.so)
==26472==    by 0x400756: main (in /opt/MMGT_TOOL/src/a.out)
==26472==
==26472==
==26472== 4,821 (184 direct, 4,637 indirect) bytes in 1 blocks are definitely lost in loss record 25 of 34
==26472==    at 0x4904B7E: malloc (vg_replace_malloc.c:149)
==26472==    by 0x3BA0243CEA: (within /usr/lib64/libkrb5.so.3.2)
==26472==    by 0x3B9D6085FD: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D608E9A: fe_getauthname (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60AE13: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60AEF7: (within /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60BC8A: PQconnectStart (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x3B9D60BCD5: PQconnectdb (in /usr/lib64/libpq.so.3.1)
==26472==    by 0x40070D: fDb (in /opt/MMGT_TOOL/src/a.out)
==26472==    by 0x3B9D806109: start_thread (in /lib64/tls/libpthread-2.3.4.so)
==26472==    by 0x3B9CDC68C2: clone (in /lib64/tls/libc-2.3.4.so)
==26472==
==26472== LEAK SUMMARY:
==26472==    definitely lost: 189 bytes in 2 blocks.
==26472==    indirectly lost: 4,637 bytes in 146 blocks.
==26472==      possibly lost: 2,720 bytes in 10 blocks.
==26472==    still reachable: 185,720 bytes in 170 blocks.
==26472==         suppressed: 0 bytes in 0 blocks.
==26472== Reachable blocks (those to which a pointer was found) are not shown.
==26472== To see them, rerun with: --show-reachable=yes
強制終了
----------------------------------------------------------------

======================================================================
河本陽一(こうもとよういち)
mailto:komoto.yoichi @ kcc.co.jp




pgsql-jp メーリングリストの案内