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

Draft compile with compiler.stackMode=strip seems to break stack trace deobfuscation with sourcemaps #9956

Open
niloc132 opened this issue May 12, 2024 · 1 comment

Comments

@niloc132
Copy link
Contributor

LoggingRPCSuite was apparently written to support running in Chrome with stack mode strip, but still using the "modern" collector (renamed about three years after this commit):

<!-- Turn off emulation to test non-sourcemap mode -->
<set-property name="compiler.stackMode" value="native"/>
<!-- when Chrome is enabled, turn off stack trace emulation -->
<set-property name="compiler.stackMode" value="strip">
<when-property-is name="user.agent" value="safari"/>
</set-property>
<!-- when stack trace stripping is enabled, we need to replace the Null collector
with one that does something for Chrome -->
<replace-with class="com.google.gwt.core.client.impl.StackTraceCreator.CollectorChrome">
<when-type-is class="com.google.gwt.core.client.impl.StackTraceCreator.Collector" />
<!-- For now, only Chrome provides Error.stack support, so we hijack the
entire WebKit permutation -->
<when-property-is name="user.agent" value="safari" />
<when-property-is name="compiler.useSourceMaps" value="true" />
</replace-with>

However, this wasn't run since at least ChromeCollector was renamed to ModernCollector (and possibly earlier, haven't confirmed), and running it in recent versions seems to break. When compiled without draft, HtmlUnit is able to send stack traces to the server and have them deobfuscated, so this is likely not a limitation of HtmlUnit vs some other browser.

@niloc132
Copy link
Contributor Author

Chrome does behave differently than htmlunit here, but still fails the test with draft+stackMode=strip.

Chrome's failure:

expected: <40>, actual: <26>
junit.framework.AssertionFailedError: expected: <40>, actual: <26>
	at java.lang.Throwable.Throwable(com/google/gwt/emul/java/lang/Throwable.java:73)
	at java.lang.Error.Error(com/google/gwt/emul/java/lang/Error.java:30)
	at java.lang.AssertionError.AssertionError(com/google/gwt/emul/java/lang/AssertionError.java:51)
	at com/google/gwt/junit/translatable/junit/framework/AssertionFailedError.java.(com/google/gwt/junit/translatable/junit/framework/AssertionFailedError.java:27)
	at com.google.gwt.jsonp.client.TimeoutException_FieldSerializer.instantiate(TimeoutException_FieldSerializer.java:6)
	at java.lang.Object.$getClass(Object.java:6)
	at com.google.gwt.core.client.impl.Impl.apply(com/google/gwt/user/client/rpc/impl/RequestCallbackAdapter.java:232)
	at com.google.gwt.core.client.impl.AsyncFragmentLoader$HttpDownloadFailure.AsyncFragmentLoader$HttpDownloadFailure(com/google/gwt/http/client/Request.java:227)
	at com/google/gwt/http/client/RequestBuilder.java.(com/google/gwt/http/client/RequestBuilder.java:412)
	at com/google/gwt/xhr/client/XMLHttpRequest.java.(com/google/gwt/xhr/client/XMLHttpRequest.java:329)
	at com.google.gwt.core.client.impl.Impl.apply(com/google/gwt/core/client/impl/Impl.java:299)
	at com.google.gwt.core.client.impl.Impl.entry0(com/google/gwt/core/client/impl/Impl.java:351)
	at com/google/gwt/core/client/impl/Impl.java.(com/google/gwt/core/client/impl/Impl.java:78)

Chrome's actual exception after deobf:

