Web服务调用C++DLL报System.StackOverflowException

dengrenyi 2014-05-06 11:45:32
c++的dll是用来转换图片的,从jpg到我们自定义的图片格式。

用Console应用程序调用没有问题,不会报错,但是到Web服务上调用就会一直报上面这个错。

C++ 的代码是没有问题的,不存在内存溢出。
因为是处理图片,我已开始以为是图片太大(我们的图片有300-500M),IIS承受不住,用小图片依然存在这个问题

直接在VS中调试WebService会报错,以为是VS自带的IIS的问题,发布到IIS上也会报错,又想是不是IIS应用程序池的内置系统账户的问题,改成localSystem依旧报错,IIS上我想到的配置基本上都改了完全没有用。

百度上有人问过这个问题,但是没有出解决方案,求大神看我大半夜还在加班弄这个问题,给个解答~~~分数不多,贡献一百分。
跪求解决方案
...全文
534 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
dengrenyi 2014-05-07
  • 打赏
  • 举报
回复
引用 15 楼 caozhy 的回复:
确实很诡异。我只能给一点猜测,有可能是你的函数内部使用了线程不安全的变量,比如说异步读写之类的,没有做好同步。因为控制台程序是单线程的,所以没有暴露出来。而显然你的服务程序是在多线程环境下调用的。
好的 谢谢 我再找找问题~~~
threenewbee 2014-05-07
  • 打赏
  • 举报
回复
确实很诡异。我只能给一点猜测,有可能是你的函数内部使用了线程不安全的变量,比如说异步读写之类的,没有做好同步。因为控制台程序是单线程的,所以没有暴露出来。而显然你的服务程序是在多线程环境下调用的。
dengrenyi 2014-05-07
  • 打赏
  • 举报
回复
System.dll!System.ComponentModel.BackgroundWorker.OnDoWork(System.ComponentModel.DoWorkEventArgs e) + 0x77 字节 System.dll!System.ComponentModel.BackgroundWorker.WorkerThreadStart(object argument) + 0x4b 字节 [本机到托管的转换] [托管到本机的转换] > mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, System.Runtime.Remoting.Messaging.IMessageSink replySink) + 0x1d8 字节 mscorlib.dll!System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(object o) + 0x51 字节 mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x3e 字节 mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0xa7 字节 mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x16 字节 mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x60 字节 mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x149 字节 mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x5 字节 [本机到托管的转换] 没有了
dengrenyi 2014-05-07
  • 打赏
  • 举报
