-
-
Notifications
You must be signed in to change notification settings - Fork 181
Description
I am opening different pages with HtmlUnit 2.55.0 and notices that 1 page loads CPU on 100%
This page has javascript protection.
Problem not in that HtmlUnit can't open protection.
Problem in infinite loop and stuck. javascript timeout helps, but until it will happen, it will load 100 % CPU.
All browsers open this page fine (old and new).
For me it's clear bug in HtmlUnit js processing.
I tried to investigate it and fix, but I can't handle it.
Below details that I found
Code
`
WebClient webClient = null;
try {
final long javascriptTimeout = TimeUnit.SECONDS.toMillis(60);
webClient = new WebClient();
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.getOptions().setDownloadImages(true);
webClient.getOptions().setCssEnabled(true);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.setJavaScriptTimeout(javascriptTimeout);
String loginURL = "http://www.pbc.gov.cn/diaochatongjisi/116219/116319/index.html";
System.out.println("Connecting to " + loginURL + " (" + webClient.getBrowserVersion() + ")");
HtmlPage page = webClient.getPage(loginURL);
// never get here (will get JS timeout after 60 seconds)
System.out.print(" Waiting for Javascript to complete...");
webClient.waitForBackgroundJavaScript(javascriptTimeout);
System.out.println(page.asXml());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (webClient != null)
webClient.close();
}
`
this page saved to file
1.txt
so when I debug
net.sourceforge.htmlunit.corejs.javascript.Interpreter
method: interpretLoop
it write some other codes (not like below) and after it, I see this infinite pattern all time (again and again), until timeout:
frame.pc: 67 op: -45
Icode_REG_STR1: _0x432180
frame.pc: 69 op: 49
frame.pc: 70 op: -45
Icode_REG_STR1: _0x230f38
frame.pc: 72 op: 39
frame.pc: 73 op: -45
Icode_REG_STR1: _0x18d5c9
frame.pc: 75 op: 39
frame.pc: 76 op: 36
frame.pc: 77 op: -45
Icode_REG_STR1: _0x432180
frame.pc: 79 op: 8
frame.pc: 80 op: -4
frame.pc: 81 op: -42
frame.pc: 82 op: 49
frame.pc: 83 op: -42
frame.pc: 84 op: 39
frame.pc: 85 op: -45
Icode_REG_STR1: ;
frame.pc: 87 op: 41
frame.pc: 88 op: -45
Icode_REG_STR1: _0x432180
frame.pc: 90 op: 39
frame.pc: 91 op: 21
frame.pc: 92 op: 21
frame.pc: 93 op: -42
frame.pc: 94 op: 8
frame.pc: 95 op: -4
frame.pc: 96 op: -45
Icode_REG_STR1: _0x2ab90b
frame.pc: 98 op: 49
frame.pc: 99 op: -45
Icode_REG_STR1: _0x230f38
frame.pc: 101 op: 39
frame.pc: 102 op: -45
Icode_REG_STR1: _0x432180
frame.pc: 104 op: 39
frame.pc: 105 op: 36
frame.pc: 106 op: -45
Icode_REG_STR1: _0x2ab90b
frame.pc: 108 op: 8
frame.pc: 109 op: -4
frame.pc: 110 op: -45
Icode_REG_STR1: _0x230f38
frame.pc: 112 op: 39
frame.pc: 113 op: -45
Icode_REG_STR1: push
frame.pc: 115 op: 41
frame.pc: 116 op: -17
frame.pc: 117 op: -45
Icode_REG_STR1: _0x2ab90b
frame.pc: 119 op: 39
frame.pc: 120 op: -33
frame.pc: 121 op: 38
frame.pc: 122 op: -4
frame.pc: 123 op: -45
Icode_REG_STR1: _0x333808
frame.pc: 125 op: 49
frame.pc: 126 op: -45
Icode_REG_STR1: _0x230f38
frame.pc: 128 op: 39
frame.pc: 129 op: -45
Icode_REG_STR1: length
frame.pc: 131 op: 41
frame.pc: 132 op: 36
frame.pc: 133 op: -45
Icode_REG_STR1: _0x333808
frame.pc: 135 op: 8
frame.pc: 136 op: -4
frame.pc: 137 op: -45
Icode_REG_STR1: _0x2ab90b
frame.pc: 139 op: 39
frame.pc: 140 op: -32
frame.pc: 141 op: -29
frame.pc: 142 op: 66
frame.pc: 143 op: 26
frame.pc: 144 op: 26
frame.pc: 145 op: 47
frame.pc: 146 op: 7
frame.pc: 149 op: -42
frame.pc: 150 op: 49
frame.pc: 151 op: -42
frame.pc: 152 op: 39
frame.pc: 153 op: -44
frame.pc: 154 op: 41
frame.pc: 155 op: -45
Icode_REG_STR1: _0x2ab90b
frame.pc: 157 op: 39
frame.pc: 158 op: 21
frame.pc: 159 op: 21
frame.pc: 160 op: -42
frame.pc: 161 op: 8
frame.pc: 162 op: -4
frame.pc: 163 op: -45
Icode_REG_STR1: _0x18d5c9
frame.pc: 165 op: -8
frame.pc: 167 op: -4
frame.pc: 168 op: -45
Icode_REG_STR1: _0x18d5c9
frame.pc: 170 op: 39
frame.pc: 171 op: -45
Icode_REG_STR1: _0x333808
frame.pc: 173 op: 39
frame.pc: 174 op: 14
frame.pc: 175 op: 6