File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,12 @@ ur_adapter_handle_t_ *GlobalAdapter = new ur_adapter_handle_t_();
27
27
#else
28
28
ur_adapter_handle_t_ *GlobalAdapter;
29
29
#endif
30
-
30
+ // This is a temporary workaround on windows, where UR adapter is teardowned
31
+ // before the UR loader, which will result in access violation when we use print
32
+ // function as the overrided print function was already released with the UR
33
+ // adapter.
34
+ // TODO: Change adapters to use a common sink class in the loader instead of
35
+ // using thier own sink class that inherit from logger::Sink.
31
36
class ur_legacy_sink : public logger ::Sink {
32
37
public:
33
38
ur_legacy_sink (std::string logger_name = " " , bool skip_prefix = true )
@@ -40,7 +45,11 @@ class ur_legacy_sink : public logger::Sink {
40
45
fprintf (stderr, " %s" , msg.c_str ());
41
46
}
42
47
43
- ~ur_legacy_sink () = default ;
48
+ ~ur_legacy_sink () {
49
+ #if defined(_WIN32)
50
+ logger::isTearDowned = true ;
51
+ #endif
52
+ };
44
53
};
45
54
46
55
ur_result_t initPlatforms (PlatformVec &platforms) noexcept try {
Original file line number Diff line number Diff line change 17
17
18
18
namespace logger {
19
19
20
+ #if defined(_WIN32)
21
+ inline bool isTearDowned = false ;
22
+ #endif
23
+
20
24
class Sink {
21
25
public:
22
26
template <typename ... Args>
@@ -28,7 +32,21 @@ class Sink {
28
32
}
29
33
30
34
format (buffer, fmt, std::forward<Args &&>(args)...);
35
+ // This is a temporary workaround on windows, where UR adapter is teardowned
36
+ // before the UR loader, which will result in access violation when we use print
37
+ // function as the overrided print function was already released with the UR
38
+ // adapter.
39
+ // TODO: Change adapters to use a common sink class in the loader instead of
40
+ // using thier own sink class that inherit from logger::Sink.
41
+ #if defined(_WIN32)
42
+ if (isTearDowned) {
43
+ std::cerr << buffer.str () << " \n " ;
44
+ } else {
45
+ print (level, buffer.str ());
46
+ }
47
+ #else
31
48
print (level, buffer.str ());
49
+ #endif
32
50
}
33
51
34
52
void setFlushLevel (logger::Level level) { this ->flush_level = level; }
You can’t perform that action at this time.
0 commit comments