I have a springBoot 2.1.9.RELEASE application that uses Spring Data for Couchbase
But when I use the Atomic counters in Couchbase to Increment a counter with 1
bucket.counter(doc.getId(), 1);
I got an exception
com.couchbase.client.core.CouchbaseException: INVALID_ARGUMENTS
...Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.core.message.kv.CounterResponse.class
at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:118)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:73)
... 22 common frames omitted
I also have tried
try {
bucket.counter(docId, 1);
} catch (CouchbaseException e) {
if ("INVALID_ARGUMENTS".equalsIgnoreCase(e.getMessage())) {
LegacyDocument legacyDocument = rqmBucket.get(LegacyDocument.create(docId));
String s = legacyDocument.content().toString();
Long value = Long.parseLong(s) + 1;
bucket.upsert(JsonLongDocument.create(docId, value));
}
}
but I got at a java.lang.NumberFormatException because legacyDocument.content() gives me all the Json doc. :
"{"hostel":{"address":15..."
Related
version:rocketmq-all-4.1.0-incubating
We send msg 1000 QPS,sync send, but throw exception:-
[TIMEOUT_CLEAN_QUEUE] broker busy, start flow control for a while
There is the related code:
while (true) {
try {
if (!this.brokerController.getSendThreadPoolQueue().isEmpty()) {
final Runnable runnable = this.brokerController.getSendThreadPoolQueue().peek();
if (null == runnable) {
break;
}
final RequestTask rt = castRunnable(runnable);
if (rt == null || rt.isStopRun()) {
break;
}
final long behind = System.currentTimeMillis() - rt.getCreateTimestamp();
if (behind >= this.brokerController.getBrokerConfig().getWaitTimeMillsInSendQueue()) {
if (this.brokerController.getSendThreadPoolQueue().remove(runnable)) {
rt.setStopRun(true);
rt.returnResponse(RemotingSysResponseCode.SYSTEM_BUSY, String.format("[TIMEOUT_CLEAN_QUEUE]broker busy, start flow control for a while, period in queue: %sms, size of queue: %d", behind, this.brokerController.getSendThreadPoolQueue().size()));
}
} else {
break;
}
} else {
break;
}
} catch (Throwable ignored) {
}
}
}
I find broker the default value of sendMessageThreadPoolNums is 1,
/**
* thread numbers for send message thread pool, since spin lock will be used by default since 4.0.x, the default value is 1.
*/
private int sendMessageThreadPoolNums = 1; //16 + Runtime.getRuntime().availableProcessors() * 4;
private int pullMessageThreadPoolNums = 16 + Runtime.getRuntime().availableProcessors() * 2;
but the previous version isn't 1, and if I configure sendMessageThreadPoolNums = 100, can resolve this question ? It will lead to what is different with default value.
thanks
SHORT ANSWER:
you have two choices:
set sendMessageThreadPoolNums to a small number, say 1, which is the default value after version 4.1.x. And, remain the default value of useReentrantLockWhenPutMessage=false, which is introduced after 4.1.x
sendMessageThreadPoolNums=1
useReentrantLockWhenPutMessage=false
If you need to use a large numbers of threads to process sending message, you'd better use useReentrantLockWhenPutMessage=true
sendMessageThreadPoolNums=128//large thread numbers
useReentrantLockWhenPutMessage=true // indicating that do NOT use spin lock but use ReentrantLock when putting message
I'm trying to use Databroker of MD-SAL to save a list of data, after modifying the yang file and InstanceIdentifier many times but always facing similar validation issue, for example
java.util.concurrent.ExecutionException: TransactionCommitFailedException{message=canCommit encountered an unexpected failure, errorList=[RpcError [message=canCommit encountered an unexpected failure, severity=ERROR, errorType=APPLICATION, tag=operation-failed, applicationTag=null, info=null, cause=org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException: Child /(urn:opendaylight:params:xml:ns:yang:testDataBroker?revision=2015-01-05)service-datas is not present in schema tree.]]}
at org.opendaylight.yangtools.util.concurrent.MappingCheckedFuture.wrapInExecutionExc
My goal is to use rpc save-device-info to get data from rest. Then use databroker api to save data in the memory and finally test if the data could be succesfully replicated into other cluster nodes.
Yang file:
module testDataBroker {
yang-version 1;
namespace "urn:opendaylight:params:xml:ns:yang:testDataBroker";
prefix "testDataBroker";
revision "2015-01-05" {
description "Initial revision of testDataBroker model";
}
container service-datas {
list service-data {
key "service-id";
uses service-id;
uses device-info;
}
}
grouping device-info {
container device-info {
leaf device-name {
type string;
config false;
}
leaf device-description {
type string;
config false;
}
}
}
grouping service-id {
leaf service-id {
type string;
mandatory true;
}
}
rpc save-device-info {
input {
uses service-id;
uses device-info;
}
output {
uses device-info;
}
}
rpc get-device-info {
output {
uses device-info;
}
}
}
Java Code
#Override public Future<RpcResult<SaveDeviceInfoOutput>> saveDeviceInfo(SaveDeviceInfoInput input) {
String name = input.getDeviceInfo().getDeviceName();
String description = input.getDeviceInfo().getDeviceDescription();
String serviceId = input.getServiceId();
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
DeviceInfo deviceInfo = new DeviceInfoBuilder().setDeviceDescription(description).setDeviceName(name).build();
ServiceData serviceData = new ServiceDataBuilder().setServiceId(serviceId).setDeviceInfo(deviceInfo).build();
InstanceIdentifier<ServiceData> instanceIdentifier =
InstanceIdentifier.builder(ServiceDatas.class).child(ServiceData.class, serviceData.getKey()).build();
writeTransaction.put(LogicalDatastoreType.CONFIGURATION, instanceIdentifier, serviceData, true);
boolean isFailed = false;
try {
writeTransaction.submit().get();
log.info("Create containers succeeded!");
} catch (InterruptedException | ExecutionException e) {
log.error("Create containers failed: ", e);
isFailed = true;
}
return isFailed ?
RpcResultBuilder.success(new SaveDeviceInfoOutputBuilder())
.withError(RpcError.ErrorType.RPC, "Create container failed").buildFuture() :
RpcResultBuilder.success(new SaveDeviceInfoOutputBuilder().setDeviceInfo(input.getDeviceInfo()))
.buildFuture();
}
Really need your help. Thanks.
Update:
With the same version of md-sal bundles, I installed feature odl-toaster on only one ODL instead of cluster nodes. It seems like rpc from odl-toaster is working properly on single node.
I didn't realize that rpc is also clustered. Sometimes the rpc request hit on other nodes which didn't deploy the same bundles. Now the problem has been solved after the bundle is distrubted on each node.
When I run my code I get:
Breaking on exception: String expected
What I am trying to do is connect to my server using a websocket. However, it seems that no matter if my server is online or not the client still crashes.
My code:
import 'dart:html';
WebSocket serverConn;
int connectionAttempts;
TextAreaElement inputField = querySelector("#inputField");
String key;
void submitMessage(Event e) {
if (serverConn.readyState == WebSocket.OPEN) {
querySelector("#chatLog").text = inputField.value;
inputField.value = "";
}
}
void recreateConnection(Event e) {
connectionAttempts++;
if (connectionAttempts <= 5) {
inputField.value = "Connection failed, reconnecting. Attempt" + connectionAttempts.toString() + "out of 5";
serverConn = new WebSocket("ws://127.0.0.1:8887");
serverConn.onClose.listen(recreateConnection);
serverConn.onError.listen(recreateConnection);
} else {
inputField.value = "Connections ran out, please refresh site";
}
}
void connected(Event e) {
serverConn.sendString(key);
if (serverConn.readyState == WebSocket.OPEN) {
inputField.value = "CONNECTED!";
inputField.readOnly = false;
}
}
void main() {
serverConn = new WebSocket("ws://127.0.0.1:8887");
serverConn.onClose.listen(recreateConnection);
serverConn.onError.listen(recreateConnection);
serverConn.onOpen.listen(connected);
//querySelector("#inputField").onInput.listen(submitMessage);
querySelector("#sendInput").onClick.listen(submitMessage);
}
My Dart Editor says nothing about where the problem comes from nor does it give any warning until run-time.
You need to initialize int connectionAttempts; with a valid value;
connectionAttempts++; fails with an exception on null.
You also need an onMessage handler to receive messages.
serverConn.onMessage.listen((MessageEvent e) {
recreateConnection should register an onOpen handler as well.
After serverConn = new WebSocket the listener registered in main() will not work
If you register a listener where only one single event is expected you can use first instead of listen
serverConn.onOpen.first.then(connected);
According to #JAre s comment.
Try to use a hardcoded string
querySelector("#chatLog").text = 'someValue';
to ensure this is not the culprit.
Raised as bug with Railo https://issues.jboss.org/browse/RAILO-2698 - this question should be closed
I am currently attempting to ObjectSave() on a rather complex Struct which contains instances of some CFCs among other data using the following cfscript (this is a test script I put together to reproduce the issue)
<cfscript>
thisState = session.objBasket.getState();
writedump(thisState); // dumps the object successfully
ObjectSave(thisState); // causes java.io.UTFDataFormatException
</cfscript>
I am getting the following error java.io.UTFDataFormatException (stack trace follows). Does anyone know of a way to fix this, or is it a matter of simply trying to use the wrong tool for the job?
Railo versions the error occurs on
Railo 4.1.1.009 final (Java 1.7.0_45)
Railo 4.1.1.009 final (Java 1.7.0_17)
Railo 4.1.2.001 final (Java 1.7.0_45) (Preview release)
Railo versions the error does not occur on
Railo 4.0.4.001 final (Java 1.7.0_45)
Stack trace of the error
java.io.UTFDataFormatException at
java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:2163):2163
at
java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:2006):2006
at
java.io.ObjectOutputStream.writeUTF(ObjectOutputStream.java:868):868
at
railo.runtime.ComponentImpl.writeExternal(ComponentImpl.java:1975):1975
at
java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1458):1458
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429):1429
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177):1177
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347):347
at java.util.HashMap.writeObject(HashMap.java:1133):1133 at
sun.reflect.GeneratedMethodAccessor62.invoke(Unknown Source):-1 at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43):43
at java.lang.reflect.Method.invoke(Method.java:606):606 at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988):988
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495):1495
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431):1431
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177):1177
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347):347
at
railo.commons.collection.AbstractMapPro.writeExternal(AbstractMapPro.java:49):49
at
java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1458):1458
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429):1429
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177):1177
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547):1547
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508):1508
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431):1431
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177):1177
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347):347
at java.util.HashMap.writeObject(HashMap.java:1133):1133 at
sun.reflect.GeneratedMethodAccessor62.invoke(Unknown Source):-1 at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43):43
at java.lang.reflect.Method.invoke(Method.java:606):606 at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988):988
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1495):1495
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431):1431
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177):1177
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347):347
at
railo.commons.collection.AbstractMapPro.writeExternal(AbstractMapPro.java:49):49
at
java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1458):1458
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429):1429
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177):1177
at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1547):1547
at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1508):1508
at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1431):1431
at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1177):1177
at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347):347
at
railo.runtime.converter.JavaConverter.serialize(JavaConverter.java:67):67
at
railo.runtime.functions.other.ObjectSave.call(ObjectSave.java:31):31
at
railo.runtime.functions.other.ObjectSave.call(ObjectSave.java:22):22
at
mso.clientobject_cfc$cf._3(/var/www/html/www/www.simon.test/mso/ClientObject.cfc:476):476
at
mso.clientobject_cfc$cf.udfCall(/var/www/html/www/www.simon.test/mso/ClientObject.cfc):-1
at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:94):94 at
railo.runtime.type.UDFImpl._call(UDFImpl.java:307):307 at
railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:198):198
at
railo.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:709):709
at
railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:738):738
at
railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1513):1513
at
mso.clientobject_cfc$cf._3(/var/www/html/www/www.simon.test/mso/ClientObject.cfc:437):437
at
mso.clientobject_cfc$cf.udfCall(/var/www/html/www/www.simon.test/mso/ClientObject.cfc):-1
at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:94):94 at
railo.runtime.type.UDFImpl._call(UDFImpl.java:307):307 at
railo.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:198):198
at railo.runtime.ComponentImpl._call(ComponentImpl.java:617):617 at
railo.runtime.ComponentImpl._call(ComponentImpl.java:499):499 at
railo.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1732):1732
at
railo.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:738):738
at
railo.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1513):1513
at
mso.proxyclientobject_cfm$cf._1(/var/www/html/www/www.simon.test/mso/proxyClientObject.cfm:19):19
at
mso.proxyclientobject_cfm$cf.udfCall(/var/www/html/www/www.simon.test/mso/proxyClientObject.cfm):-1
at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:94):94 at
railo.runtime.type.UDFImpl._call(UDFImpl.java:307):307 at
railo.runtime.type.UDFImpl.call(UDFImpl.java:211):211 at
railo.runtime.ComponentImpl._call(ComponentImpl.java:616):616 at
railo.runtime.ComponentImpl._call(ComponentImpl.java:499):499 at
railo.runtime.ComponentImpl.call(ComponentImpl.java:1715):1715 at
railo.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:712):712
at
railo.runtime.PageContextImpl.getFunction(PageContextImpl.java:1503):1503
at
preparecosting_cfm$cf.call(/var/www/html/www/www.simon.test/prepareCosting.cfm:24):24
at
railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:834):834
at
railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:781):781
at
application_cfc$cf._1(/var/www/html/www/www.simon.test/Application.cfc:177):177
at
application_cfc$cf.udfCall(/var/www/html/www/www.simon.test/Application.cfc):-1
at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:94):94 at
railo.runtime.type.UDFImpl._call(UDFImpl.java:307):307 at
railo.runtime.type.UDFImpl.call(UDFImpl.java:211):211 at
railo.runtime.ComponentImpl._call(ComponentImpl.java:616):616 at
railo.runtime.ComponentImpl._call(ComponentImpl.java:499):499 at
railo.runtime.ComponentImpl.call(ComponentImpl.java:1715):1715 at
railo.runtime.listener.ModernAppListener.call(ModernAppListener.java:388):388
at
railo.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:204):204
at
railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:18):18
at
railo.runtime.PageContextImpl.execute(PageContextImpl.java:2167):2167
at
railo.runtime.PageContextImpl.execute(PageContextImpl.java:2134):2134
at
railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:335):335
at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29 at
javax.servlet.http.HttpServlet.service(HttpServlet.java:728):728 at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305):305
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210):210
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222):222
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123):123
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472):472
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171):171
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99):99
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118):118
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407):407
at
org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200):200
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589):589
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310):310
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145):1145
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615):615
at java.lang.Thread.run(Thread.java:744):744
Unit test + accompanying cfc that can be used to reproduce
javaErrorTest.cfc (Unit test)
component extends='mxunit.framework.TestCase' {
public void function trySavingLargeNestedStruct() {
// Prove that it doesn't happen with nested structures
var nestedStruct = {};
var nestInMe = nestedStruct;
// Make a big struct
var nestedStruct = {};
var v = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
for (var i in v) {
for (var j in v) {
for (var k in v) {
for (var l in v) {
nestedStruct[i][j][k][l] = {};
}
}
}
}
debug('Nested struct len = '&len(serialize(nestedStruct)));
ObjectSave(nestedStruct);
debug('Nested struct saved without error');
}
public void function triggerUTFDataFormatException() {
// Prove that it happens with objects nested deeply
var previousLength = 0;
for (var i=600;i<700;i++) {
objTest = new TestObject( levels = i );
var strSerialized = serialize(objTest);
try {
ObjectSave(objTest);
} catch (java.io.UTFDataFormatException e) {
// Expected place of java.io.UTFDataFormatException
debug('Levels = '&i-1&' has serialize() length = '&previousLength);
debug('Levels = '&i&' has serialize() length = '&Len(strSerialized));
debug(strSerialized);
debug(e);
fail('java.io.UTFDataFormatException (expected) error thrown');
} catch (any e) {
debug(e);
fail('Error thrown, not not the expected one');
}
previousLength = Len(strSerialized);
}
}
}
TestObject.cfc (Used within the failing test)
component {
public TestObject function init(
required numeric levels = 0
) {
variables.a = (arguments.levels > 0)?new TestObject( levels = arguments.levels - 1 ):{};
return this;
}
}
Look at the stack trace. It answers all your questions.
java.io.UTFDataFormatException at java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:2163):2163 at java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:2006):2006
A glance at the Javadoc shows that this exception is thrown by writeUTF() if the data to be written is longer than 65535 bytes.
railo.runtime.ComponentImpl.writeExternal(ComponentImpl.java:1975):1975
This is the code that calls writeUTF(). So it appears to be a bug in the railo.runtime.ComponentImpl class. It shouldn't be calling writeUTF() for such a long string.
The following 2 methods are what I am using in place of ObjectSave and ObjectLoad until the Railo bug is corrected. It seems to function up to a decent level of complexity.
// Replaces ObjectSave
private binary function serializeState(
required struct inState
) {
var strSerialized = serialize(arguments.inState);
return strSerialized.GetBytes();
}
// Replaces ObjectLoad
private struct function deserializeState(
required binary inState
) {
var strSerialized = ToString(arguments.inState);
var stcDeserialized = evaluate(strSerialized);
return stcDeserialized;
}
We are using MdbgCore.dll to evaluate a property off a parameter on a thread callstack.
To do this, we are performing a func-eval.
Unfortunately, all our attempts to perform the func-eval are failing with CORDBG_E_ILLEGAL_IN_OPTIMIZED_CODE, which seems to be due to the thread being used for the func-eval not being in a GC-safe point.
This is documented here: http://blogs.msdn.com/b/jmstall/archive/2005/11/15/funceval-rules.aspx.
We tried scanning all threads in the process to find a thread that is in a GC-safe point, but they all appear to have UserState marked with USER_UNSAFE_POINT.
There is very scarce documentation on the subject, and we are pulling our hair out trying to figure out if there is a way to get a thread in a GC-safe point so we can do the func-eval. We would consider anything that allows us to deterministically break into the process with a thread to do the func-eval with.
Disclaimer: we are trying to evaluate a method on a class that resides in an optimized assembly, so not sure if this is maybe also causing an issue.
The sample code follows:
if (argument.TypeName.EndsWith(
"WorkerRequest", StringComparison.OrdinalIgnoreCase)
&& !argument.IsNull)
{
try
{
// Invoke the "GetUriPath()" function to obtain the URI
string functionName = "System.Web.HttpWorkerRequest.GetUriPath";
MDbgFunction func = debugger.Processes.Active.ResolveFunctionNameFromScope(
functionName,
thread.CorThread.AppDomain
);
if (null == func)
{
throw new InvalidOperationException(
String.Format("Could not resolve {0}", functionName));
}
// Setup the eval
CorEval eval = threadForFuncEvals.CorThread.CreateEval();
// Setup the function parameters
List<CorValue> values = new List<CorValue>();
// Add the worker request "this" pointer
values.Add(
argument.CorValue
);
// resume the thread being used to do the func-eval
threadForFuncEvals.CorThread.DebugState = CorDebugThreadState.THREAD_RUN;
// Queue the function for execution
// EXCEPTION THROWN BELOW
// EXCEPTION THROWN BELOW
// EXCEPTION THROWN BELOW
eval.CallFunction(func.CorFunction, values.ToArray());
// BUGBUG: Should we pause all other threads to prevent them from moving?
// Continue the process to execute the function
if (!proc.Go().WaitOne(settings.BreakTimeout))
{
throw new InvalidOperationException("Timeout while evaluating function");
}
// get the returned string
var result = eval.Result;
if (result != null)
{
MDbgValue mv = new MDbgValue(proc, result);
string returnedValue = mv.GetStringValue(false);
threadInfo.Url = returnedValue;
}
}
catch (Exception e)
{
// BUGBUG: Ignoring exception
}
finally
{
// suspend the thread again
if (threadForFuncEvals != null)
{
threadForFuncEvals.CorThread.DebugState =
CorDebugThreadState.THREAD_SUSPEND;
}
}
}
Microsoft / Mdbg team, can you help?
Best,
Mike
Is this something to do with JIT optimization?
In my program, I turn JIT optimization off (for technical reasons, I think you can only do this with CreateProcess() and not using Attach()).
proc = m_Debugger.CreateProcess(ProcessName, ProcessArgs, DebugModeFlag.Default, DebugEngineUtils.GetAssemblyRuntimeVersion(ProcessName,DefaultNetVersion));
if (proc!=null) proc.CorProcess.OnCreateProcess += new Microsoft.Samples.Debugging.CorDebug.CorProcessEventHandler(CorProcess_OnCreateProcess);
if (proc!=null) proc.CorProcess.OnModuleLoad += new Microsoft.Samples.Debugging.CorDebug.CorModuleEventHandler(CorProcess_OnModuleLoad);
void CorProcess_OnModuleLoad(object sender, Microsoft.Samples.Debugging.CorDebug.CorModuleEventArgs e)
{
e.Module.JITCompilerFlags = Microsoft.Samples.Debugging.CorDebug.CorDebugJITCompilerFlags.CORDEBUG_JIT_DISABLE_OPTIMIZATION;
}
void CorProcess_OnCreateProcess(object sender, Microsoft.Samples.Debugging.CorDebug.CorProcessEventArgs e)
{
//try to disable optimization
((Microsoft.Samples.Debugging.CorDebug.CorProcess)sender).DesiredNGENCompilerFlags = Microsoft.Samples.Debugging.CorDebug.CorDebugJITCompilerFlags.CORDEBUG_JIT_DISABLE_OPTIMIZATION;
}