回复
引用 12 楼 caozhy 的回复:
下面呢?没有了?关键是那个pathologyservice.dll的调用
[托管到本机的转换] PathologyService.dll!PathologyService.SliceImageOpreation.StartConvertJpgToSpi(string sourceImagePath) 行 26 + 0x11 字节 C# [轻量函数] System.ServiceModel.dll!System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(object instance, object[] inputs, out object[] outputs) + 0x34b 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x136 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x92 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x5b 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x9f 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x59 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x3b 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x4e 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x118 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(ref System.ServiceModel.Dispatcher.MessageRpc rpc) + 0x34 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.MessageRpc.Process(bool isOperationContextSet) + 0xf7 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(System.ServiceModel.Channels.RequestContext request, bool cleanThread, System.ServiceModel.OperationContext currentOperationContext) + 0x574 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(System.ServiceModel.Channels.RequestContext request, System.ServiceModel.OperationContext currentOperationContext) + 0x122 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(System.IAsyncResult result) + 0x3f 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(System.IAsyncResult result) + 0x3f 字节 System.ServiceModel.Internals.dll!System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult result) + 0x2c 字节 System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.Complete(bool completedSynchronously) + 0x11f 字节 System.ServiceModel.Internals.dll!System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.AsyncQueueReader.Set(System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.Item item) + 0x44 字节 System.ServiceModel.Internals.dll!System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.EnqueueAndDispatch(System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.Item item, bool canDispatchOnThisThread) + 0x1b0 字节 System.ServiceModel.Internals.dll!System.Runtime.InputQueue<System.ServiceModel.Channels.RequestContext>.EnqueueAndDispatch(System.ServiceModel.Channels.RequestContext item, System.Action dequeuedCallback, bool canDispatchOnThisThread) + 0x60 字节 System.ServiceModel.dll!System.ServiceModel.Channels.SingletonChannelAcceptor<System.ServiceModel.Channels.IReplyChannel,System.ServiceModel.Channels.ReplyChannel,System.ServiceModel.Channels.RequestContext>.Enqueue(System.ServiceModel.Channels.RequestContext item, System.Action dequeuedCallback, bool canDispatchOnThisThread) + 0x6b 字节 System.ServiceModel.dll!System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.CompleteParseAndEnqueue(System.IAsyncResult result) + 0x78 字节 System.ServiceModel.dll!System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.HandleParseIncomingMessage(System.IAsyncResult result) + 0x33 字节 System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.SyncContinue(System.IAsyncResult result) + 0x32 字节 System.ServiceModel.dll!System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult.EnqueueMessageAsyncResult(System.ServiceModel.Channels.ReplyChannelAcceptor acceptor, System.Action dequeuedCallback, System.ServiceModel.Channels.HttpPipeline pipeline, System.AsyncCallback callback, object state) + 0x7b 字节 System.ServiceModel.dll!System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginProcessInboundRequest(System.ServiceModel.Channels.ReplyChannelAcceptor replyChannelAcceptor, System.Action dequeuedCallback, System.AsyncCallback callback, object state) + 0x30 字节 System.ServiceModel.dll!System.ServiceModel.Channels.HttpChannelListener<System.ServiceModel.Channels.IReplyChannel>.HttpContextReceivedAsyncResult<System.ServiceModel.Channels.IReplyChannel>.ProcessHttpContextAsync() + 0xe0 字节 System.ServiceModel.dll!System.ServiceModel.Channels.HttpChannelListener<System.ServiceModel.Channels.IReplyChannel>.BeginHttpContextReceived(System.ServiceModel.Channels.HttpRequestContext context, System.Action acceptorCallback, System.AsyncCallback callback, object state) + 0x5a 字节 System.ServiceModel.Activation.dll!System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(System.ServiceModel.Activation.HostedHttpRequestAsyncResult result) + 0x126 字节 System.ServiceModel.Activation.dll!System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() + 0x1d8 字节 System.ServiceModel.Activation.dll!System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() + 0x1f 字节 System.ServiceModel.Activation.dll!System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(object state) + 0x40 字节 System.ServiceModel.Activation.dll!System.ServiceModel.AspNetPartialTrustHelpers.PartialTrustInvoke(System.Threading.ContextCallback callback, object state) + 0x5a 字节 System.ServiceModel.Activation.dll!System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequestWithFlow(object state) + 0x71 字节 System.ServiceModel.Internals.dll!System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped) + 0x72 字节 System.ServiceModel.Internals.dll!System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(uint error, uint bytesRead, System.Threading.NativeOverlapped* nativeOverlapped) + 0x32 字节 mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) + 0x6e 字节 [本机到托管的转换] [应用程序域转换] [本机到托管的转换] ----- 从客户端转换到服务器 ----- [托管到本机的转换] System.dll!System.Net.Sockets.Socket.Receive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode) + 0xbd 字节 System.dll!System.Net.Sockets.Socket.Receive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags) + 0x1d 字节 System.dll!System.Net.Sockets.NetworkStream.Read(byte[] buffer, int offset, int size) + 0x83 字节 System.dll!System.Net.PooledStream.Read(byte[] buffer, int offset, int size) + 0x14 字节 System.dll!System.Net.Connection.SyncRead(System.Net.HttpWebRequest request, bool userRetrievedStream, bool probeRead) + 0xfc 字节 System.dll!System.Net.Connection.PollAndRead(System.Net.HttpWebRequest request, bool userRetrievedStream) + 0x75 字节 System.dll!System.Net.ConnectStream.WriteHeaders(bool async) + 0x267 字节 System.dll!System.Net.HttpWebRequest.EndSubmitRequest() + 0x8a 字节 System.dll!System.Net.HttpWebRequest.CheckDeferredCallDone(System.Net.ConnectStream stream) + 0x48 字节 System.dll!System.Net.HttpWebRequest.GetResponse() + 0x21c 字节 System.ServiceModel.dll!System.ServiceModel.Channels.HttpChannelFactory<System.ServiceModel.Channels.IRequestChannel>.HttpRequestChannel.HttpChannelRequest.WaitForReply(System.TimeSpan timeout) + 0x38 字节 System.ServiceModel.dll!System.ServiceModel.Channels.RequestChannel.Request(System.ServiceModel.Channels.Message message, System.TimeSpan timeout) + 0x161 字节 System.ServiceModel.dll!System.ServiceModel.Dispatcher.RequestChannelBinder.Request(System.ServiceModel.Channels.Message message, System.TimeSpan timeout) + 0x14 字节 System.ServiceModel.dll!System.ServiceModel.Channels.ServiceChannel.Call(string action, bool oneway, System.ServiceModel.Dispatcher.ProxyOperationRuntime operation, object[] ins, object[] outs, System.TimeSpan timeout) + 0x238 字节 System.ServiceModel.dll!System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(System.Runtime.Remoting.Messaging.IMethodCallMessage methodCall, System.ServiceModel.Dispatcher.ProxyOperationRuntime operation) + 0x5b 字节 System.ServiceModel.dll!System.ServiceModel.Channels.ServiceChannelProxy.Invoke(System.Runtime.Remoting.Messaging.IMessage message) + 0x5b 字节 mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(ref System.Runtime.Remoting.Proxies.MessageData msgData, int type) + 0xea 字节 Client.dll!SliceImageOpreationClient.StartConvertJpgToSpi(string sourceImagePath) + 0x36 字节 [本机到托管的转换] WcfTestClient.exe!Microsoft.Tools.TestClient.ServiceExecutor.Execute(Microsoft.Tools.TestClient.ServiceInvocationInputs inputValues) + 0x532 字节 [应用程序域转换] WCFTestClient.exe!Microsoft.Tools.TestClient.ServiceExecutor.ExecuteInClientDomain(Microsoft.Tools.TestClient.ServiceInvocationInputs inputs) + 0x61 字节 WCFTestClient.exe!Microsoft.Tools.TestClient.UI.MainForm.invokeServiceWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) + 0x45 字节
threenewbee 2014-05-07
  • 打赏
  • 举报
