리눅스에서 sqlite의 내부 콜중 SIGSEGV 에러가 납니다.
글쓴이: 소타 / 작성시간: 금, 2004/01/02 - 6:45오전
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)
어떤 문제일까요.. 답변 부탁드립니다~
Forums:
sqlite 는 THREADSAFE=1 로 컴파일 되었습니다..움..
sqlite 는 THREADSAFE=1 로 컴파일 되었습니다..
움.. 원인이 thread 때문이 아닐지 싶은데..
도무지 이유를 모르겠네요..
레뎃 7.3이 깔린 다른 머신에서 해봐도 똑같은 에러가 나옵니다..
문제가 있는 소스라면 왜 다윈에서는 너무 잘 동작하는지 -_-;;
댓글 달기