尝试使用 ODP.NET 读取或写入 Oracle 11g 中受保护的内存

发布于 2024-11-18 02:40:44 字数 1065 浏览 5 评论 0原文

我正在开发一个应用程序,该应用程序应该长期运行并通过 ODP.NET 广泛使用 Oracle (11g) 数据库。

不过,有时(每 2 或 3 天)ODP.NET 会抛出 System.AccessViolationException,然后需要重新启动应用程序。这是我的堆栈跟踪:

Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 
---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Oracle.DataAccess.Client.OpsSql.Prepare2(IntPtr opsConCtx, IntPtr& opsErrCtx, IntPtr& opsSqlCtx, IntPtr& opsDacCtx, OpoSqlValCtx*& pOpoSqlValCtx, string pCommandText, IntPtr& pUTF8CommandText, OpoMetValCtx*& pOpoMetValCtx, Int32 prmCnt)
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonquery()

堆栈跟踪的其余部分有时会有所不同,并且指的是来自我的应用程序的内部调用。

现在,在在这里提问之前我已经做了相当多的研究,但我没有发现任何结论性的东西。许多其他人显然也遇到了同样的问题,尽管根本原因似乎有很大不同。我真的希望有人能解决这个问题:-)

在一个不相关的注释中,这个异常似乎能够忽略我的 catch {} 块,并在每次发生时导致应用程序崩溃。这是因为它与内存损坏问题有关吗?

问候, 安德里亚

编辑:进一步的调查使我相信可能值得启动“分布式事务协调器”服务并查看异常是否停止抛出。你怎么认为?

I am developing an application that is supposed to run for long periods and make extensive usage of an Oracle (11g) database via ODP.NET.

It happens, though, that once in a while (every 2 or 3 days) a System.AccessViolationException is thrown by ODP.NET and then the application needs to be restarted. Here is my stack trace:

Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 
---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Oracle.DataAccess.Client.OpsSql.Prepare2(IntPtr opsConCtx, IntPtr& opsErrCtx, IntPtr& opsSqlCtx, IntPtr& opsDacCtx, OpoSqlValCtx*& pOpoSqlValCtx, string pCommandText, IntPtr& pUTF8CommandText, OpoMetValCtx*& pOpoMetValCtx, Int32 prmCnt)
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonquery()

The rest of the stack trace is different from time to time and refers to internal calls from my application.

Now, I've made a fair amount of research before asking here, but I have found nothing conclusive. A number of other people are apparently experiencing the very same problem, although the root causes seem to vary a lot. I really hope somebody has a solution for this one :-)

On an unrelated note, it appears that this exception is capable of ignoring my catch {} blocks and result in an application crash every time it occurs. Is that because it is related to memory corruption issues?

Regards,
Andrea

edit: further investigation led me to believe that it could be worth starting the "Distributed Transactions Coordinator" service and see if the exception stops being thrown. What do you think?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

遗弃M 2024-11-25 02:40:44

这是一个错误。 11.1 和 11.2 提供商存在此问题。解决此问题的唯一方法是安装 11.2.0.2 客户端,然后应用补丁 6。

This is a bug. The 11.1 and 11.2 providers had this issue. The only way to get around this is to install the 11.2.0.2 client and then apply patch 6.

我不吻晚风 2024-11-25 02:40:44

在构造我的 OracleCommand 对象并添加参数时...

我发现从: 更改

select.Parameters.Add("Result", OracleDbType.RefCursor);

为:

select.Parameters.Add("Result", OracleDbType.RefCursor, ParameterDirection.Output);

在 11.2.0.2 客户端上为我消除了这个问题。

While constructing my OracleCommand object and adding parameters...

I found that changing from:

select.Parameters.Add("Result", OracleDbType.RefCursor);

To:

select.Parameters.Add("Result", OracleDbType.RefCursor, ParameterDirection.Output);

Eliminated this problem for me on the 11.2.0.2 client.

一直在等你来 2024-11-25 02:40:44

我们遇到了相同的 AccessViolationException,因为 RefCursor 被声明为输入参数而不是输出

command.Parameters.Add("O_RECS", OracleDbType.RefCursor, null, ParameterDirection.Input);

对于这样一个简单的错误,这是一个严厉的信息。更改参数方向修复了错误。

command.Parameters.Add("O_RECS", OracleDbType.RefCursor, null, ParameterDirection.Output);

We experienced the same AccessViolationException because an RefCursor was declared as an input parameter instead of Output.

command.Parameters.Add("O_RECS", OracleDbType.RefCursor, null, ParameterDirection.Input);

This is a harsh message for such a simple mistake. Changing the parameter direction fixed the error.

command.Parameters.Add("O_RECS", OracleDbType.RefCursor, null, ParameterDirection.Output);
小鸟爱天空丶 2024-11-25 02:40:44

对于其他发现此问题的人。如果 BatchSize 没有合适的值,则可能会耗尽内存。这会产生相同的错误。

For anyone else finding this issue. If you do not have an appropriate value for BatchSize, you could run out of memory. This yields the same error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文