성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] 그냥 RSS Reader 기능과 약간의 UI 편의성 때문에 사용...
[이종효] 오래된 소프트웨어는 보안 위협이 되기도 합니다. 혹시 어떤 기능...
[정성태] @Keystroke IEEE의 문서를 소개해 주시다니... +_...
[손민수 (Keystroke)] 괜히 듀얼채널 구성할 때 한번에 같은 제품 사라고 하는 것이 아...
[정성태] 전각(Full-width)/반각(Half-width) 기능을 토...
[정성태] Vector에 대한 내용은 없습니다. Vector가 닷넷 BCL...
[orion] 글 읽고 찾아보니 디자인 타임에는 InitializeCompon...
[orion] 연휴 전에 재현 프로젝트 올리자 생각해 놓고 여의치 않아서 못 ...
[정성태] 아래의 글에 정리했으니 참고하세요. C# - Typed D...
[정성태] 간단한 재현 프로젝트라도 있을까요? 저런 식으로 설명만 해...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>리눅스 환경에서 C/C++ 프로그램이 Segmentation fault 에러가 발생한 경우 (2)</h1> <p> 오랜만에 먼지 낀 라즈베리 파이를 꺼내 지난번에 만들어 둔,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Raspberry Pi Zero(OTG)를 다른 컴퓨터에 연결해 가상 키보드 및 마우스로 쓰는 방법 (절대 좌표, 상대 좌표, 휠) ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/11369'>https://www.sysnet.pe.kr/2/0/11369</a> </pre> <br /> 모듈을 테스트하는데 "shutdown" 명령이 동작하질 않습니다. 때마침 배운 것도 있으니, ^^<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > 리눅스 환경에서 C/C++ 프로그램이 Segmentation fault 에러가 발생한 경우 ; <a target='tab' href='https://www.sysnet.pe.kr/2/0/12208'>https://www.sysnet.pe.kr/2/0/12208</a> </pre> <br /> 실습으로 호출 스택을 떴는데,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > root@raspberrypi:/home/pi# <span style='color: blue; font-weight: bold'>gdb /share/rasp_vusb_server.out</span> GNU gdb (Raspbian 7.12-6) 7.12.0.20161007-git Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "arm-linux-gnueabihf". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /share/rasp_vusb_server.out...done. (gdb) <span style='color: blue; font-weight: bold'>r test</span> Starting program: /share/rasp_vusb_server.out test [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1". init_openssl completed: init_openssl [New Thread 0xb6989450 (LWP 600)] [New Thread 0xb6188450 (LWP 601)] ipResolver prepared keyboard/mouse opened [New Thread 0xb5987450 (LWP 602)] usbServer prepared Press any key to exit... Client connection information: IP: 172.30.1.37, Port: 54863 [New Thread 0xb4fff450 (LWP 603)] Client connection information: IP: 172.30.1.37, Port: 51683 [New Thread 0xb47fe450 (LWP 604)] recvBytes == 1 <span style='color: blue; font-weight: bold'>Thread 2 "rasp_vusb_serve" received signal SIGSEGV, Segmentation fault.</span> [Switching to Thread 0xb6989450 (LWP 600)] std::basic_ios<char, std::char_traits<char> >::widen () at /usr/include/c++/6/bits/basic_ios.h:450 450 { return __check_facet(_M_ctype).widen(__c); } (gdb) <span style='color: blue; font-weight: bold'>bt</span> #0 std::basic_ios<char, std::char_traits<char> >::widen () at /usr/include/c++/6/bits/basic_ios.h:450 #1 std::endl<char, std::char_traits<char> > () at /usr/include/c++/6/ostream:591 #2 std::ostream::operator<< () at /usr/include/c++/6/ostream:113 #3 UsbEmulator::ProcessUsbInput () at /home/pi/projects/rasp_vusb_server/UsbEmulator.cpp:105 #4 operator() () at /home/pi/projects/rasp_vusb_server/UsbEmulator.cpp:72 #5 _M_invoke<> () at /usr/include/c++/6/functional:1391 #6 operator() () at /usr/include/c++/6/functional:1380 #7 _M_run () at /usr/include/c++/6/thread:197 #8 0xb6ca39dc in ?? () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 #9 0xb6b37fc4 in start_thread (arg=0xb6989450) at pthread_create.c:458 #10 0xb6ac4038 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:76 from /lib/arm-linux-gnueabihf/libc.so.6 Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) </pre> <br /> 분명히 "cout" 라인에서 Segmentation fault 오류가 발생합니다. 혹시나 싶어 그 라인을 printf로 바꿨더니,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > printf("shutting down...\n"); // cout << "shutting down..." << endl; </pre> <br /> 오호~~~ 잘 동작합니다. 그런데, 이유를 모르겠군요. 혹시나 소스코드(<a target='tab' href='https://github.com/stjeong/rasp_vusb/blob/master/rasp_vusb_server/UsbEmulator.cpp#L51'>https://github.com/stjeong/rasp_vusb/blob/master/rasp_vusb_server/UsbEmulator.cpp#L51</a>)를 보시고 원인이 짐작되시는 분이 있다면 덧글 부탁드립니다. ^^<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1908
(왼쪽의 숫자를 입력해야 합니다.)