성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
[정성태] 저렇게 조각 코드 말고, 실제로 재현이 되는 예제 프로젝트를 압...
[정성태] Modules 창(Ctrl+Shift+U)을 띄워서, 해당 Op...
글쓰기
제목
이름
암호
전자우편
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>
첨부파일
스팸 방지용 인증 번호
1607
(왼쪽의 숫자를 입력해야 합니다.)