Skip to content
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

Missing barriers in cache initialization #7

Closed
goldmann opened this issue Sep 9, 2013 · 0 comments
Closed

Missing barriers in cache initialization #7

goldmann opened this issue Sep 9, 2013 · 0 comments

Comments

@goldmann
Copy link

goldmann commented Sep 9, 2013

The following code is generated from the example:

void cachebarFields(JNIEnv *env, jobject lpObject)
{
        if (barFc.cached) return;
        barFc.clazz = env->GetObjectClass(lpObject);
        barFc.a = env->GetFieldID(barFc.clazz, "a", "I");
        barFc.b = env->GetFieldID(barFc.clazz, "b", "J");
        barFc.c = env->GetFieldID(barFc.clazz, "c", "[B");
        barFc.c5 = env->GetFieldID(barFc.clazz, "c5", "B");
        barFc.prev = env->GetFieldID(barFc.clazz, "prev", "J");
        barFc.cached = 1;
}

There are no barriers, so readers may observe the write to the "cached" member before the other members.

(One of the barFc.cached checks is redundant, BTW.)

This issue was reported originally in the Red Hat Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=957181

chirino added a commit that referenced this issue Sep 9, 2013
…ched' field to 1 so that reader don't see this get re-ordered before all the fields are readable.
chirino added a commit to fusesource/rocksdbjni that referenced this issue Dec 2, 2013
@gnodet gnodet closed this as completed Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants