Hello Misc, I have been trying to get Valgrind to run on OpenBSD 6.1-release, with all errata applied via syspatch(8), and I am having no luck. When executing Valgrind against any binary (or no binary at all), it claims to run out of memory and dumps a W^X violation error into the dmesg output.
There have been several other mailing list posts about this issue over the last few months, but nothing seems to have come of it: http://openbsd-archive.7691.n7.nabble.com/valgrind-error-W-X-violation-td299828.html http://openbsd-archive.7691.n7.nabble.com/W-X-issues-running-valgrind-td305977.html I have tried reaching out to the package maintainer listed in pkg_info, but haven’t heard anything back yet. Is there anything that I can do to assist in debugging and fixing this issue? If it would be of any use to anyone, I have ktrace dumps, but the output was a bit verbose for an already long email. I can forward along if it would be helpful. It appears that the next step may be to update my system to follow current, grab a copy of the ports tree, and attempt to build the package with -Wl,-z,wxneeded. Am I on the right track here? Relevant command output follows: === $ valgrind -q ls --73181:0:aspacem <<< SHOW_SEGMENTS: out_of_memory (20 segments, 0 segnames) --73181:0:aspacem 0: RSVN 0000000000-0003ffffff 64m ----- SmFixed --73181:0:aspacem 1: 0004000000-0037ffffff 832m --73181:0:aspacem 2: ANON 0038000000-003835ffff 3538944 r-x-- --73181:0:aspacem 3: 0038360000-003845efff 1044480 --73181:0:aspacem 4: FILE 003845f000-00384f4fff 614400 r---- d=0x000 i=0 o=3534848 (-1) --73181:0:aspacem 5: 00384f5000-00385f4fff 1048576 --73181:0:aspacem 6: FILE 00385f5000-00385fdfff 36864 rw--- d=0x000 i=0 o=4149248 (-1) --73181:0:aspacem 7: ANON 00385fe000-00385fefff 4096 rw--- --73181:0:aspacem 8: 00385ff000-00386fdfff 1044480 --73181:0:aspacem 9: FILE 00386fe000-00386fefff 4096 rw--- d=0x000 i=0 o=4186112 (-1) --73181:0:aspacem 10: ANON 00386ff000-003a150fff 26m rw--- --73181:0:aspacem 11: 003a151000-02e6faffff 10958m --73181:0:aspacem 12: ANON 02e6fb0000-02e6fb0fff 4096 r-x-- --73181:0:aspacem 13: 02e6fb1000-0801ffffff 20912m --73181:0:aspacem 14: RSVN 0802000000-0802000fff 4096 ----- SmFixed --73181:0:aspacem 15: 0802001000-0fffffffff 32735m --73181:0:aspacem 16: RSVN 1000000000-7f7ffded9fff 130495g ----- SmFixed --73181:0:aspacem 17: ANON 7f7ffdeda000-7f7fffbd9fff 29m ----- --73181:0:aspacem 18: ANON 7f7fffbda000-7f7ffffd9fff 4194304 rw--- --73181:0:aspacem 19: RSVN 7f7ffffda000-ffffffffffffffff 16383e ----- SmFixed --73181:0:aspacem >>> --73181-- core : 0/ 0 max/curr mmap'd, 0/0 unsplit/split sb unmmap'd, 0/ 0 max/curr, 0/ 0 totalloc-blocks/bytes, 0 searches 8 rzB --73181-- dinfo : 0/ 0 max/curr mmap'd, 0/0 unsplit/split sb unmmap'd, 0/ 0 max/curr, 0/ 0 totalloc-blocks/bytes, 0 searches 8 rzB --73181-- (null) : 0/ 0 max/curr mmap'd, 0/0 unsplit/split sb unmmap'd, 0/ 0 max/curr, 0/ 0 totalloc-blocks/bytes, 0 searches 0 rzB --73181-- demangle: 0/ 0 max/curr mmap'd, 0/0 unsplit/split sb unmmap'd, 0/ 0 max/curr, 0/ 0 totalloc-blocks/bytes, 0 searches 8 rzB --73181-- ttaux : 0/ 0 max/curr mmap'd, 0/0 unsplit/split sb unmmap'd, 0/ 0 max/curr, 0/ 0 totalloc-blocks/bytes, 0 searches 8 rzB --73181-- translate: fast SP updates identified: 0 ( --%) --73181-- translate: generic_known SP updates identified: 0 ( --%) --73181-- translate: generic_unknown SP updates identified: 0 ( --%) --73181-- tt/tc: 0 tt lookups requiring 0 probes --73181-- tt/tc: 0 fast-cache updates, 0 flushes --73181-- transtab: new 0 (0 -> 0; ratio 0:10) [0 scs] --73181-- transtab: dumped 0 (0 -> ??) --73181-- transtab: discarded 0 (0 -> ??) --73181-- scheduler: 0 event checks. --73181-- scheduler: 0 indir transfers, 0 misses (1 in 0) --73181-- scheduler: 0/0 major/minor sched events. --73181-- sanity: 0 cheap, 0 expensive checks. ==73181== ==73181== Valgrind's memory management: out of memory: ==73181== newSuperblock's request for 4194304 bytes failed. ==73181== 65748992 bytes have already been allocated. ==73181== Valgrind cannot continue. Sorry. ==73181== ==73181== There are several possible reasons for this. ==73181== - You have some kind of memory limit in place. Look at the ==73181== output of 'ulimit -a'. Is there a limit on the size of ==73181== virtual memory or address space? ==73181== - You have run out of swap space. ==73181== - Valgrind has a bug. If you think this is the case or you are ==73181== not sure, please let us know and we'll try to fix it. ==73181== Please note that programs can take substantially more memory than ==73181== normal when running under Valgrind tools, eg. up to twice or ==73181== more, depending on the tool. On a 64-bit machine, Valgrind ==73181== should be able to make use of up 32GB memory. On a 32-bit ==73181== machine, Valgrind should be able to use all the memory available ==73181== to a single process, up to 4GB if that's how you have your ==73181== kernel configured. Most 32-bit Linux setups allow a maximum of ==73181== 3GB per process. ==73181== ==73181== Whatever the reason, Valgrind cannot continue. Sorry. $ dmesg OpenBSD 6.1 (GENERIC) #8: Mon May 22 20:27:59 CEST 2017 rob...@syspatch-61-amd64.openbsd.org<mailto:rob...@syspatch-61-amd64.openbsd.org>:/usr/src/sys/arch/amd64/compile/GENERIC real mem = 2130640896 (2031MB) avail mem = 2061524992 (1966MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.5 @ 0xe1000 (10 entries) bios0: vendor innotek GmbH version "VirtualBox" date 12/01/2006 bios0: innotek GmbH VirtualBox acpi0 at bios0: rev 2 acpi0: sleep states S0 S5 acpi0: tables DSDT FACP APIC SSDT acpi0: wakeup devices acpitimer0 at acpi0: 3579545 Hz, 32 bits acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz, 2491.44 MHz cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,RDRAND,NXE,RDTSCP,LONG,LAHF,ABM,ITSC cpu0: 256KB 64b/line 8-way L2 cache cpu0: TSC frequency 2491436930 Hz cpu0: smt 0, core 0, package 0 mtrr: CPU supports MTRRs but not enabled by BIOS cpu0: apic clock running at 1000MHz cpu0: mwait min=64, max=64 ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 20, 24 pins acpiprt0 at acpi0: bus 0 (PCI0) acpicpu0 at acpi0: C1(@1 halt!) "PNP0303" at acpi0 not configured "PNP0F03" at acpi0 not configured acpibat0 at acpi0: BAT0 model "1" serial 0 type VBOX oem "innotek" acpiac0 at acpi0: AC unit online acpivideo0 at acpi0: GFX0 pci0 at mainbus0 bus 0 pchb0 at pci0 dev 0 function 0 "Intel 82441FX" rev 0x02 pcib0 at pci0 dev 1 function 0 "Intel 82371SB ISA" rev 0x00 pciide0 at pci0 dev 1 function 1 "Intel 82371AB IDE" rev 0x01: DMA, channel 0 configured to compatibility, channel 1 configured to compatibility wd0 at pciide0 channel 0 drive 0: <VBOX HARDDISK> wd0: 128-sector PIO, LBA, 20480MB, 41943040 sectors wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2 atapiscsi0 at pciide0 channel 1 drive 0 scsibus1 at atapiscsi0: 2 targets cd0 at scsibus1 targ 0 lun 0: <VBOX, CD-ROM, 1.0> ATAPI 5/cdrom removable cd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2 vga1 at pci0 dev 2 function 0 "InnoTek VirtualBox Graphics Adapter" rev 0x00 wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation) wsdisplay0: screen 1-5 added (80x25, vt100 emulation) em0 at pci0 dev 3 function 0 "Intel 82540EM" rev 0x02: apic 1 int 19, address 08:00:27:aa:0f:89 "InnoTek VirtualBox Guest Service" rev 0x00 at pci0 dev 4 function 0 not configured auich0 at pci0 dev 5 function 0 "Intel 82801AA AC97" rev 0x01: apic 1 int 21, ICH ac97: codec id 0x83847600 (SigmaTel STAC9700) audio0 at auich0 ohci0 at pci0 dev 6 function 0 "Apple Intrepid USB" rev 0x00: apic 1 int 22, version 1.0 piixpm0 at pci0 dev 7 function 0 "Intel 82371AB Power" rev 0x08: apic 1 int 23 iic0 at piixpm0 isa0 at pcib0 isadma0 at isa0 pckbc0 at isa0 port 0x60/5 irq 1 irq 12 pckbd0 at pckbc0 (kbd slot) wskbd0 at pckbd0: console keyboard, using wsdisplay0 pms0 at pckbc0 (aux slot) wsmouse0 at pms0 mux 0 pcppi0 at isa0 port 0x61 spkr0 at pcppi0 usb0 at ohci0: USB revision 1.0 uhub0 at usb0 configuration 1 interface 0 "Apple OHCI root hub" rev 1.00/1.00 addr 1 vscsi0 at root scsibus2 at vscsi0: 256 targets softraid0 at root scsibus3 at softraid0: 256 targets root on wd0a (44c07e72d464603b.a) swap on wd0b dump on wd0b memcheck-amd64-o(60871): mmap W^X violation memcheck-amd64-o(97933): mmap W^X violation memcheck-amd64-o(17438): mmap W^X violation memcheck-amd64-o(45468): mmap W^X violation memcheck-amd64-o(6173): mmap W^X violation memcheck-amd64-o(73181): mmap W^X violation $ mount /dev/wd0a on / type ffs (local) /dev/wd0k on /home type ffs (local, nodev, nosuid) /dev/wd0d on /tmp type ffs (local, nodev, nosuid) /dev/wd0f on /usr type ffs (local, nodev) /dev/wd0g on /usr/X11R6 type ffs (local, nodev) /dev/wd0h on /usr/local type ffs (local, nodev, wxallowed) /dev/wd0j on /usr/obj type ffs (local, nodev, nosuid) /dev/wd0i on /usr/src type ffs (local, nodev, nosuid) /dev/wd0e on /var type ffs (local, nodev, nosuid) $ which valgrind /usr/local/bin/valgrind $ objdump -p /usr/local/bin/valgrind /usr/local/bin/valgrind: file format elf64-x86-64 Program Header: PHDR off 0x0000000000000040 vaddr 0x0000000000000040 paddr 0x0000000000000040 align 2**3 filesz 0x0000000000000230 memsz 0x0000000000000230 flags r-x INTERP off 0x0000000000001f0e vaddr 0x0000000000101f0e paddr 0x0000000000101f0e align 2**0 filesz 0x0000000000000013 memsz 0x0000000000000013 flags r-- LOAD off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**20 filesz 0x0000000000001f0e memsz 0x0000000000001f0e flags r-x LOAD off 0x0000000000001f0e vaddr 0x0000000000101f0e paddr 0x0000000000101f0e align 2**20 filesz 0x00000000000011aa memsz 0x00000000000011aa flags r-- LOAD off 0x0000000000003d70 vaddr 0x0000000000203d70 paddr 0x0000000000203d70 align 2**20 filesz 0x00000000000002a4 memsz 0x0000000000001318 flags rw- DYNAMIC off 0x0000000000003d80 vaddr 0x0000000000203d80 paddr 0x0000000000203d80 align 2**3 filesz 0x0000000000000140 memsz 0x0000000000000140 flags rw- NOTE off 0x0000000000001f24 vaddr 0x0000000000101f24 paddr 0x0000000000101f24 align 2**2 filesz 0x0000000000000018 memsz 0x0000000000000018 flags r-- EH_FRAME off 0x0000000000002d10 vaddr 0x0000000000102d10 paddr 0x0000000000102d10 align 2**2 filesz 0x00000000000000ac memsz 0x00000000000000ac flags r-- OPENBSD_RANDOMIZE off 0x0000000000003d70 vaddr 0x0000000000203d70 paddr 0x0000000000203d70 align 2**3 filesz 0x0000000000000008 memsz 0x0000000000000008 flags rw- RELRO off 0x0000000000003d70 vaddr 0x0000000000203d70 paddr 0x0000000000203d70 align 2**3 filesz 0x0000000000000290 memsz 0x0000000000000290 flags r-- Dynamic Section: NEEDED libc.so.89.3 HASH 0x101f40 STRTAB 0x102558 SYMTAB 0x1020a8 STRSZ 0x11c SYMENT 0x18 DEBUG 0x0 PLTGOT 0x203ee0 PLTRELSZ 0x2b8 PLTREL 0x7 JMPREL 0x1026f0 RELA 0x102678 RELASZ 0x78 RELAENT 0x18 RELACOUNT 0x2 === Thanks in advance for any advice that you might be able to offer. Peter