提交 606da936 编写于 作者: D dbuck

8234691: Potential double-free in ParallelSPCleanupTask constructor

Summary: Prevent extraneous constructor call
Reviewed-by: dholmes, stefank
上级 c80e8a7e
/*
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -324,6 +324,8 @@ class SubTasksDone: public CHeapObj<mtInternal> {
// Set all tasks to unclaimed.
void clear();
NONCOPYABLE(SubTasksDone);
public:
// Initializes "this" to a state in which there are "n" tasks to be
// processed, none of the which are originally claimed. The number of
......
......@@ -640,7 +640,7 @@ public:
AbstractGangTask("Parallel Safepoint Cleanup"),
_cleanup_threads_cl(ParallelSPCleanupThreadClosure(counters)),
_num_workers(num_workers),
_subtasks(SubTasksDone(SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS)),
_subtasks(SafepointSynchronize::SAFEPOINT_CLEANUP_NUM_TASKS),
_counters(counters) {}
void work(uint worker_id) {
......
......@@ -46,6 +46,19 @@
// This file holds all globally used constants & types, class (forward)
// declarations and a few frequently used utility functions.
// Declare the named class to be noncopyable. This macro must be used in
// a private part of the class's definition, followed by a semi-colon.
// Doing so provides private declarations for the class's copy constructor
// and assignment operator. Because these operations are private, most
// potential callers will fail to compile because they are inaccessible.
// The operations intentionally lack a definition, to provoke link-time
// failures for calls from contexts where they are accessible, e.g. from
// within the class or from a friend of the class.
// Note: The lack of definitions is still not completely bullet-proof, as
// an apparent call might be optimized away by copy elision.
// For C++11 the declarations should be changed to deleted definitions.
#define NONCOPYABLE(C) C(C const&); C& operator=(C const&) /* next token must be ; */
//----------------------------------------------------------------------------------------------------
// Printf-style formatters for fixed- and variable-width types as pointers and
// integers. These are derived from the definitions in inttypes.h. If the platform
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册