gdb한 결과입니다. 원인이 뭘까요?
:roll: 안녕하세요. 제가 짠 소켓통신 하는 프로그램이 Segmentation fault를 내고 죽어서 아래와 같이 해봤습니다. Segmentation fault 의 원인이 오라클과 관련된 건가요? 답변 부탁드립니다. :D
[sorrel]$ gdb mp_server core
GNU gdb 19991004
Copyright 1998 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"...
Core was generated by `./mp_server 9900'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /home/oracle/OraHome1/lib/libclntsh.so.8.0...done.
Reading symbols from /lib/libdl.so.2...done.
Reading symbols from /lib/libm.so.6...done.
Reading symbols from /lib/libpthread.so.0...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /home/oracle/OraHome1/lib/libwtc8.so...done.
Reading symbols from /lib/ld-linux.so.2...done.
Reading symbols from /lib/libnss_files.so.2...done.
#0 0x40664a34 in __libc_read () from /lib/libc.so.6
(gdb)
원인은 모르죠.
그 정보만 가지고는 알 수 없습니다. ?
단순히 SIGSEGV가 발생했다는 거 말고는 알 수 있는 부분이 없네요.
차라리 gdb에서 bt(backtrace) 명령으로 SIGSEGV가 발생한 부분의 코드를
올려주시는게 훨씬 더 효과가 있을 것 같습니다.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Korean Ver: http://cinsk.github.io/cfaqs/
bt 한 내용입니다.
:D 안녕하세요. 답변감사합니다.
그런데.. 제가 gdb을 잘 몰라서요.. :oops:
그냥 아래와 같이 해봤거든요.. 맞는지 모르겠네요.
수고스러우시겠지만.. 한번 더 봐주세요~
(gdb) bt
#0 0x40664a34 in __libc_read () from /lib/libc.so.6
#1 0x405bbd1c in ?? () from /lib/libpthread.so.0
#2 0x40328f15 in nttrd () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#3 0x4021a8ee in nsprecv () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#4 0x4021e0ce in nsrdr () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#5 0x4020af7e in nsdo () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#6 0x4027a49a in nioqrc () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#7 0x4034ff9c in ttcdrv () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#8 0x4027ff85 in nioqwa () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#9 0x401abfda in upirtrc () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#10 0x4018b6a1 in kpurcsc () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#11 0x401e0365 in kpuexecv8 () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#12 0x401e1abc in kpuexec () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#13 0x401985d4 in OCIStmtExecute () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#14 0x4014c975 in sqlcucExecute () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#15 0x40144121 in sqlall () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#16 0x401487a5 in sqlatm () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#17 0x4013c1f4 in sqlnst () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#18 0x401328fd in sqlcmex () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#19 0x40132bec in sqlcxt () from /home/oracle/OraHome1/lib/libclntsh.so.8.0
#20 0x804ad00 in pt_get_menu (args=0x80a05d0) at server_test.c:1611
#21 0x80503ee in ParseProtocol (args=0x80a05d0, DataMsg=0x80a0628 "\001", pt_count=1) at server_test.c:665
#22 0x8048edb in HandleTCPClient (args=0x80a05d0) at server_test.c:554
#23 0x8050369 in ThreadMain (args=0x80a05d0) at server_test.c:451
#24 0x405afb85 in pthread_start_thread (arg=0xbedffe40) at manager.c:241
가령.. #20에서.. 1611 라인에서.. 오류가 있어서.. segmentation fault가 났다는 건가요?
참고로..
#20 1611 line----------------------------------------------------
EXEC SQL SELECT count(*) into :listCount FROM mng_tbl WHERE category = 4 AND idx <> 27 AND (confirm_016 = 1 OR idx = 10);
위는 제가 pro*C를 사용해서.. .pc의 코드를 적어봅니다.
실제 .c의 코드는 이겁니다.
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
#21 665 line----------------------------------------------------
pt_get_menu(args);
#22 554 line----------------------------------------------------
if (ParseProtocol(threadArgs, threadArgs->buffer+HEADER_LEN+i, packetLen) == RV_NONE)
#23 451 line----------------------------------------------------
result = HandleTCPClient(args);
#24는 제가 pthread를 사용했는데.. 거기에서 불려진 함수인거 같습니다.
제가 짠 코드는 아닙니다.
pro*c 에서 thread-safe
아래의 문서에서 thread-safe에 관련된 내용을 참조하세요.
http://info-it.umsystem.edu/oradocs/doc/api/doc/PC_22/apa.htm
ctx를 쓰레드 별로 각각 생성해줘야 하는 걸로 알고 있습니다.
Examples The following code fragments show how to use embedded SQL statements and precompiler directives for two typical programming models; they use thread_create() to create threads.
The first example showing multiple threads using multiple runtime contexts:
main()
{ sql_context ctx1,ctx2; /* declare runtime contexts */
EXEC SQL ENABLE THREADS;
EXEC SQL ALLOCATE :ctx1;
EXEC SQL ALLOCATE :ctx2;
...
/* spawn thread, execute function1 (in the thread) passing ctx1 */
thread_create(..., function1, ctx1);
/* spawn thread, execute function2 (in the thread) passing ctx2 */
thread_create(..., function2, ctx2);
...
EXEC SQL CONTEXT FREE :ctx1;
EXEC SQL CONTEXT FREE :ctx2;
...
}
void function1(sql_context ctx)
{ EXEC SQL CONTEXT USE :ctx;
/* execute executable SQL statements on runtime context ctx1!!! */
...
}
void function2(sql_context ctx)
{ EXEC SQL CONTEXT USE :ctx;
/* execute executable SQL statements on runtime context ctx2!!! */
...
}
The next example shows how to use multiple threads that share a common runtime context. Because the SQL statements executed in function1() and function2() potentially execute at the same time, you must place mutexes around every executable EXEC SQL statement to ensure serial, therefore safe, manipulation of the data.
main()
{ sql_context ctx; /* declare runtime context */
EXEC SQL ALLOCATE :ctx;
...
/* spawn thread, execute function1 (in the thread) passing ctx */
thread_create(..., function1, ctx);
/* spawn thread, execute function2 (in the thread) passing ctx */
thread_create(..., function2, ctx);
...
}
void function1(sql_context ctx)
{ EXEC SQL CONTEXT USE :ctx;
/* Execute SQL statements on runtime context ctx. */
...
}
void function2(sql_context ctx)
{ EXEC SQL CONTEXT USE :ctx;
/* Execute SQL statements on runtime context ctx. */
...
}
울랄라~ 호기심 천국~!!
http://www.ezdoum.com
댓글 달기