Skip to content

Commit e8efbc5

Browse files
kychendevigcbot
authored andcommitted
Fix thread safety for inline asm support.
Fix inline assembly test error with multiple threads due to data race.
1 parent 333f527 commit e8efbc5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

visa/BuildCISAIRImpl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SPDX-License-Identifier: MIT
3333
#include <string>
3434
#include <sstream>
3535
#include <functional>
36+
#include <mutex>
3637

3738
using namespace vISA;
3839
extern "C" int64_t getTimerTicks(unsigned int idx);
@@ -919,9 +920,11 @@ typedef struct yy_buffer_state * YY_BUFFER_STATE;
919920
extern int CISAparse(CISA_IR_Builder *builder);
920921
extern YY_BUFFER_STATE CISA_scan_string(const char* yy_str);
921922
extern void CISA_delete_buffer(YY_BUFFER_STATE buf);
923+
static std::mutex mtx;
922924

923925
int CISA_IR_Builder::ParseVISAText(const std::string& visaText, const std::string& visaTextFile)
924926
{
927+
const std::lock_guard<std::mutex> lock(mtx);
925928
#if defined(__linux__) || defined(_WIN64) || defined(_WIN32)
926929
// Direct output of parser to null
927930
#if defined(_WIN64) || defined(_WIN32)

0 commit comments

Comments
 (0)