segfault if I call func from a lib, why?

This is a discussion on segfault if I call func from a lib, why? within the Linux Programming forums, part of the Platform Specific Boards category; hi every1, perhaps some one be able to help me in that worst deal... actually I use libiptc & libxtables ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    77

    segfault if I call func from a lib, why?

    hi every1,
    perhaps some one be able to help me in that worst deal...
    actually I use libiptc & libxtables from netfilter project and have got this trace....
    it happening every time if I do to call function from those libraries, e.g xtables_error(), xtables_find_target(), add_command() and any other..., but unfortunately everywhere I has segfault.
    Code:
    ==21005== Invalid read of size 4
    ==21005==    at 0x4050D4B: xtables_find_target (xtables.c:626)
    ==21005==    by 0x804C723: main (in /home/quant/table)
    ==21005==  Address 0x4 is not stack'd, malloc'd or (recently) free'd
    ==21005==
    ==21005== Process terminating with default action of signal 11 (SIGSEGV)
    ==21005==  Access not within mapped region at address 0x4
    ==21005==    at 0x4050D4B: xtables_find_target (xtables.c:626)
    ==21005==    by 0x804C723: main (in /home/quant/table)
    --21005-- REDIR: 0x40c4790 (free) redirected to 0x4022ad0 (free)
    ==21005==
    ==21005== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 19 from 1)
    there... how i do configuration libs after building and installation.
    Code:
    ./configure --prefix=/usr/local --enable-devel --enable-libipq --enable-static

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by quantt View Post
    actually I use libiptc & libxtables from netfilter project and have got this trace....
    it happening every time if I do to call function from those libraries,
    Looks to me like this netfilter project has some bugs! See if they have a mailing list and write to the developers.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    Option "--enable-static" maybe installing static version of netfilter libraries while cc wants the dynamic ones.
    Is there an option to install the dynamically linked netfilter libraries?

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    Quote Originally Posted by quantt View Post
    Code:
    ==21005==  Address 0x4 is not stack'd, malloc'd or (recently) free'd
    Classic sign of trying to access a structure member through a pointer when the pointer is NULL. Either the lib has a bug (less likely) or you are passing it a NULL pointer somewhere that you shouldn't (more likely)
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Registered User
    Join Date
    Mar 2009
    Posts
    37
    Brewbuck,

    I agree with you about that

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 08-16-2009, 10:49 AM
  2. Delete & print func()
    By spentdome in forum C Programming
    Replies: 5
    Last Post: 05-29-2002, 09:02 AM
  3. help me using lib from Visual C++ 6
    By oskilian in forum Windows Programming
    Replies: 3
    Last Post: 10-11-2001, 11:28 AM
  4. Recursive Functions
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 10-10-2001, 07:47 PM
  5. Pls help me to do this project in C I need source code
    By sureshmenon74 in forum C Programming
    Replies: 4
    Last Post: 10-04-2001, 06:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21