Project

Profile

Help

Bug #4449

NPE in CaseVariants

Added by Vladimir Nesterovsky 5 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Multithreading
Sprint/Milestone:
-
Start date:
2020-02-02
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.9, trunk
Fix Committed on Branch:
9.9, trunk
Fixed in Maintenance Release:

Description

During the transformation I got an exception:

Caused by: java.lang.NullPointerException
  at net.sf.saxon.regex.CaseVariants.getCaseVariants(CaseVariants.java:98)
  at net.sf.saxon.regex.REMatcher.equalCaseBlind(REMatcher.java:715)
  at net.sf.saxon.regex.Operation$OpAtom.iterateMatches(Operation.java:631)
  at net.sf.saxon.regex.Operation$OpUnambiguousRepeat.iterateMatches(Operation.java:774)
  at net.sf.saxon.regex.REMatcher.checkPreconditions(REMatcher.java:482)
  at net.sf.saxon.regex.REMatcher.match(REMatcher.java:385)
  at net.sf.saxon.regex.ARegularExpression.containsMatch(ARegularExpression.java:89)
  at net.sf.saxon.functions.Matches.call(Matches.java:78)
  at net.sf.saxon.functions.Matches.call(Matches.java:24)

It has happened once only and is not reproducible.

From looking into CaseVariants.getCaseVariants()

    public static int[] getCaseVariants(int code) {
        if (monoVariants == null) {
            build();
        }
        int mono = monoVariants.get(code);
        if (mono != monoVariants.getDefaultValue()) {
            return new int[]{mono};
        } else {
            int[] result = polyVariants.get(code); <-------------- NPE is here
            if (result == null) {
                return IntArraySet.EMPTY_INT_ARRAY;
            } else {
                return result;
            }
        }
    }
...

    private static IntToIntMap monoVariants = null;
    private static IntHashMap<int[]> polyVariants = null;


    static void build() {

        monoVariants = new IntToIntHashMap(2500);
        polyVariants = new IntHashMap<>(100);
...

I can guess the only reason: race between threads.

History

#1 Updated by Michael Kay 5 months ago

  • Category set to Multithreading
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal
  • Applies to branch trunk added

Yes, I think you're right, this method should be synchronized. Thanks for reporting it.

#2 Updated by Michael Kay 5 months ago

I have checked other similar methods. Some are already synchronized, but the following need to be changed:

  • Categories.getCategory()
  • Initialization code in Normalizer.java constructor

#3 Updated by Michael Kay 5 months ago

  • Status changed from New to Resolved
  • Fix Committed on Branch 9.9, trunk added

#4 Updated by O'Neil Delpratt 4 months ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.9.1.7 added

Patch applied in the 9.9.1.7 maintenance release.

Please register to edit this issue

Also available in: Atom PDF