Repository navigation
native interop: fix syslog on Apple arm64, stop starting getprop #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4485723
Probes for f045 & f046
FreeAndNil 9df80b1
detect Android without starting getprop #325
FreeAndNil 40621f4
use AutoTempEnvironmentVariable in the env var tests #325
FreeAndNil e48a2b5
release the FormatMessage buffer with LocalFree #325
FreeAndNil 7202528
pass no variadic argument to syslog #325
FreeAndNil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/changelog/3.5.0/325-android-detection-without-getprop.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns="https://logging.apache.org/xml/ns" | ||
| xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd" | ||
| type="changed"> | ||
| <issue id="325" link="https://github.com/apache/logging-log4net/pull/325"/> | ||
| <description format="asciidoc"> | ||
| detect Android from the file system instead of starting `getprop`, which `SystemInfo` ran on | ||
| every Unix host, resolved through `PATH`, so the first match there decided the answer (audit | ||
| da18b6fd-f048, fixed by @FreeAndNil) | ||
| </description> | ||
| </entry> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns="https://logging.apache.org/xml/ns" | ||
| xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd" | ||
| type="changed"> | ||
| <issue id="325" link="https://github.com/apache/logging-log4net/pull/325"/> | ||
| <description format="asciidoc"> | ||
| release the `FormatMessage` buffer in `NativeError` with `LocalFree`, the allocator that API | ||
| uses, instead of letting the marshaller free it as COM task memory. Both hit the process heap on | ||
| current Windows, so this is hygiene rather than a fix (audit da18b6fd-f045, fixed by @FreeAndNil) | ||
| </description> | ||
| </entry> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns="https://logging.apache.org/xml/ns" | ||
| xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd" | ||
| type="fixed"> | ||
| <issue id="325" link="https://github.com/apache/logging-log4net/pull/325"/> | ||
| <description format="asciidoc"> | ||
| stop `LocalSyslogAppender` passing a variadic argument to `syslog(3)`, which on Apple arm64 | ||
| travels differently from a fixed one, so the callee read a pointer the runtime never wrote there | ||
| and logged stack bytes or crashed. Only the two fixed parameters are declared now, and the record | ||
| is passed as the format string with its percent signs escaped. The logged text is unchanged | ||
| (audit da18b6fd-f046, fixed by @FreeAndNil) | ||
| </description> | ||
| </entry> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #region Apache License | ||
| // | ||
| // Licensed to the Apache Software Foundation (ASF) under one or more | ||
| // contributor license agreements. See the NOTICE file distributed with | ||
| // this work for additional information regarding copyright ownership. | ||
| // The ASF licenses this file to you under the Apache License, Version 2.0 | ||
| // (the "License"); you may not use this file except in compliance with | ||
| // the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
| #endregion | ||
|
|
||
| using System.ComponentModel; | ||
|
|
||
| using log4net.Util; | ||
|
|
||
| using NUnit.Framework; | ||
|
|
||
| namespace log4net.Tests.Util; | ||
|
|
||
| /// <summary> | ||
| /// Tests for <see cref="NativeError"/>, which formats a Win32 error code through | ||
| /// <c>FormatMessage</c> and releases its buffer itself. | ||
| /// </summary> | ||
| [TestFixture] | ||
| [Platform("Win")] | ||
| public sealed class NativeErrorTest | ||
| { | ||
| /// <summary>ERROR_FILE_NOT_FOUND, a code every Windows has a message for.</summary> | ||
| private const int FileNotFound = 2; | ||
|
|
||
| /// <summary> | ||
| /// The framework formats the same code through the same API, so it is the text oracle. Only the | ||
| /// trailing period differs: .NET Framework strips it, log4net and .NET do not. | ||
| /// </summary> | ||
| [Test] | ||
| public void TheMessageIsTheOneWindowsReports() | ||
| => Assert.That(NativeError.GetErrorMessage(FileNotFound)?.TrimEnd('.'), | ||
| Is.EqualTo(new Win32Exception(FileNotFound).Message.TrimEnd('.'))); | ||
|
|
||
| /// <summary>The message arrives without the newlines <c>FormatMessage</c> appends.</summary> | ||
| [Test] | ||
| public void TheMessageCarriesNoTrailingNewLine() | ||
| => Assert.That(NativeError.GetErrorMessage(FileNotFound), Does.Not.Match("[\r\n]$")); | ||
|
|
||
| /// <summary>Zero is "no error", which has no message rather than an empty one.</summary> | ||
| [Test] | ||
| public void ThereIsNoMessageForErrorZero() | ||
| => Assert.That(NativeError.GetErrorMessage(0), Is.Null); | ||
|
|
||
| /// <summary> | ||
| /// Driven hard enough that a heap the wrong release had corrupted would show up here. | ||
| /// </summary> | ||
| [Test] | ||
| public void RepeatedUseKeepsReturningTheSameMessage() | ||
| { | ||
| string? first = NativeError.GetErrorMessage(FileNotFound); | ||
|
|
||
| for (int i = 0; i < 500; i++) | ||
| { | ||
| Assert.That(NativeError.GetErrorMessage(FileNotFound), Is.EqualTo(first)); | ||
| } | ||
|
|
||
| Assert.That(first, Is.Not.Null.And.Not.Empty); | ||
| } | ||
|
|
||
| /// <summary>The number and the message both reach the formatted text.</summary> | ||
| [Test] | ||
| public void ToStringCarriesTheNumberAndTheMessage() | ||
| => Assert.That(NativeError.GetError(FileNotFound).ToString(), | ||
| Is.EqualTo($"0x00000002: {NativeError.GetErrorMessage(FileNotFound)}")); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.