Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 May 2012 01:38:33 -0500 (CDT)
From:      Robert Bonomi <bonomi@mail.r-bonomi.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Segmentation fault in FreeBSD 9.0 flockfile ()
Message-ID:  <201205020638.q426cXhg008660@mail.r-bonomi.com>
In-Reply-To: <1335932118.29543.YahooMailNeo@web160102.mail.bf1.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help

Unga <unga888@yahoo.com> wrote;
> From: Darren Baginski <kickbsd@yandex.com>
> > Unga <unga888@yahoo.com> wrote:
> > 
> >01.05.2012, 22:08, "Unga" <unga888@yahoo.com>:
> >> Hi all
> >>
> >> I'm getting a  Segmentation fault in FreeBSD 9.0 as follows for myprog.c:
> >>
> >> Reading symbols from /libexec/ld-elf.so.1...done.
> >> Loaded symbols for /libexec/ld-elf.so.1
> >> #0  0x28ebb062 in flockfile () from /lib/libc.so.7
> >> [New Thread 29c04900 (LWP 100575/SDLTimer)]
> >> [New Thread 29c04300 (LWP 100416/myprog)]
> >> (gdb)
> >> (gdb) info threads
> >> * 2 Thread 29c04300 (LWP 100416/myprog)  0x28ebb062 in flockfile ()
> >>    from /lib/libc.so.7
> >>   1 Thread 29c04900 (LWP 100575/SDLTimer)  0x28e1527b in _umtx_op ()
> >>    from /lib/libc.so.7
> >> (gdb)
> >>
> >> I don't use flockfile () directly in my program.
> >>
> >
> >Hi!
> >
> >Mind to share code snippet caused the problem?
> 
> Hi Thanks for the reply. I have mentioned in my original post that neithe
> r I nor SDL use the flockfile () in the source.
> 

There was a _reason_ the prior poster asked about seeing your code.
The information you provided is not adequate/sufficient for anyone to
have any chance of helping you.  Informationn that -is- necessary was
therefore requested.  

What you "don't use" is irrelevant to solving the problem. 

To be any help one must figure out what you _did_ do -- which =indirectly= 
calls flockfile().

Your code calls "something" in 'libc'  that calls flockfile().

You "don't know" what that something in your code is.  Other eyes _might_
recognize it, -if- they saw what you were doing.

Here is how to find out what does that calling, yourself.
 1) recompile all the components of 'myprog' with the '-g' compiler option.
 2) start 'script', so that you have a complete log of the debugger session.
 3) load the debugger with 'myprog' as the program to be debugged.
 4) set a breakpoinnt in the 'flockfile' function
 5) 'run' the program
 6) when it stops at flockfile() entry. use 'where' to see a stack trace.
 7) 'display' each of the arguments to flockfile().
 9) go 'up' to the calling code.
 9) repeat steps 7 and 8 util you reach 'your' code.
10) now 'continue' the program.  If it immediately segfaults, this was the
    offending call.  Otherwise, the program will stop aggain at another
    flockfile() invocation. repeat from step 7 -until- you get the segfault.

If, from that debugger session, you still don't see anything wrong, post
the log of the debugger session.

There is a *remote* possibility that the program will run properly under
the debugger, while it crashes when run directly.  This has been known 
to happen when a program _uses_ a variable before initializing it.

*IF* that happens, you will have to modify 'myprog' to add diagnostic
output before and after each identified point (above) in your code that
indirectly invokes flockfile() to find which is failing.  

In _that_ event, you =will= have to post the 'relevant' source-code from
'myprog', with the failing statement identified.








Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205020638.q426cXhg008660>