리눅스에서 sqlite의 내부 콜중 SIGSEGV 에러가 납니다.

소타의 이미지

malloc 에서 에러가 납니다.. malloc 호출 위치는 sqlite 라이브러리 내부입니다.
문제가 있는 부분의 소스코드입니다.

sqlites[0].db = sqlite_open( sqlites[0].dbname, 0, &(sqlites[0].errmsg) );

참고로 Darwin(맥OS X) 에서는 아무문제 없이 동작합니다.
그리고 sqlite 의 레퍼런스 문서에 샘플코드(http://www.sqlite.org/quickstart.html 의 아래쪽 소스)는 정상 동작합니다.

strace 결과입니다. 위의 코드가 호출된 이후부터의 시스템콜들 입니다.

[pid  1941] getcwd("/work/root/board", 5000) = 17
[pid  1941] open("/work/root/board/board_1", O_RDWR|O_CREAT|O_LARGEFILE, 0644) = 7
[pid  1941] fstat64(7, {st_mode=S_IFREG|0644, st_size=11628544, ...}) = 0
[pid  1941] --- SIGSEGV (Segmentation fault) ---
[pid  1940] <... poll resumed> [{fd=5, events=POLLIN}], 1, 2000) = -1 EINTR (Interrupted system call)
[pid  1940] --- SIGRT_1 (Real-time signal 1) ---
[pid  1940] sigreturn()                 = ? (mask now ~[TRAP KILL STOP])
[pid  1940] getppid()                   = 1939
[pid  1940] wait4(-1, [WIFSIGNALED(s) && WTERMSIG(s) == SIGSEGV], WNOHANG|__WCLONE, NULL) = 1941
[pid  1940] munmap(0xbf600000, 2097152) = 0
[pid  1940] kill(1939, SIGSEGV)         = 0
[pid  1940] _exit(0)                    = ?
<... poll resumed> [{fd=3, events=POLLIN}], 1, 1000) = -1 EINTR (Interrupted system call)
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++

GDB 결과입니다.

[root@linux board]# gdb ./board
GNU gdb Red Hat Linux (5.2-2)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) run
Starting program: /work/root/board/board
[New Thread 1024 (LWP 1914)]
[New Thread 2049 (LWP 1921)]
[New Thread 1026 (LWP 1922)]
THREAD START

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1026 (LWP 1922)]
0x4012802f in chunk_alloc () from /lib/libc.so.6
(gdb) bt
#0  0x4012802f in chunk_alloc () from /lib/libc.so.6
#1  0x401279d0 in malloc () from /lib/libc.so.6
#2  0x40092461 in sqliteMalloc (n=8462) at ./src/util.c:254
#3  0x4008540d in sqlitepager_open (ppPager=0x8a7833c, zFilename=0x804cfe8 "board_1", mxPage=2000, nExtra=280, useJournal=1) at ./src/pager.c:857
#4  0x4007001e in sqliteBtreeOpen (zFilename=0x804cfe8 "board_1", omitJournal=0, nCache=2000, ppBtree=0x8a7820c) at ./src/btree.c:711
#5  0x40083a61 in sqliteBtreeFactory (db=0x8a78200, zFilename=0x804cfe8 "board_1", omitJournal=0, nCache=2000, ppBtree=0x8a7820c) at ./src/main.c:1036
#6  0x40082d95 in sqlite_open (zFilename=0x804cfe8 "board_1", mode=0, pzErrMsg=0x804cc74) at ./src/main.c:447
#7  0x08049f79 in find_sqlite_pool ()
#8  0x080495b6 in query_cache_check ()
#9  0x08049528 in request_parse ()
#10 0x0804929f in proc ()
#11 0x40035f77 in pthread_start_thread () from /lib/libpthread.so.0
(gdb)

[root@linux board]# rpm -qa | grep glibc
glibc-utils-2.2.5-44
glibc-2.2.5-44
glibc-common-2.2.5-44
glibc-debug-static-2.2.5-44
glibc-debug-2.2.5-44
glibc-kernheaders-2.4-7.16
glibc-devel-2.2.5-44
compat-glibc-6.2-2.1.3.2
glibc-profile-2.2.5-44
[root@linux board]# rpm -qa | grep gcc
gcc-chill-2.96-113
gcc-2.96-113
gcc-objc-2.96-113
gcc-java-2.96-113
gcc-c++-2.96-113
gcc-g77-2.96-113
[root@linux board]# cat /etc/redhat-release
Red Hat Linux release 7.3 (Valhalla)

어떤 문제일까요.. 답변 부탁드립니다~

소타의 이미지

sqlite 는 THREADSAFE=1 로 컴파일 되었습니다..
움.. 원인이 thread 때문이 아닐지 싶은데..
도무지 이유를 모르겠네요..
레뎃 7.3이 깔린 다른 머신에서 해봐도 똑같은 에러가 나옵니다..
문제가 있는 소스라면 왜 다윈에서는 너무 잘 동작하는지 -_-;;

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.