Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 May 2012 11:59:57 -0700 (PDT)
From:      Unga <unga888@yahoo.com>
To:        Robert Bonomi <bonomi@mail.r-bonomi.com>, "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Cc:        "kickbsd@yandex.com" <kickbsd@yandex.com>
Subject:   Re: Segmentation fault in FreeBSD 9.0 flockfile ()
Message-ID:  <1335985197.76056.YahooMailNeo@web160105.mail.bf1.yahoo.com>
In-Reply-To: <201205020638.q426cXhg008660@mail.r-bonomi.com>
References:  <1335932118.29543.YahooMailNeo@web160102.mail.bf1.yahoo.com> <201205020638.q426cXhg008660@mail.r-bonomi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> From: Robert Bonomi <bonomi@mail.r-bonomi.com>=0A> To: freebsd-questions@=
freebsd.org=0A> Cc: =0A> Sent: Wednesday, May 2, 2012 6:38 AM=0A> Subject: =
Re: Segmentation fault in FreeBSD 9.0 flockfile ()=0A> =0A> =0A> Unga <unga=
888@yahoo.com> wrote;=0A>>  From: Darren Baginski <kickbsd@yandex.com>=0A>>=
  > Unga <unga888@yahoo.com> wrote:=0A>>  > =0A>>  >01.05.2012, 22:08, "Ung=
a" <unga888@yahoo.com>:=0A>>  >> Hi all=0A>>  >>=0A>>  >> I'm getting a=A0 =
Segmentation fault in FreeBSD 9.0 as follows =0A> for myprog.c:=0A>>  >>=0A=
>>  >> Reading symbols from /libexec/ld-elf.so.1...done.=0A>>  >> Loaded sy=
mbols for /libexec/ld-elf.so.1=0A>>  >> #0=A0 0x28ebb062 in flockfile () fr=
om /lib/libc.so.7=0A>>  >> [New Thread 29c04900 (LWP 100575/SDLTimer)]=0A>>=
  >> [New Thread 29c04300 (LWP 100416/myprog)]=0A>>  >> (gdb)=0A>>  >> (gdb=
) info threads=0A>>  >> * 2 Thread 29c04300 (LWP 100416/myprog)=A0 0x28ebb0=
62 in flockfile =0A> ()=0A>>  >>=A0 =A0 from /lib/libc.so.7=0A>>  >>=A0  1 =
Thread 29c04900 (LWP 100575/SDLTimer)=A0 0x28e1527b in _umtx_op =0A> ()=0A>=
>  >>=A0 =A0 from /lib/libc.so.7=0A>>  >> (gdb)=0A>>  >>=0A>>  >> I don't u=
se flockfile () directly in my program.=0A>>  >>=0A>>  >=0A>>  >Hi!=0A>>  >=
=0A>>  >Mind to share code snippet caused the problem?=0A>> =0A>>  Hi Thank=
s for the reply. I have mentioned in my original post that neithe=0A>>  r I=
 nor SDL use the flockfile () in the source.=0A>> =0A> =0A> There was a _re=
ason_ the prior poster asked about seeing your code.=0A> The information yo=
u provided is not adequate/sufficient for anyone to=0A> have any chance of =
helping you.=A0 Informationn that -is- necessary was=0A> therefore requeste=
d.=A0 =0A> =0A> What you "don't use" is irrelevant to solving the problem. =
=0A> =0A> To be any help one must figure out what you _did_ do -- which =3D=
indirectly=3D =0A> calls flockfile().=0A> =0A> Your code calls "something" =
in 'libc'=A0 that calls flockfile().=0A> =0A> You "don't know" what that so=
mething in your code is.=A0 Other eyes =0A> _might_=0A> recognize it, -if- =
they saw what you were doing.=0A> =0A> Here is how to find out what does th=
at calling, yourself.=0A> 1) recompile all the components of 'myprog' with =
the '-g' =0A> compiler option.=0A> 2) start 'script', so that you have a co=
mplete log of the debugger =0A> session.=0A> 3) load the debugger with 'myp=
rog' as the program to be debugged.=0A> 4) set a breakpoinnt in the 'flockf=
ile' function=0A> 5) 'run' the program=0A> 6) when it stops at flockfile() =
entry. use 'where' to see a stack trace.=0A> 7) 'display' each of the argum=
ents to flockfile().=0A> 9) go 'up' to the calling code.=0A> 9) repeat step=
s 7 and 8 util you reach 'your' code.=0A> 10) now 'continue' the program.=
=A0 If it immediately segfaults, this was =0A> the=0A> =A0 =A0 offending ca=
ll.=A0 Otherwise, the program will stop aggain at another=0A> =A0 =A0 flock=
file() invocation. repeat from step 7 -until- you get the segfault.=0A> =0A=
> If, from that debugger session, you still don't see anything wrong, post=
=0A> the log of the debugger session.=0A> =0A> There is a *remote* possibil=
ity that the program will run properly under=0A> the debugger, while it cra=
shes when run directly.=A0 This has been known =0A> to happen when a progra=
m _uses_ a variable before initializing it.=0A> =0A> *IF* that happens, you=
 will have to modify 'myprog' to add diagnostic=0A> output before and after=
 each identified point (above) in your code that=0A> indirectly invokes flo=
ckfile() to find which is failing.=A0 =0A> =0A> In _that_ event, you =3Dwil=
l=3D have to post the 'relevant' source-code from=0A> 'myprog', with the fa=
iling statement identified.=0A> =0AHopefully I have not offended anyone wit=
h my reply :) Very sorry if I did.=0A=0AMy this FreeBSD 9.0 box is seems ve=
ry messy. I have another issue that getaddrinfo(3) doesn't accept "localhos=
t". =0A=0AAfter installing FreeBSD 9.0, I installed KDE, then realised that=
 the existing Intel display driver does not support my Intel Sandy Bridge b=
ased GPU. So I had to patch the kernel to support KMS based latest Intel dr=
iver, upgraded to Xorg to 7.5.2, etc. etc. Whole process was done multiple =
times as I was new to this complex upgrade.=0A=0AI presume, I should erase =
off the hard disk and reinstall everything cleanly and then retry my progra=
ms on FreeBSD 9.0. If the problem still persists, I'll surely do a detailed=
 debug. Pls note, whole thing works well on FreeBSD 8.1.=0A=0AAs this is ti=
me consuming and as per existing commitments, I only try this at least in a=
nother two weeks time. I will sure let the list know the outcome.=0A=0ABest=
 regards=0AUnga



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