Skip to content

Commit

Permalink
adding minimal Deadlock repro case
Browse files Browse the repository at this point in the history
  • Loading branch information
nabacg committed Dec 2, 2024
1 parent d69afa8 commit 466c6e8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.mozilla.javascript.tests.es6;

import org.junit.Test;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.NativeObject;
import org.mozilla.javascript.ScriptableObject;

import static org.junit.Assert.assertEquals;

public class DeadlockReproTest {
@Test
public void redefinePropertyWithThreadSafeSlotMap() {
final ContextFactory factory =
new ContextFactory() {
@Override
protected boolean hasFeature(Context cx, int featureIndex) {
if (featureIndex == Context.FEATURE_THREAD_SAFE_OBJECTS) {
return true;
}
return super.hasFeature(cx, featureIndex);
}
};

try (Context cx = factory.enterContext()) {
cx.setLanguageVersion(Context.VERSION_ES6);
ScriptableObject scope = cx.initStandardObjects();

scope.put("o", scope, new NativeObject());
final String script = "Object.defineProperty(o, 'test', {value: '1', configurable: !0});" +
"Object.defineProperty(o, 'test', {value: 2});" +
"o.test";



var result =
cx.evaluateString(scope, script, "myScript", 1, null);

assertEquals(2, result);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,10 @@ public void redefinePropertyWithThreadSafeSlotMap() {
new ContextFactory() {
@Override
protected boolean hasFeature(Context cx, int featureIndex) {
switch (featureIndex) {
case Context.FEATURE_THREAD_SAFE_OBJECTS:
return true;
default:
return super.hasFeature(cx, featureIndex);
if (featureIndex == Context.FEATURE_THREAD_SAFE_OBJECTS) {
return true;
}
return super.hasFeature(cx, featureIndex);
}
};

Expand Down

0 comments on commit 466c6e8

Please sign in to comment.