세그멘테이션오류를 효울적으로 잡으려면

down7town의 이미지

어떻게 하는게 좋을까요...

처음에 포인터가 에매할때는 GDB도 써보고 했었는데, 점점 printf로 찍어보는게 젤 좋더군요..

그러다가 이젠 프로그램이 제법 커져서 모듈이 총 8개 정도되는데,

make로 관리하고 있죠..

모듈 여려개를 수정할 일이 있어서 일단은 코딩부터 해놓고, 하나씩 에러를 잡아가는데, 파싱에러 완료하고,, 세그멘테이션 오류가 발생하는데, 이번건 아예 메인에서 첫라인에 printf를 넣어도 안나오는군요..

malloc를 추가하진 않았으니 힙쪽에서 발생한건 아니고요.. 참조를 잘못하고 있는듯한데, 이런경우 어떻게 찾는게 좋죠!! GDB를 쓸려니 엄두가 안나고,, 잠시 생각하다가, 그냥 한번 올려봅니다.

crimsoncream의 이미지

electricfence를 써보시는 건 어떨까요?
다음은 man page에 나와있는 instruction 입니다.

$> man efence
           .
           .
           .
                 1.     Link with libefence.a as explained above.

                 2.     Run your program in a debugger and fix any overruns
                        or accesses to free memory.

                 3.     Quit the debugger.

                 4.     Set EF_PROTECT_BELOW = 1 in the shell  environment.

                 5.     Repeat  step  2,  this  time repairing underruns if
                        they occur.

                 6.     Quit the debugger.

                 7.     Read the restrictions in the section on WORD-ALIGN-
                        MENT  AND  OVERRUN  DETECTION.   See if you can set
                        EF_ALIGNMENT to 0 and repeat step 2. Sometimes this
                        will  be  too  much work, or there will be problems
                        with library routines for which you don't have  the
                        source, that will prevent you from doing this.

Purify가 더 좋다는데 손에 익은게 이거라 :)

오늘 우리는 동지를 땅에 묻었습니다. 그러나 땅은 이제 우리들의 것입니다.
아직도 우리의 적은 강합니다. 그러나 우리는 그들보다 많습니다.
항상 많을 것입니다.

김성진의 이미지

허허허..

purify하고 efence를 비교하시는건....

질문자께서 정말로 문제를 제대로 잡고 싶으시다면,

purify를 권해드립니다.

evaluation 버젼을 받으셔서 한번 써 보시면,

인간이 얼마나 실수를 많이 하는지...

느끼실 수 있습니다. ^^

저도 이 툴을 쓰면서 인간 이성의 한계를 절감하곤 합니다.

김성진 드림..

고도의 추상화, 극도의 구체화, 에디슨을 그리워하다.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.