java.lang.RuntimeException: Runtime Exception
	at java.lang.Throwable.Throwable(com/google/gwt/emul/java/lang/Throwable.java:66)
	at java.lang.Exception.Exception(com/google/gwt/emul/java/lang/Exception.java:29)
	at com/google/gwt/emul/java/lang/RuntimeException.java.(com/google/gwt/emul/java/lang/RuntimeException.java:29)
	at com.google.gwt.jsonp.client.TimeoutException_FieldSerializer.$clinit(com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/ModuleUtils.java:39)
	at com.google.gwt.core.client.CodeDownloadException$Reason.valueOf(com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/ModuleUtils.java:35)
	at com.google.gwt.core.client.impl.JavaScriptExceptionBase.$clinit(com/google/gwt/core/client/impl/AsyncFragmentLoader.java:582)
	at com.google.gwt.core.client.impl.AsyncFragmentLoader.onLoad(com/google/gwt/core/client/impl/AsyncFragmentLoader.java:276)
	at com.google.gwt.core.client.impl.Impl.apply(com/google/gwt/core/client/impl/Impl.java:299)
	at com.google.gwt.core.client.impl.Impl.entry0(com/google/gwt/core/client/impl/Impl.java:351)
	at com/google/gwt/core/client/impl/Impl.java.(com/google/gwt/core/client/impl/Impl.java:78)
	at gen/com/google/gwt/user/client/rpc/LoggingRPCTestService_Proxy.java.(gen/com/google/gwt/user/client/rpc/LoggingRPCTestService_Proxy.java:26)
	at Unknown.__installRunAsyncCode(http://localhost:10000/com.google.gwt.user.LoggingRPCSuite.JUnit/com.google.gwt.user.LoggingRPCSuite.JUnit.nocache.js@241:11)
	at Unknown.__gwtInstallCode(com.google.gwt.user.LoggingRPCSuite.JUnit-0.js@584:1)
	at com.google.gwt.core.client.impl.LoadingStrategyBase.gwtInstallCode(com/google/gwt/core/client/impl/LoadingStrategyBase.java:173)
	at com.google.gwt.core.client.JsArrayString.$length(com/google/gwt/core/client/impl/LoadingStrategyBase.java:150)
	at com.google.gwt.core.client.impl.ScriptTagLoadingStrategy.asyncCallback(com/google/gwt/core/client/impl/ScriptTagLoadingStrategy.java:60)
	at com/google/gwt/core/client/impl/ScriptTagLoadingStrategy.java.(com/google/gwt/core/client/impl/ScriptTagLoadingStrategy.java:85)
	at com.google.gwt.core.client.impl.Impl.apply(com/google/gwt/core/client/impl/Impl.java:299)
	at com.google.gwt.core.client.impl.Impl.entry0(com/google/gwt/core/client/impl/Impl.java:351)
	at com/google/gwt/core/client/impl/Impl.java.(com/google/gwt/core/client/impl/Impl.java:78)
	at com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/CollapsedPropertyHolder.java.(com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/CollapsedPropertyHolder.java:32)

Chrome's exception after deobf when not using draft:

java.lang.RuntimeException: Runtime Exception
	at java.lang.Throwable.Throwable(com/google/gwt/emul/java/lang/Throwable.java:66)
	at java.lang.Exception.Exception(com/google/gwt/emul/java/lang/Exception.java:29)
	at com/google/gwt/emul/java/lang/RuntimeException.java.(com/google/gwt/emul/java/lang/RuntimeException.java:29)
	at com.google.gwt.user.client.rpc.LoggingRPCTest.$throwException(com/google/gwt/user/client/rpc/LoggingRPCTest.java:40)
	at java.lang.Throwable.Throwable(com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/ModuleUtils.java:62)
	at com.google.gwt.core.client.impl.AsyncFragmentLoader.$onLoadImpl(com/google/gwt/core/client/impl/AsyncFragmentLoader.java:582)
	at com.google.gwt.core.client.impl.AsyncFragmentLoader.onLoad(com/google/gwt/core/client/impl/AsyncFragmentLoader.java:276)
	at com.google.gwt.core.client.impl.Impl.apply(com/google/gwt/core/client/impl/Impl.java:299)
	at com.google.gwt.core.client.impl.Impl.entry0(com/google/gwt/core/client/impl/Impl.java:351)
	at com/google/gwt/core/client/impl/Impl.java.(com/google/gwt/core/client/impl/Impl.java:78)
	at Unknown.anonymous(com.google.gwt.user.LoggingRPCSuite.JUnit-1.js@7:8)
	at Unknown.__installRunAsyncCode(http://localhost:10000/com.google.gwt.user.LoggingRPCSuite.JUnit/com.google.gwt.user.LoggingRPCSuite.JUnit.nocache.js@241:11)
	at com/google/web/bindery/event/shared/UmbrellaException.java.(com/google/web/bindery/event/shared/UmbrellaException.java:27)
	at com.google.gwt.core.client.impl.LoadingStrategyBase$RequestData.$tryInstall(com/google/gwt/core/client/impl/LoadingStrategyBase.java:173)
	at com.google.gwt.core.client.impl.ScriptTagLoadingStrategy.asyncCallback(com/google/gwt/core/client/impl/ScriptTagLoadingStrategy.java:59)
	at com/google/gwt/core/client/impl/ScriptTagLoadingStrategy.java.(com/google/gwt/core/client/impl/ScriptTagLoadingStrategy.java:85)
	at com.google.gwt.core.client.impl.Impl.apply(com/google/gwt/core/client/impl/Impl.java:299)
	at com.google.gwt.core.client.impl.Impl.entry0(com/google/gwt/core/client/impl/Impl.java:351)
	at com/google/gwt/core/client/impl/Impl.java.(com/google/gwt/core/client/impl/Impl.java:78)
	at Unknown.anonymous(http://localhost:10000/com.google.gwt.user.LoggingRPCSuite.JUnit/deferredjs/474E62227CCEEC7D5C90D27E197E3557/1.cache.js@48:1)

The expected line is

	at com.google.gwt.user.client.rpc.LoggingRPCTest.$throwException(com/google/gwt/user/client/rpc/LoggingRPCTest.java:40)

but going by counting stack frames, we instead get

	at com.google.gwt.jsonp.client.TimeoutException_FieldSerializer.$clinit(com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/ModuleUtils.java:39)

which looks like nonsense (or confusion from merging too many functions due to strip mode).

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

1 participant