Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7923833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:26:42+00:00 2026-06-03T17:26:42+00:00

I use a library (libnids) in my program. I call the function nids_run from

  • 0

I use a library (libnids) in my program. I call the function nids_run from the library which continues running until I explicitly call nids_exit.

My program handles SIGINT and calls nids_exit. The interrupt handler returns normally, but sometimes before the library returns the control to my program, I receive a segfault. This is the backtrace GDB gives me:

#0  0x00007ffff6498b2a in ?? () from /usr/lib/libpcap.so.1
#1  0x00007ffff649bee1 in pcap_loop () from /usr/lib/libpcap.so.1
#2  0x00007ffff77bae66 in nids_run () from /usr/lib/libnids.so.1.24
#3  0x0000000000401e92 in main (argc=3, argv=0x7fffffffebf8) at eve.c:139

What is the best strategy to find the problem? Should I somehow debug libpcap?

UPDATE:
As suggetsed by ArjunShankar, I ran my program under Valgrind. This is part of the output:

==7504== Invalid read of size 4
==7504==    at 0x654EDC1: ??? (in /usr/lib/libpcap.so.1.2.1)
==7504==    by 0x6551EE0: pcap_loop (in /usr/lib/libpcap.so.1.2.1)
==7504==    by 0x5250E65: nids_run (in /usr/lib/libnids.so.1.24)
==7504==    by 0x401E91: main (eve.c:139)
==7504==  Address 0x70eece8 is 40 bytes inside a block of size 768 free'd
==7504==    at 0x4C29A9E: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7504==    by 0x5250DEB: nids_exit (in /usr/lib/libnids.so.1.24)
==7504==    by 0x4026D0: signal_handler (signalhandling.c:17)
==7504==    by 0x5B6313F: ??? (in /lib/libpthread-2.15.so)
==7504==    by 0x5B5FC60: pthread_cond_timedwait@@GLIBC_2.3.2 (in /lib/libpthread-2.15.so)
==7504==    by 0x58E37D4: g_cond_wait_until (in /usr/lib/libglib-2.0.so.0.3200.1)
==7504==    by 0x587E2C0: ??? (in /usr/lib/libglib-2.0.so.0.3200.1)
==7504==    by 0x587E909: g_async_queue_timeout_pop (in /usr/lib/libglib-2.0.so.0.3200.1)
==7504==    by 0x4022D2: analyzer_thread_func (analyzers.c:93)
==7504==    by 0x58CA0C4: ??? (in /usr/lib/libglib-2.0.so.0.3200.1)
==7504==    by 0x5B5BE0D: start_thread (in /lib/libpthread-2.15.so)

More of the output can be found at: http://pastebin.com/93gkSScS

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:26:52+00:00Added an answer on June 3, 2026 at 5:26 pm

    The Valgrind output shows that libpcap (from inside nids_run) tries to read memory locations after nids_exit frees them:

    e.g.:

    ==7504== Invalid read of size 4
    ==7504==    at 0x654EDC1: ??? (in /usr/lib/libpcap.so.1.2.1)
    ==7504==    by 0x6551EE0: pcap_loop (in /usr/lib/libpcap.so.1.2.1)
    ==7504==    by 0x5250E65: nids_run (in /usr/lib/libnids.so.1.24)
    
    Address 0x70eece8 is 40 bytes inside a block of size 768 free'd
    ==7504==    at 0x4C29A9E: free
    ==7504==    by 0x5250DEB: nids_exit (in /usr/lib/libnids.so.1.24)
    

    So that is a 768 sized block, that is freed in nids_exit, and subsequently read inside nids_run (which apparently has not stopped yet).

    All other errors are similar (nids_exit frees a block, and nids_run continues to try to use it.

    What this means is: You’re either not using libnids (nids_run/nids_exit) correctly, or there is a bug in libnids.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use SharpSvn library from CollabNET. I would like to set revision author while
I'm trying to use this library (which looks very nice) but I'm having difficulty
When debugging a function I usually use library(debug) mtrace(FunctionName) FunctionName(...) And that works quite
I use library which download torrents. But today some error happened (log): Could not
I use library which uses sfl4j-api for logging in android application. So I use
I want to use a library developed by someone else, of which I only
We use Enterprise Library 3.0 to access Oracle DB (microsoft oracle client). What happens
I use this library: https://github.com/robbiehanson/CocoaAsyncSocket My test code: #import <UIKit/UIKit.h> @class GCDAsyncUdpSocket; @interface ThirdViewController
How can I use Enterprise Library to do a Data Access Layer in c#
When should you use a library or a framework vs your own implementation. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.