Encounter 'java.lang.OutOfMemoryError' error when compiling with command 'make -f client.mk'

RESOLVED FIXED in mozilla28

Status

()

Core
Build Config
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: Cedric Wang, Assigned: ckitching)

Tracking

unspecified
mozilla28
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 3 obsolete attachments)

(Reporter)

Description

4 years ago
I encountered the following error when compiling gecko with command 'make -f client.mk'

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:2882)
	at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:572)
	at java.lang.StringBuilder.append(StringBuilder.java:203)
	at org.mozilla.gecko.annotationProcessors.utils.Utils.writeTypeSignature(Utils.java:248)
	at org.mozilla.gecko.annotationProcessors.utils.Utils.getTypeSignatureString(Utils.java:228)
	at org.mozilla.gecko.annotationProcessors.utils.AlphabeticMethodComparator.compare(AlphabeticMethodComparator.java:23)
	at org.mozilla.gecko.annotationProcessors.utils.AlphabeticMethodComparator.compare(AlphabeticMethodComparator.java:10)
	at java.util.Arrays.mergeSort(Arrays.java:1270)
	at java.util.Arrays.sort(Arrays.java:1210)
	at org.mozilla.gecko.annotationProcessors.utils.GeneratableEntryPointIterator.<init>(GeneratableEntryPointIterator.java:30)
	at org.mozilla.gecko.annotationProcessors.AnnotationProcessor.main(AnnotationProcessor.java:44)

This compile error is caused by the following code segment in 'gecko/build/annotationProcessors/utils/Utils.java'

int len = name.length();
        while (name.endsWith("[]")) {
            sb.append('[');
            name = name.substring(0, len - 2);
        }

The variable 'len' is not assigned the new length(len -2) at the end of the 'while', so when the variable 'name' is a string likes 'boolean[][]',there will be a endless loop.
(Assignee)

Comment 1

4 years ago
Created attachment 826645 [details] [diff] [review]
Don't explode when faced with multi-dimensional arrays.

Whoops!

You appear to be exactly right. He's an patch doing exactly what you said.
Flagging the original reviewer of this code for a rubber-stamp.
Assignee: cewang → chriskitching
Status: NEW → ASSIGNED
Attachment #826645 - Flags: review?(bugmail.mozilla)
(Reporter)

Comment 2

4 years ago
Created attachment 826646 [details] [diff] [review]
Solve endless loop problem in gecko/build/annotationProcessors/utils/Utils.java

Hi, Chris Kitching,could you help me review this patch?
Attachment #826646 - Flags: review?(chriskitching)
(Reporter)

Updated

4 years ago
Attachment #826646 - Attachment is obsolete: true
Attachment #826646 - Flags: review?(chriskitching)
(Assignee)

Updated

4 years ago
Attachment #826645 - Attachment is obsolete: true
Attachment #826645 - Flags: review?(bugmail.mozilla)
(Assignee)

Comment 3

4 years ago
Comment on attachment 826646 [details] [diff] [review]
Solve endless loop problem in gecko/build/annotationProcessors/utils/Utils.java

Sorry. Beat you to it by a tiny bit there!

Still, your patch looks fine - probably not necessary to include "[PATCH]" at the beginning of the commit message.

It also occurs to me that my patch is actually sort of dumb - an extra function call? that's not sensible. Your approach will perform a little better, as well as being shorter. Let's do it your way.

Just tweak that commit message thing (I think there's sort of strict rules about everything starting with just "Bug XXXXX") and it looks fine to me!
Attachment #826646 - Flags: feedback+
(Assignee)

Updated

4 years ago
Attachment #826646 - Attachment is obsolete: false
(Assignee)

Comment 4

4 years ago
You could also perhaps formulate it as len -= 2?
(Assignee)

Comment 5

4 years ago
Created attachment 833355 [details] [diff] [review]
Solve endless loop problem in gecko/build/annotationProcessors/utils/Utils.java

This seems to have stagnated for a while...

Rubberstamp, please!
Attachment #826646 - Attachment is obsolete: true
Attachment #833355 - Flags: review?(bugmail.mozilla)
Comment on attachment 833355 [details] [diff] [review]
Solve endless loop problem in gecko/build/annotationProcessors/utils/Utils.java

Review of attachment 833355 [details] [diff] [review]:
-----------------------------------------------------------------

Either use cedric's version or move the int to be local inside the loop (or just inline it). I don't like exiting the loop with len !〓 length() even though len isn't used after that. rs〓me with any of those.
Attachment #833355 - Flags: review?(bugmail.mozilla) → review+
(Assignee)

Comment 7

4 years ago
Created attachment 833373 [details] [diff] [review]
Solve endless loop problem in gecko/build/annotationProcessors/utils/Utils.java

(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #6)
> Either use cedric's version or move the int to be local inside the loop (or
> just inline it). I don't like exiting the loop with len != length() even
> though len isn't used after that. rs=me with any of those.

Amazing, I uploaded the wrong patch.

Yes, Cedric's approach is clearly far more sane than what I just uploaded. Subtraction! It's subtraction! How did I get subtraction wrong!? :P

Actual rubber-stamp this time, then we can add this to the ever-increasing queue of things to land once the tree opens.
Attachment #833355 - Attachment is obsolete: true
Attachment #833373 - Flags: review?(bugmail.mozilla)
Comment on attachment 826646 [details] [diff] [review]
Solve endless loop problem in gecko/build/annotationProcessors/utils/Utils.java

This one has the right author.
Attachment #826646 - Attachment is obsolete: false
Attachment #826646 - Flags: review+
Attachment #833373 - Attachment is obsolete: true
Attachment #833373 - Flags: review?(bugmail.mozilla)
(Reporter)

Updated

4 years ago
Keywords: checkin-needed
https://hg.mozilla.org/integration/fx-team/rev/94d56e88f893
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/94d56e88f893
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
You need to log in before you can comment on or make changes to this bug.