Skip to content

native interop: fix syslog on Apple arm64, stop starting getprop - #325

Merged
FreeAndNil merged 5 commits into
masterfrom
Feature/325-native-interop
Sep 25, 2026
Merged

FreeAndNil merged 5 commits into
masterfrom
Feature/325-native-interop

Conversation

@FreeAndNil

@FreeAndNil FreeAndNil commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixed

  • LocalSyslogAppender passed a variadic argument to syslog(3), audit da18b6f-f046
    • on Apple arm64 a variadic argument goes on the stack, a fixed one in a register, so the callee
      read a slot the runtime never wrote: stack bytes in the system log, or a crash
    • proved by a probe on macOS 26.6.2 arm64, green on Linux and x64
    • variadic is not an option, CoreCLR refuses a __arglist P/Invoke, so only the two fixed
      parameters are declared and the record goes in as the format string with every % doubled
    • logged text, record length and every platform that already worked are unchanged

Changed

  • Android detection started a process, audit da18b6f-f048
    • SystemInfo ran getprop ro.build.user at type initialisation on every Unix host, off PATH,
      so the first match there decided the answer
    • now /system/bin/getprop, and the platform itself off net462
  • The FormatMessage buffer was released by the wrong allocator, audit da18b6f-f045
    • the API allocates with LocalAlloc, the ref string marshalling freed it as COM task memory
    • now out IntPtr, PtrToStringUni over the returned length, LocalFree in a finally
    • hygiene, not a fix: a probe found the block inside the process heap

Tests

  • both probes are gone, each replaced by the regression test of its fix
  • the f048 and f046 tests fail against the old code; f045 has none, hence hygiene

FreeAndNil added a commit that referenced this pull request Sep 21, 2026
- SystemInfo ran "getprop ro.build.user" on every Unix host, via PATH
- first PATH match decided the answer
- now /system/bin/getprop, plus the platform itself off net462
- System.Diagnostics.Process out of the startup path

audit da18b6f-f048
@FreeAndNil
FreeAndNil force-pushed the Feature/325-native-interop branch from ed5e345 to 7842360 Compare September 21, 2026 20:15
FreeAndNil added a commit that referenced this pull request Sep 21, 2026
- process level env var tests restore through a using, not by hand
- ProcessLevelEnvironmentVariable leaked the variable on a failed assert
- Machine and User targets keep cleaning up themselves, not covered
FreeAndNil added a commit that referenced this pull request Sep 21, 2026
- FormatMessage allocates with LocalAlloc, the ref string marshalling
  freed it as COM task memory
- now out IntPtr, PtrToStringUni over the returned length, LocalFree in
  a finally
- hygiene, not a fix: the probe found the block inside the process heap
- WindowsAllocatorProbeTest replaced by NativeErrorTest

audit da18b6f-f045
FreeAndNil added a commit that referenced this pull request Sep 21, 2026
- a variadic argument goes on the stack on Apple arm64, a fixed one in a
  register, so the callee read the wrong slot
- declaring it variadic is out: CoreCLR refuses a __arglist P/Invoke
- only the two fixed parameters now, record as the format string with
  every percent sign doubled
- logged text, length and platforms that worked stay as they were
- VariadicAbiProbeTest replaced by the escaping and signature tests

audit da18b6f-f046
@FreeAndNil FreeAndNil changed the title Feature/325 native interop native interop: fix syslog on Apple arm64, stop starting getprop Sep 21, 2026
@FreeAndNil FreeAndNil added this to the 3.5.0 milestone Sep 22, 2026
@FreeAndNil
FreeAndNil changed the base branch from master to Feature/2.x September 24, 2026 08:38
@FreeAndNil
FreeAndNil changed the base branch from Feature/2.x to master September 24, 2026 08:38
- SystemInfo ran "getprop ro.build.user" on every Unix host, via PATH
- first PATH match decided the answer
- now /system/bin/getprop, plus the platform itself off net462
- System.Diagnostics.Process out of the startup path

audit da18b6f-f048
- process level env var tests restore through a using, not by hand
- ProcessLevelEnvironmentVariable leaked the variable on a failed assert
- Machine and User targets keep cleaning up themselves, not covered
- FormatMessage allocates with LocalAlloc, the ref string marshalling
  freed it as COM task memory
- now out IntPtr, PtrToStringUni over the returned length, LocalFree in
  a finally
- hygiene, not a fix: the probe found the block inside the process heap
- WindowsAllocatorProbeTest replaced by NativeErrorTest

audit da18b6f-f045
- a variadic argument goes on the stack on Apple arm64, a fixed one in a
  register, so the callee read the wrong slot
- declaring it variadic is out: CoreCLR refuses a __arglist P/Invoke
- only the two fixed parameters now, record as the format string with
  every percent sign doubled
- logged text, length and platforms that worked stay as they were
- VariadicAbiProbeTest replaced by the escaping and signature tests

audit da18b6f-f046
@FreeAndNil
FreeAndNil force-pushed the Feature/325-native-interop branch from 56334ea to 7202528 Compare September 24, 2026 09:12
@FreeAndNil
FreeAndNil marked this pull request as ready for review September 24, 2026 09:13
Comment thread src/log4net/Appender/LocalSyslogAppender.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants