Skip to content

[cling] The LookupHelper routines need the ROOT lock. #18522

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 2 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "cling/Interpreter/Transaction.h"
#include "cling/Interpreter/Interpreter.h"
#include "cling/Utils/AST.h"
#include "cling/Interpreter/InterpreterAccessRAII.h"

#include "llvm/Support/Path.h"
#include "llvm/Support/FileSystem.h"
Expand Down Expand Up @@ -569,6 +570,9 @@ void TClingLookupHelper::GetPartiallyDesugaredName(std::string &nameLong)
bool TClingLookupHelper::IsAlreadyPartiallyDesugaredName(const std::string &nondef,
const std::string &nameLong)
{
// We are going to use and possibly update the interpreter information.
cling::InterpreterAccessRAII LockAccess(*fInterpreter);

const cling::LookupHelper& lh = fInterpreter->getLookupHelper();
clang::QualType t = lh.findType(nondef.c_str(), ToLHDS(WantDiags()));
if (!t.isNull()) {
Expand All @@ -584,6 +588,9 @@ bool TClingLookupHelper::IsAlreadyPartiallyDesugaredName(const std::string &nond

bool TClingLookupHelper::IsDeclaredScope(const std::string &base, bool &isInlined)
{
// We are going to use and possibly update the interpreter information.
cling::InterpreterAccessRAII LockAccess(*fInterpreter);

const cling::LookupHelper& lh = fInterpreter->getLookupHelper();
const clang::Decl *scope = lh.findScope(base.c_str(), ToLHDS(WantDiags()), nullptr);

Expand Down Expand Up @@ -618,6 +625,9 @@ bool TClingLookupHelper::GetPartiallyDesugaredNameWithScopeHandling(const std::s

if (fAutoParse) fAutoParse(tname.c_str());

// We are going to use and possibly update the interpreter information.
cling::InterpreterAccessRAII LockAccess(*fInterpreter);

// Since we already check via other means (TClassTable which is populated by
// the dictonary loading, and the gROOT list of classes and enums, which are
// populated via TProtoClass/Enum), we should be able to disable the autoloading
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
// author: Vassil Vassilev <[email protected]>
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------

#ifndef CLING_INTERPRETERACCESSRAII_H
#define CLING_INTERPRETERACCESSRAII_H

#include "cling/Interpreter/Interpreter.h"
#include "cling/Interpreter/InterpreterCallbacks.h"

namespace cling {
///\brief Locks and unlocks access to the interpreter.
struct InterpreterAccessRAII {
/// Callbacks used to un/lock.
InterpreterCallbacks* fCallbacks;
/// Info provided to UnlockCompilationDuringUserCodeExecution().
void* fStateInfo = nullptr;

InterpreterAccessRAII(InterpreterCallbacks* callbacks):
fCallbacks(callbacks)
{
if (fCallbacks)
// The return value is alway a nullptr.
fStateInfo = fCallbacks->LockCompilationDuringUserCodeExecution();
}

InterpreterAccessRAII(Interpreter& interp):
InterpreterAccessRAII(interp.getCallbacks()) {}

~InterpreterAccessRAII()
{
if (fCallbacks)
fCallbacks->UnlockCompilationDuringUserCodeExecution(fStateInfo);
}
};
}

#endif // CLING_ENTERUSERCODERAII_H
Loading