Re: Need support in debugging Valgrind 3.18 glibc segv error
kiran hardas <[email protected]> Fri, 28 Mar 2025 16:51:42 +0530
| Newsgroups | gmane.comp.debugging.valgrind |
|---|---|
| Message-ID | <CAPyEgmZh2445u=3+R+4hCTaQDYV9figpcAXTO7Z02R4o=2iVwA@mail.gmail.com> |
--===============8988816122938903130== Content-Type: multipart/alternative; boundary="00000000000015557706316547ca" --00000000000015557706316547ca Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Team, Regarding the shmat "invalid argument" error, in continuation of debugging the issue, I have got further info. I used strace on my valgrind process id to understand better. It gave the following output for shmat function calls of my application, $ /var/run/strace -p 5564 -e shmat /var/run/strace: Process 5564 attached /var/run/strace: [ Process PID=3D5564 runs in 32 bit mode. ] shmat(0, 0x1fc15000, 0) =3D 0x1fc15000 shmat(1, 0x1fc15000, 0) =3D -1 EINVAL (Invalid argument) shmat(3, 0x1fc15000, 0) =3D -1 EINVAL (Invalid argument) +++ exited with 1 +++ shmat function is called like this in my application code, data =3D shmat(shmid, NULL, 0); /* where data is a struct pointe= r */ Here we can see that for 1st shmat call, we get an address 0x1fc15000 by default to attach. But for 2nd and 3rd shmat call by the same application process we can see the same address is getting used for attach purpose due to which it is failing and giving invalid argument error. Setup details are as follows, GNU/Linux 5.4 Glibc 2.40 gcc 14.2 binutils 2.43 valgrind-3.24.0 I tried similar check on my old version of application and it showed different address for shmat purpose as seen below, $ /var/run/strace -p 4336 -e shmat -v /var/run/strace: Process 4336 attached /var/run/strace: [ Process PID=3D4336 runs in 32 bit mode. ] shmat(0, 0x1be88000, 0) =3D 0x1be88000 shmat(1, 0x1bea8000, 0) =3D 0x1bea8000 my old setup details are as follows, GNU/Linux 5.4 Glibc 2.23 gcc 8.5 binutils 2.32 valgrind-3.18.0 In my old application version, this shmat function is working fine with valgrind. But with new glibc and new Valgrind, shmat is giving invalid argument error. Also if i use old valgrind 3.18 with my latest application version, it still gives same shmat error. Is this abnormal behaviour from valgrind or from glibc? any inputs here? (Note: only shmat is showing error, shmget is working proper under valgrind= ) Thanks & Regards, Kiran H. On Mon, Mar 24, 2025 at 9:03=E2=80=AFPM kiran hardas <[email protected]> = wrote: > Hi Paul, > > Thanks for taking time and providing inputs. I am still debugging for tha= t > shmat failure, so far no rca. > The error string that i got from perror after shmat is "Invalid argument"= . > > > Regards, > Kiran H. > > On Sat, Mar 22, 2025 at 2:18=E2=80=AFAM Paul Floyd <[email protected]> w= rote: > >> >> On 21/03/2025 09:06, kiran hardas wrote: >> > Hi Paul/Team, >> > >> > Thank you for your suggestion. I added the entry for shmget function >> > in coregrind/m_syswrap/syswrap-x86-linux.c >> > and the error got resolved for shmget function. Yes it is x86 linux >> > that is getting used. Similar errors came for shmat, shmdt, shmctl >> > functions. >> > I added similar entries of those functions too in the table and >> > resolved the errors. >> > >> > Currently i am getting error from shmat function as "Invalid argument" >> > from my application code. >> > The data pointer returned by shmat function is coming as 0xffffffff >> > which is -1 (error). I am calling the shmat as below >> > in my application code >> > >> > data =3D shmat(shmid, NULL, 0); /* where data is a struct >> > pointer and shmid is 1 obtained by a successful shmget call */ >> > >> > I verified the arguments for this shmat function and they seem to be >> > fine. Also checked for permission issues. >> > I am suspecting memory issue which could be resulting in shmat attach >> > failure after running valgrind (have glibc 2.40). >> > >> > Would appreciate any advice/suggestion you can provide for this issue. >> > >> >> Hi >> >> On the Valgrind side I've pushed a change that adds these 4 syscalls to >> x86 Linux. >> >> I can't tell why your shmat call is failing. If the shmget call to >> obtain shmid works than it ought to work. The man page lists the error >> conditions. What do you get in errno? >> >> It might be worth checking with the ipcs command to see if hou have lots >> of leftover memorys/queues/semaphores. >> >> >> A+ >> >> Paul >> >> --00000000000015557706316547ca Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hi Team,<div><br></div><div>Regarding the shmat "inva= lid argument" error, in continuation of debugging the issue, I have go= t further=C2=A0info.</div><div>I used strace on my valgrind process id to u= nderstand better. It gave the following output for shmat function calls of = my application,</div><div><br></div><div>$ /var/run/strace -p 5564 -e shmat= <br>/var/run/strace: Process 5564 attached<br>/var/run/strace: [ Process PI= D=3D5564 runs in 32 bit mode. ]<br>shmat(0, 0x1fc15000, 0) =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x1fc15000<br>shmat(1, 0x1fc1= 5000, 0) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D -1 EIN= VAL (Invalid argument)<br>shmat(3, 0x1fc15000, 0) =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D -1 EINVAL (Invalid argument)<br>+++ exi= ted with 1 +++<br><br></div><div>shmat function is called like this in my a= pplication code,</div><div><span style=3D"color:rgb(80,0,80)">data =3D shma= t(shmid, NULL, 0);=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* where data i= s a struct=C2=A0</span><span style=3D"color:rgb(80,0,80)">pointer */</span>= </div><div><br></div><div>Here we can see that for 1st shmat call, we get a= n address 0x1fc15000 by default to attach.</div><div>But for 2nd and 3rd sh= mat call by the same application process we can see the same address is get= ting used=C2=A0</div><div>for attach purpose due to which it is failing and= giving invalid argument error.</div><div><br></div><div>Setup details are = as follows,</div><div><font color=3D"#000000">GNU/Linux 5.4</font></div><di= v><font color=3D"#000000">Glibc 2.40<br style=3D"">gcc 14.2<br style=3D"">b= inutils 2.43</font></div><div><span class=3D"gmail-il">valgrind</span>-3.24= .0</div><div><br></div><div>I tried similar check on my old version of appl= ication=C2=A0and it showed different address for shmat purpose as seen belo= w,</div><div><br></div><div>$ /var/run/strace -p 4336 -e shmat -v<br>/var/r= un/strace: Process 4336 attached<br>/var/run/strace: [ Process PID=3D4336 r= uns in 32 bit mode. ]<br>shmat(0, 0x1be88000, 0) =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x1be88000<br>shmat(1, 0x1bea8000, 0) = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x1bea8000<br><= br></div><div>my old setup details are as follows,</div><div><div><font col= or=3D"#000000">GNU/Linux 5.4</font></div><div><font color=3D"#000000">Glibc= 2.23<br>gcc 8.5<br>binutils 2.32</font></div><div><span class=3D"gmail-il"= >valgrind</span>-3.18.0</div></div><div><br></div><div>In my old applicatio= n version, this shmat function is working fine with valgrind. But with new = glibc and new Valgrind, shmat is giving=C2=A0</div><div>invalid argument er= ror. Also if i use old valgrind 3.18 with my latest application version, it= still gives same=C2=A0shmat error.</div><div><br></div><div>Is this abnorm= al behaviour from valgrind or from glibc? any inputs here?=C2=A0</div><div>= (Note: only shmat is showing=C2=A0error, shmget is working proper under val= grind)</div><div><br></div><div><br></div><div>Thanks & Regards,</div><= div>Kiran H.</div><div><br></div><div><br></div><div><br></div><div><br></d= iv><div><br></div><div><br></div><div><br></div></div><br><div class=3D"gma= il_quote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Mo= n, Mar 24, 2025 at 9:03=E2=80=AFPM kiran hardas <<a href=3D"mailto:khard= [email protected]">[email protected]</a>> wrote:<br></div><blockquote cla= ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid = rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Hi Paul,<div><br></div>= <div>Thanks for taking time and providing inputs. I am still debugging for = that shmat failure,=C2=A0so far no rca.</div><div>The error string that i g= ot from perror after shmat is "Invalid argument".</div><div><br><= /div><div><br></div><div>Regards,</div><div>Kiran H.</div></div><br><div cl= ass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, Mar 22, 2= 025 at 2:18=E2=80=AFAM Paul Floyd <<a href=3D"mailto:[email protected]"= target=3D"_blank">[email protected]</a>> wrote:<br></div><blockquote c= lass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px soli= d rgb(204,204,204);padding-left:1ex"><br> On 21/03/2025 09:06, kiran hardas wrote:<br> > Hi Paul/Team,<br> ><br> > Thank you for your suggestion. I added the entry for shmget function <= br> > in coregrind/m_syswrap/syswrap-x86-linux.c<br> > and the error got resolved for shmget function. Yes it is x86 linux <b= r> > that is=C2=A0getting used. Similar errors came for shmat, shmdt, shmct= l <br> > functions.<br> > I added similar entries of those functions too in the table and <br> > resolved the=C2=A0errors.<br> ><br> > Currently i am getting error from shmat function as "Invalid argu= ment" <br> > from my application code.<br> > The data pointer returned by shmat function is coming as 0xffffffff <b= r> > which is -1 (error). I am calling the shmat as below<br> > =C2=A0in my application code<br> ><br> > data =3D shmat(shmid, NULL, 0);=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 /* where data is a struct <br> > pointer and shmid is 1 obtained by a successful=C2=A0shmget call */<br= > ><br> > I verified the arguments for this shmat function and they seem to be <= br> > fine. Also checked for permission issues.<br> > I am suspecting memory issue which could be resulting in shmat attach = <br> > failure after running valgrind (have glibc 2.40).<br> ><br> > Would appreciate any advice/suggestion you can provide for this issue.= <br> ><br> <br> Hi<br> <br> On the Valgrind side I've pushed a change that adds these 4 syscalls to= <br> x86 Linux.<br> <br> I can't tell why your shmat call is failing. If the shmget call to <br> obtain shmid works than it ought to work. The man page lists the error <br> conditions. What do you get in errno?<br> <br> It might be worth checking with the ipcs command to see if hou have lots <b= r> of leftover memorys/queues/semaphores.<br> <br> <br> A+<br> <br> Paul<br> <br> </blockquote></div> </blockquote></div> --00000000000015557706316547ca-- --===============8988816122938903130== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============8988816122938903130== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Valgrind-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/valgrind-users --===============8988816122938903130==--