回复
下面呢?没有了?关键是那个pathologyservice.dll的调用
dengrenyi 2014-05-07
  • 打赏
  • 举报
回复
threenewbee 2014-05-07
  • 打赏
  • 举报
回复
你要在服务端,而不是调用端调试。
dengrenyi 2014-05-07
  • 打赏
  • 举报
回复
引用 8 楼 caozhy 的回复:


类似这样的图


我这调用dll根本出不来这些东西 调用堆栈中只有下面的信息
threenewbee 2014-05-07
  • 打赏
  • 举报
回复


类似这样的图
threenewbee 2014-05-07
  • 打赏
  • 举报
回复
要看堆栈的截图
dengrenyi 2014-05-07
  • 打赏
  • 举报
回复
引用 4 楼 caozhy 的回复:
[quote=引用 3 楼 dengrenyi 的回复:]
[quote=引用 1 楼 caozhy 的回复:]
说明程序中有无限递归。调试出错的时候打开调用堆栈窗口,看下都调用了什么函数。

如果存在无限递归的问题的话,C++的dll在哪调用都应该会有溢出错误的吧~[/quote]
贴出你的调试截图再说[/quote]


这个是在服务上的截图

这个是在Console上执行调试直接执行过去了
dengrenyi 2014-05-07
  • 打赏
  • 举报
回复
引用 15 楼 caozhy 的回复:
确实很诡异。我只能给一点猜测,有可能是你的函数内部使用了线程不安全的变量,比如说异步读写之类的,没有做好同步。因为控制台程序是单线程的,所以没有暴露出来。而显然你的服务程序是在多线程环境下调用的。
经过试验,就算用WebService也是这个问题~~~
dengrenyi 2014-05-07
  • 打赏
  • 举报
回复
引用 17 楼 findcaiyzh 的回复:
WCF? 我们也用WCF遇到过很诡异的事情,我们是在WCF调用dongle 保护的dll. 进程hang在那里。 最后不得已又用回asmx web service.
用WebService?我试试~~~说不定真的是WCF来的毛病~~~
宝_爸 2014-05-07
  • 打赏
  • 举报
回复
WCF? 我们也用WCF遇到过很诡异的事情,我们是在WCF调用dongle 保护的dll. 进程hang在那里。 最后不得已又用回asmx web service.
dengrenyi 2014-05-07
  • 打赏
  • 举报
回复
感谢楼上几位大神的回答,这个问题没有办法解决,换了另外一种方式,用windows服务来弄,将要转换的记录丢到数据库中,windows服务来轮询数据库逐个转换。 感谢 caozhy 版主大半夜的还在帮我解答。。。 结贴~~~~~
threenewbee 2014-05-06
  • 打赏
  • 举报
回复
程序的bug是各种各样的。为什么微软的软件开发出来,要在不同的系统上测试?“按理说”Windows 7上正常,Windows 8还要测试么?
threenewbee 2014-05-06
  • 打赏
  • 举报
回复
引用 3 楼 dengrenyi 的回复:
[quote=引用 1 楼 caozhy 的回复:] 说明程序中有无限递归。调试出错的时候打开调用堆栈窗口,看下都调用了什么函数。
如果存在无限递归的问题的话,C++的dll在哪调用都应该会有溢出错误的吧~[/quote] 贴出你的调试截图再说
dengrenyi 2014-05-06
  • 打赏
  • 举报
回复
引用 1 楼 caozhy 的回复:
说明程序中有无限递归。调试出错的时候打开调用堆栈窗口,看下都调用了什么函数。
如果存在无限递归的问题的话,C++的dll在哪调用都应该会有溢出错误的吧~
dengrenyi 2014-05-06
  • 打赏
  • 举报
回复
如果程序中有无限递归,那么Console程序调用这个dll的时候怎么会没有溢出呢~
threenewbee 2014-05-06
  • 打赏
  • 举报
回复
说明程序中有无限递归。调试出错的时候打开调用堆栈窗口,看下都调用了什么函数。

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