Skip to content

Commit 10bf48a

Browse files
committed
8350214: Test gtest/AsyncLogGtest.java fails after JDK-8349755
Reviewed-by: aboldtch, dholmes
1 parent 960ad21 commit 10bf48a

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

src/hotspot/share/logging/logAsyncWriter.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#include "memory/resourceArea.hpp"
3131
#include "runtime/atomic.hpp"
3232
#include "runtime/os.inline.hpp"
33+
#include "runtime/globals.hpp"
3334

34-
DEBUG_ONLY(bool AsyncLogWriter::ignore_recursive_logging = false;)
3535

3636
class AsyncLogWriter::AsyncLogLocker : public StackObj {
3737
static Thread* _holder;
@@ -116,10 +116,11 @@ bool AsyncLogWriter::is_enqueue_allowed() {
116116
// Do not log while holding the Async log lock.
117117
// Try to catch possible occurrences in debug builds.
118118
#ifdef ASSERT
119-
if (!AsyncLogWriter::ignore_recursive_logging) {
119+
if (!TestingAsyncLoggingDeathTestNoCrash) {
120120
ShouldNotReachHere();
121121
}
122122
#endif // ASSERT
123+
123124
return false;
124125
}
125126

@@ -142,8 +143,13 @@ bool AsyncLogWriter::enqueue(LogFileStreamOutput& output, const LogDecorations&
142143
}
143144

144145
AsyncLogLocker locker;
145-
DEBUG_ONLY(log_debug(deathtest)("Induce a recursive log for testing (for crashing)");)
146-
DEBUG_ONLY(log_debug(deathtest2)("Induce a recursive log for testing");)
146+
147+
#ifdef ASSERT
148+
if (TestingAsyncLoggingDeathTest || TestingAsyncLoggingDeathTestNoCrash) {
149+
log_debug(deathtest)("Induce a recursive log for testing");
150+
}
151+
#endif // ASSERT
152+
147153
AsyncLogWriter::instance()->enqueue_locked(&output, decorations, msg);
148154
return true;
149155
}

src/hotspot/share/logging/logAsyncWriter.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ class AsyncLogWriter : public NonJavaThread {
198198
static bool is_enqueue_allowed();
199199

200200
public:
201-
DEBUG_ONLY(static bool ignore_recursive_logging;)
202201
static bool enqueue(LogFileStreamOutput& output, const LogDecorations& decorations, const char* msg);
203202
static bool enqueue(LogFileStreamOutput& output, LogMessageBuffer::Iterator msg_iterator);
204203

src/hotspot/share/logging/logTag.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class outputStream;
6969
LOG_TAG(datacreation) \
7070
LOG_TAG(dcmd) \
7171
DEBUG_ONLY(LOG_TAG(deathtest)) /* Log Internal death test tag */ \
72-
DEBUG_ONLY(LOG_TAG(deathtest2)) /* Log Internal death test tag */ \
7372
LOG_TAG(decoder) \
7473
LOG_TAG(defaultmethods) \
7574
LOG_TAG(deoptimization) \

src/hotspot/share/logging/logTagSet.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,7 @@ void LogTagSet::log(LogLevelType level, const char* msg) {
7878
// the implied memory order of Atomic::add().
7979
LogOutputList::Iterator it = _output_list.iterator(level);
8080
LogDecorations decorations(level, *this, _decorators);
81-
#ifdef ASSERT
82-
// If we log for tag deathtest2 then we're testing that recursive logging works.
83-
// In this case, do not crash when detecting recursive logging.
84-
if (this->contains(LogTagType::_deathtest2)) {
85-
AsyncLogWriter::ignore_recursive_logging = true;
86-
}
87-
#endif
81+
8882
for (; it != _output_list.end(); it++) {
8983
(*it)->write(decorations, msg);
9084
}

src/hotspot/share/runtime/globals.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,10 @@ const int ObjectAlignmentInBytes = 8;
481481
\
482482
develop(bool, ZapTLAB, trueInDebug, \
483483
"Zap allocated TLABs") \
484+
develop(bool, TestingAsyncLoggingDeathTest, false, \
485+
"Recursive logging death test") \
486+
develop(bool, TestingAsyncLoggingDeathTestNoCrash, false, \
487+
"Recursive logging death test (no crash)") \
484488
\
485489
product(bool, ExecutingUnitTests, false, \
486490
"Whether the JVM is running unit tests or not") \

test/hotspot/jtreg/runtime/logging/AsyncDeathTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,24 @@
3838

3939
public class AsyncDeathTest {
4040
public static void main(String[] args) throws Exception {
41-
// For deathtest we expect the VM to reach ShouldNotReachHere() and die
41+
// TestingAsyncLoggingDeathTest is set: We expect the VM to reach ShouldNotReachHere() and die.
4242
ProcessBuilder pb =
43-
ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:async", "-Xlog:os,deathtest=debug", "-XX:-CreateCoredumpOnCrash", "--version");
43+
ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:async", "-Xlog:os,deathtest=debug", "-XX:-CreateCoredumpOnCrash", "-XX:+TestingAsyncLoggingDeathTest", "--version");
4444
OutputAnalyzer output = new OutputAnalyzer(pb.start());
4545
output.shouldNotHaveExitValue(0);
4646
output.shouldNotContain("Induce a recursive log for testing");
47-
// For deathtest2 we expect the VM to ignore that recursive logging has been detected and is handled by printing synchronously.
47+
// TestingAsyncLoggingDeathTestNoCrash is set: We expect the VM to ignore that recursive logging has been detected and the logging should be handled by printing synchronously.
4848
ProcessBuilder pb2 =
49-
ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:async", "-Xlog:os,deathtest2=debug", "--version");
49+
ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:async", "-Xlog:os,deathtest=debug", "-XX:+TestingAsyncLoggingDeathTestNoCrash" , "--version");
5050
OutputAnalyzer output2 = new OutputAnalyzer(pb2.start());
5151
output2.shouldHaveExitValue(0);
5252
output2.shouldContain("Induce a recursive log for testing");
53+
54+
// For -Xlog:all=debug but without any global set, the test should succeed and not contain the recursive message.
55+
ProcessBuilder pb3 =
56+
ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:async", "-Xlog:all=debug", "--version");
57+
OutputAnalyzer output3 = new OutputAnalyzer(pb3.start());
58+
output3.shouldHaveExitValue(0);
59+
output3.shouldNotContain("Induce a recursive log for testing");
5360
}
5461
}

0 commit comments

Comments
 (0)