swebb2066 commented on code in PR #808:
URL: https://github.com/apache/logging-log4cxx/pull/808#discussion_r4463207043


##########
src/fuzzers/cpp/AsyncAppenderFuzzer.cpp:
##########
@@ -0,0 +1,135 @@
+/*
+ * 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.
+ */
+
+//
+// Fuzzer for AsyncAppender: the ring-buffer queue, the dispatcher thread and
+// the close/shutdown path (AsyncAppenderPriv::dispatch, AsyncBuffer,
+// CyclicBuffer, ThreadUtility).
+//
+// The producer side is driven with fuzzed BufferSize/Blocking settings, a
+// bounded event count and an optional early close(), i.e. the
+// dispatcher races a close while events are still pending - the classic
+// use-after-free/double-release shape for async logging queues.  The sink is
+// a counting appender with a PatternLayout so the dispatcher thread formats
+// events (message buffer, MDC/NDC and, for half of the inputs, location
+// information conversion) without doing I/O.
+//
+// Everything is rebuilt per iteration and the repository is reset at the
+// end, so appender, thread and queue lifetimes stay per-iteration bounded.
+//
+// Expected defect classes: use-after-free / double-free between close() and
+// the dispatcher, unbounded queue growth (OOM), lost-wake-up hangs, and
+// leaks when close is skipped while events are pending.
+//
+
+#include <fuzzer/FuzzedDataProvider.h>
+#include <log4cxx/asyncappender.h>
+#include <log4cxx/appenderskeleton.h>
+#include <log4cxx/logger.h>
+#include <log4cxx/logmanager.h>
+#include <log4cxx/mdc.h>
+#include <log4cxx/ndc.h>
+#include <log4cxx/patternlayout.h>
+
+using namespace log4cxx;
+
+namespace LOG4CXX_NS::fuzzer {
+
+/**
+ * I/O-free sink appender; formats each event in the dispatcher thread.
+ */
+class FormattingSinkAppender : public AppenderSkeleton {
+
+public:
+
+       DECLARE_LOG4CXX_OBJECT(FormattingSinkAppender)
+       BEGIN_LOG4CXX_CAST_MAP()
+       LOG4CXX_CAST_ENTRY(FormattingSinkAppender)
+       LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+       END_LOG4CXX_CAST_MAP()
+
+       FormattingSinkAppender() : AppenderSkeleton() {}
+
+       FormattingSinkAppender(const LayoutPtr& layout) : 
AppenderSkeleton(layout) {}
+
+       void close() override {}

Review Comment:
   Please merge master and remove the (now not required) `close()` 
implementation



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to