valgrind shared memory programs

Bug #2043823 reported by Philip M
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
valgrind (Ubuntu)
New
Undecided
Unassigned

Bug Description

Unexpected error occurred attempting to attach to shared memory.

This worked fine in ubuntu 20 with our APP. But is failing on ubuntu 22. I tried the latest valgrind from the internet also, same thing.

root@pmilosla-ubuntu22:/opt/iris/TAGGED/mgr# valgrind ../bin/irisdb -s.
==236668== Memcheck, a memory error detector
==236668== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==236668== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==236668== Command: ../bin/irisdb -s.
==236668==
==236668== Conditional jump or move depends on uninitialised value(s)
==236668== at 0x936BB7: mainsub (mux.c:917)
==236668== by 0x939C56: mmain (mux.c:2341)
==236668== by 0x4107C9: main (main.c:120)
==236668==
==236668== Conditional jump or move depends on uninitialised value(s)
==236668== at 0x936BCA: mainsub (mux.c:918)
==236668== by 0x939C56: mmain (mux.c:2341)
==236668== by 0x4107C9: main (main.c:120)
==236668==
Unexpected error occurred attempting to attach to shared memory.
==236668==
==236668== HEAP SUMMARY:
==236668== in use at exit: 0 bytes in 0 blocks
==236668== total heap usage: 11 allocs, 11 frees, 80,626 bytes allocated
==236668==
==236668== All heap blocks were freed -- no leaks are possible
==236668==
==236668== Use --track-origins=yes to see where uninitialised values come from
==236668== For lists of detected and suppressed errors, rerun with: -s
==236668== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
root@pmilosla-ubuntu22:/opt/iris/TAGGED/mgr#

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: valgrind (not installed)
ProcVersionSignature: Ubuntu 6.2.0-36.37~22.04.1-generic 6.2.16
Uname: Linux 6.2.0-36-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: ubuntu:GNOME
Date: Fri Nov 17 12:05:06 2023
InstallationDate: Installed on 2023-06-14 (156 days ago)
InstallationMedia: Ubuntu 22.04.2 LTS "Jammy Jellyfish" - Release amd64 (20230223)
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: valgrind
UpgradeStatus: No upgrade log present (probably fresh install)
modified.conffile..etc.default.apport:
 # set this to 0 to disable apport, or to 1 to enable it
 # you can temporarily override this with
 # sudo service apport start force_start=1
 enabled=0
mtime.conffile..etc.default.apport: 2023-07-11T12:19:20.955497

Revision history for this message
Philip M (pmilosla) wrote :
Revision history for this message
Philip M (pmilosla) wrote :
Download full text (13.9 KiB)

read(1028, "D", 1) = 1
close(4) = 0
getpid() = 237478
write(1027, "--237478-- REDIR: 0x522cc80 (lib"..., 91) = 91
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x1ffeffdb28} ---
gettid() = 237478
mmap(0x1ffeffd000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 0, 0) = 0x1ffeffd000
rt_sigreturn({mask=~[ILL TRAP BUS FPE KILL SEGV STOP SYS]}) = 7013
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x1ffeffcb28} ---
gettid() = 237478
mmap(0x1ffeffc000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 0, 0) = 0x1ffeffc000
rt_sigreturn({mask=~[ILL TRAP BUS FPE KILL SEGV STOP SYS]}) = 6501
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x1ffeffbb28} ---
gettid() = 237478
mmap(0x1ffeffb000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 0, 0) = 0x1ffeffb000
rt_sigreturn({mask=~[ILL TRAP BUS FPE KILL SEGV STOP SYS]}) = 5989
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x1ffeffafe8} ---
gettid() = 237478
mmap(0x1ffeffa000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 0, 0) = 0x1ffeffa000
rt_sigreturn({mask=~[ILL TRAP BUS FPE KILL SEGV STOP SYS]}) = 5629
getpid() = 237478
write(1027, "--237478-- REDIR: 0x5231eb0 (lib"..., 87) = 87
getpid() = 237478
getpid() = 237478
write(1027, "--237478-- REDIR: 0x5234180 (lib"..., 102) = 102
getpid() = 237478
write(1027, "--237478-- REDIR: 0x5230380 (lib"..., 86) = 86
getpid() = 237478
write(1027, "--237478-- REDIR: 0x5232240 (lib"..., 89) = 89
newfstatat(AT_FDCWD, ".", {st_mode=S_IFDIR|0775, st_size=4096, ...}, 0) = 0
getuid() = 0
getegid() = 0
setgid(1001) = 0
getpid() = 237478
write(1027, "==237478== Conditional jump or m"..., 70) = 70
getpid() = 237478
write(1027, "==237478== at 0x936BB7: mains"..., 47) = 47
getpid() = 237478
write(1027, "==237478== by 0x939C56: mmain"..., 46) = 46
getpid() = 237478
write(1027, "==237478== by 0x4107C9: main "..., 45) = 45
getpid() = 237478
write(1027, "==237478== Uninitialised value "..., 66) = 66
getpid() = 237478
write(1027, "==237478== at 0x935B36: mains"..., 47) = 47
getpid() = 237478
write(1027, "==237478== \n", 12) = 12
getpid() = 237478
write(1027, "==237478== Conditional jump or m"..., 70) = 70
getpid() = 237478
write(1027, "==237478== at 0x936BCA: mains"..., 47) = 47
getpid() = 237478
write(1027, "==237478== by 0x939C56: mmain"..., 46) = 46
getpid() ...

