Skip to content

Commit

Permalink
JBR-6522 macOS: SIGSEGV at [libawt_lwawt.dylib+0x8eaa8] MTLGC_Destroy…
Browse files Browse the repository at this point in the history
…MTLGraphicsConfig

Fix of MT access to shared data in MTLGraphicsConfigInfo
  • Loading branch information
avu committed Mar 1, 2024
1 parent cd21fc6 commit 2445ea8
Showing 1 changed file with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,24 @@
MTLGC_DestroyMTLGraphicsConfig(jlong pConfigInfo)
{
J2dTraceLn(J2D_TRACE_INFO, "MTLGC_DestroyMTLGraphicsConfig");
JNI_COCOA_ENTER(env);
[ThreadUtilities performOnMainThreadWaiting:NO block:^() {
MTLGraphicsConfigInfo *mtlinfo =
(MTLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
if (mtlinfo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR,
"MTLGC_DestroyMTLGraphicsConfig: info is null");
return;
}

MTLGraphicsConfigInfo *mtlinfo =
(MTLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
if (mtlinfo == NULL) {
J2dRlsTraceLn(J2D_TRACE_ERROR,
"MTLGC_DestroyMTLGraphicsConfig: info is null");
return;
}

MTLContext *mtlc = (MTLContext*)mtlinfo->context;
if (mtlc != NULL) {
[mtlinfo->context release];
mtlinfo->context = nil;
}
free(mtlinfo);
MTLContext *mtlc = (MTLContext*)mtlinfo->context;
if (mtlc != NULL) {
[mtlinfo->context release];
mtlinfo->context = nil;
}
free(mtlinfo);
}];
JNI_COCOA_EXIT(env);
}

JNIEXPORT jboolean JNICALL
Expand Down Expand Up @@ -114,7 +117,6 @@
Java_sun_java2d_metal_MTLGraphicsConfig_getMTLConfigInfo
(JNIEnv *env, jclass mtlgc, jint displayID, jstring mtlShadersLib)
{
__block MTLContext* mtlc = nil;
__block MTLGraphicsConfigInfo* mtlinfo = nil;

JNI_COCOA_ENTER(env);
Expand All @@ -123,7 +125,7 @@

[ThreadUtilities performOnMainThreadWaiting:YES block:^() {

mtlc = [[MTLContext alloc] initWithDevice:displayID
MTLContext* mtlc = [[MTLContext alloc] initWithDevice:displayID
shadersLib:path];
if (mtlc != 0L) {
// create the MTLGraphicsConfigInfo record for this context
Expand Down

0 comments on commit 2445ea8

Please sign in to comment.