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=5564 runs in 32 bit mode. ] shmat(0, 0x1fc15000, 0) = 0x1fc15000 shmat(1, 0x1fc15000, 0) = -1 EINVAL (Invalid argument) shmat(3, 0x1fc15000, 0) = -1 EINVAL (Invalid argument) +++ exited with 1 +++ shmat function is called like this in my application code, data = shmat(shmid, NULL, 0); /* where data is a struct pointer */ 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=4336 runs in 32 bit mode. ] shmat(0, 0x1be88000, 0) = 0x1be88000 shmat(1, 0x1bea8000, 0) = 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 PM kiran hardas <kharda...@gmail.com> wrote: > Hi Paul, > > Thanks for taking time and providing inputs. I am still debugging for that > 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 AM Paul Floyd <pjfl...@wanadoo.fr> wrote: > >> >> 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 = 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 >> >>
_______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users