Revision history for this message
Philip M (pmilosla) wrote :

I also built valgrind 3.15 using the ubu 20.04 source package and that gets the same error in ubu 22.04

Revision history for this message
Philip M (pmilosla) wrote :

If anyone want a clue, the irisdb thing uses a ton of shared memory, at least 512MB always.

Revision history for this message
Philip M (pmilosla) wrote :

Just tried RH9 on the same laptop, and valgrind works there for the same shared memory app.

Revision history for this message
Pjfloyd (pjfloyd) wrote :

 ==236668== Conditional jump or move depends on uninitialised value(s)

Fix your bugs first.

Revision history for this message
Philip M (pmilosla) wrote :

This is a very old and very heavily in use application. Think interpreted language. There are many developers. There is something ubuntu 22 specific that doesn't happen on RH 9 going on with shared memory. I did fix (they were not the cause of any issue) those 2 places temporarily and I am still getting this.

Attached is a clean run without valgrind errors that still gets the shared memory attachment message when run through valgrind.

pmilosla@pmilosla-ubuntu22:mgr> grep memory valgrind_log_226662.txt
==226662== Memcheck, a memory error detector
pmilosla@pmilosla-ubuntu22:mgr> sudo valgrind --verbose --tool=memcheck --log-file=valgrind_log_%p.txt --trace-children=yes --leak-check=full --show-leak-kinds=all --track-origins=yes ../bin/irisdb -s.
Unexpected error occurred attempting to attach to shared memory.
pmilosla@pmilosla-ubuntu22:mgr> sudo ../bin/irisdb -s.

Node: pmilosla-ubuntu22, Instance: LATEST

USER>h
pmilosla@pmilosla-ubuntu22:mgr>

Revision history for this message
Philip M (pmilosla) wrote :

Up to shmat call, the args are exactly the same in both cases:
pmilosla@pmilosla-ubuntu22:mgr> sudo ../bin/irisdb -s. About to call attshm with irisdb arg:0 msgbuf:
shmem crckeystr crc:1786300436
status: 1 buf:

Node: pmilosla-ubuntu22, Instance: LATEST

USER>h
pmilosla@pmilosla-ubuntu22:mgr> sudo valgrind --verbose --tool=memcheck --log-file=valgrind_log_%p.txt --trace-children=yes --leak-check=full --show-leak-kinds=all --track-origins=yes ../bin/irisdb -s.
About to call attshm with irisdb arg:0 msgbuf:
shmem crckeystr crc:1786300436
status: -1 buf:Error 22 mapping shared memory id 0x002f8023 (keyval: 0x6a78c814)
Unexpected error occurred attempting to attach to shared memory.
pmilosla@pmilosla-ubuntu22:mgr>

pmilosla@pmilosla-ubuntu22:mgr> ipcs

------ Message Queues --------
key msqid owner perms used-bytes messages
0x00000000 98304 root 660 0 0
0x00000000 98305 root 660 0 0
0x00000000 98306 root 660 0 0

------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 1572877 pmilosla 606 15377076 2 dest
0x00000000 1572878 pmilosla 606 15377076 2 dest
0x00000000 3112976 pmilosla 600 524288 2 dest
0x00000000 1572882 pmilosla 600 524288 2 dest
0x00000000 2850845 pmilosla 600 524288 2 dest
0x00000000 3112993 pmilosla 600 524288 2 dest
0x6a78c814 3112995 root 660 1090519040 25
0x00000000 3145764 pmilosla 600 524288 2 dest
0x00000000 3113008 pmilosla 600 524288 2 dest

------ Semaphore Arrays --------
key semid owner perms nsems

Revision history for this message
Philip M (pmilosla) wrote :

If I pass a second argument to shmat of 0x8000000, the application starts up under ubuntu 22. I didnt have to do this for ubuntu 20 or RH9.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.