[MemoryBuiltins] Clean up strdup handling (NFCI) (#246693)
Now that strdup/strndup are the only allocators that still need special
handling, remove unnecessary genericity from the code.
We only need to actually handle strdup/strndup in one place, which is
getAllocSize(), so keep things local to that code.
[asan] Describe the reported address if a range runs past a freed chunk (#243938)
If an access starts inside a heap chunk and runs past its end, the
report describes the byte after the chunk. That is normally the first
bad byte in a live chunk. In a freed chunk the first byte of the access
is already bad, so describe that one. For `p = malloc(40); free(p);
memcpy(dst, p + 8, 41);`:
```
ERROR: AddressSanitizer: heap-use-after-free on address 0x...18
before: 0x...38 is located 0 bytes after 40-byte region [0x...10,0x...38)
after: 0x...18 is located 8 bytes inside of 40-byte region [0x...10,0x...38)
```
Reports about live chunks do not change.
Assisted-by: Claude. I have reviewed every line of this PR.
18821 loader: tftp recvtftp() should read the error code once
Reviewed by: Andy Fiddaman <illumos at fiddaman.net>
Reviewed by: Sebastian Wiedenroth <wiedi at frubar.net>
Approved by: Gordon Ross <gordon.w.ross at gmail.com>
[asan] Complete the report when a stack frame has no valid header (#243684)
If a stack frame's magic number is missing, a CHECK fails while the
report is being prepared and the error itself is never printed:
```
CHECK failed: asan_thread.cpp "((ptr[0] == kCurrentStackFrameMagic)) != (0)"
```
Return "no frame found" instead, so the report completes and names the
thread whose stack holds the address. `__asan_locate_address` and
`__asan_describe_address` no longer die on such an address either.
Users hit this CHECK in google/sanitizers#1010, google/sanitizers#1531
and google/sanitizers#1669 (not reproduced).
Assisted-by: Claude. I have read every line of this PR.
[asan] Handle free-size-mismatch in __asan_get_report_dealloc_address (#243682)
`__asan_get_report_dealloc_address` returns 0 for free-size-mismatch
(`free_sized`, `free_aligned_sized`), so an `__asan_on_error` callback
or a debugger cannot get the address. Return the pointer and the size
that the caller passed, as for new-delete-type-mismatch.
Assisted-by: Claude. I have read every line of this PR.
net/wol: use hostwatch dump_full for dual-stack online status in widget (#5980)
Add WolController::getHostStatusAction() (/api/wol/wol/get_host_status) querying configd 'hostwatch dump_full' (list_hosts.py -v -n) to determine online status across both IPv4 and IPv6.
In discovery mode, mark hosts online when at least one entry for the configured physical interface and MAC was seen within the last 300 seconds (server UTC clock). In arp-ndp fallback mode (when hostwatch is disabled), fall back to live ARP/NDP presence.
Matching across all host entries per physical interface and lowercased MAC also resolves multi-IP and multi-interface MAC lookups (#5790).
Update WakeOnLan.js and Metadata/WakeOnLan.xml to use the new endpoint, and remove the now-unused api/diagnostics/interface/get_arp* pattern from ACL.xml.
Closes #5976
[asan] Drop repeated address checks from __asan_region_is_poisoned (#242408)
`__asan_region_is_poisoned` checks both ends of the region with
`AddrIsInMem`, and `MemToShadow` then checks them again. Use
`MEM_TO_SHADOW` directly and drop the redundant rounding and CHECKs.
Interceptors call this for every range above 64 bytes (32 on 32-bit).
For heap and stack ranges on x86_64 Linux it saves about 60 instructions
per call (190 to 131 for 65 bytes).
Assisted-by: Claude. I have read every line of this PR.
[AMDGPU] Ignore debug uses when choosing the i1 lane-mask lowering (#244887)
SILowerI1Copies decides whether an i1 value defined in a loop is
observed
outside the loop from the blocks of all its uses, DBG_VALUEs included. A
DBG_VALUE of a divergent i1 loop phi or copy in the loop exit block
therefore
selects the loop lowering, and -g adds lane-mask merge instructions
(s_andn2/s_or) to the loop and uses extra SGPRs.
Use use_nodbg_instructions in both places that build this bound,
PhiLoweringHelper::mergeIncomingLaneMasks and
Vreg1LoweringHelper::lowerCopiesToI1. The new test checks the same
output
with and without debugify for a loop phi and for a copy.
Fixes llvm/llvm-project#242595
[AMDGPU] Stop DBG_VALUEs in a bundle from changing the post-RA schedule (#244891)
SIInstrInfo::getInstrLatency gives a BUNDLE the largest latency of its
instructions plus one cycle for each additional instruction.
SIPostRABundler
keeps meta instructions between the memory instructions of a clause, so
each
DBG_VALUE inside the bundle adds a cycle, and -g changes the post-RA
schedule.
For example, in a kernel that calls a function and then uses its pointer
argument, -g reorders the kernel argument loads and the scratch setup.
Skip debug instructions when computing the latency of a bundle, since
they
do not issue. The new test checks the same schedule with and without the
debug
info.
[PowerPC] Do not read FPSCR for a SETRNDi/SETFLM result with only debug uses (#242640)
The `SETRNDi` and `SETFLM` custom inserters emit an `IMPLICIT_DEF`
instead
of `mffs` when the old FPSCR value is unused, but they test this with
`use_empty()`, which counts `DBG_VALUE`s. A variable that keeps the old
value, such as `double old = __builtin_setrnd(1);` with `old` otherwise
unused, therefore adds an `mffs` under `-g`.
Use `use_nodbg_empty()`. The old value is then no longer computed, so
mark
its debug uses undef.
The new functions in `setrnd.ll` use the result of `llvm.ppc.setrnd`
with a
constant (`SETRNDi`) and of `llvm.ppc.setflm` (`SETFLM`) only in a
`#dbg_value`. Without the change `MFFS` is emitted and the debug value
refers to it; with it the result is an `IMPLICIT_DEF`, the debug value
is
[6 lines not shown]
[SPARC] Use the post-RA machine scheduler for LEON5 (#245211)
Enable post-RA scheduling in the LEON5 model so that spills, reloads and
similar added after the pre-RA scheduler are scheduled too.
Use the post-RA machine scheduler, as the LEON5 model has no itineraries
for the list scheduler. No other SPARC processor enables post-RA
scheduling, so only LEON5 is affected.
Assisted-by: Claude