TI: Infinite loop and memory explosion with array2 test

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: azakai, Assigned: jandem)

Tracking

(Blocks: 1 bug)

Other Branch
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

6 years ago
Created attachment 531111 [details]
array2 test

The attached script is array2 from emscripten's test suite. With |-m -n| on JM, it enters an apparently infinite loop, and memory usage explodes out of control (be careful when running the script). Works ok with just -m.
(Assignee)

Comment 1

6 years ago
Can you still reproduce this? Works for me with 32-bit and 64-bit OS X shell, both |-m -n| and |-m -a -n|.
(Reporter)

Comment 2

6 years ago
I still see this on Linux 32. Might be a platform specific thing then.

I get the same on most other emscripten tests as well (this is among the first in the list, so I saw it first).
OS: All → Linux
Hardware: All → x86
(Assignee)

Comment 3

6 years ago
Ah this is interesting, debug build works on Linux 32-bit, but I can reproduce with a release build. Linux 32-bit tinderbox has the same problem, orange caused by time-outs. I'll reduce this now.
(Assignee)

Comment 4

6 years ago
Created attachment 531766 [details] [diff] [review]
Patch

There are different versions of JS_FLOOR_LOG2 macro, apparently the optimized version returned an invalid value if the result is signed. The register was not in freeMask, causing an infinite loop in FrameState::merge (it was busy generating code, causing the memory explosion).
Assignee: general → jandemooij
Status: NEW → ASSIGNED
Attachment #531766 - Flags: review?(bhackett1024)
Comment on attachment 531766 [details] [diff] [review]
Patch

Weird, any other hits on this?  possible to put a comment on the macro?
Attachment #531766 - Flags: review?(bhackett1024) → review+
(Assignee)

Comment 6

6 years ago
I think the fix is correct, but it looks like JS_FLOOR_LOG2 is a red herring. The problem seems to be somewhere outside peekReg. Probably a bug in GCC 4.5 with -O3, I'll look closer tomorrow.
(Assignee)

Comment 7

6 years ago
Created attachment 531880 [details] [diff] [review]
Patch

The (RegisterID)ireg cast was confusing GCC when ireg is a FP register. So maybe it's not a GCC bug but undefined behavior. We don't even need the int -> unsigned change but I left it in, it seems to be the right type.

There's another (RegisterID) cast in FrameState.cpp, but it's valid because RegisterID ranges from 0 to TotalRegisters.
Attachment #531766 - Attachment is obsolete: true
Attachment #531880 - Flags: review?(bhackett1024)
Attachment #531880 - Flags: review?(bhackett1024) → review+
(Assignee)

Comment 8

6 years ago
http://hg.mozilla.org/projects/jaegermonkey/rev/3f089c0d63f8
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.