Fortran Coder

查看: 15311|回复: 7
打印 上一主题 下一主题

[求助] release版本access violaton

[复制链接]

35

帖子

17

主题

0

精华

熟手

F 币
136 元
贡献
240 点
跳转到指定楼层
楼主
发表于 2017-2-10 12:02:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
具体的代码不贴了,估计是个很诡异的问题,看看是不是通病。

1.  debug版本编译与运行没有问题,release编译没有问题运行出现:Program Exception - access violation
2.  采用排出法后,找到问题所在语句,发现语句不存在问题,在此块语句前或者后,添加一个write(*,*)语句后,release版本就不报错,运行通过了。

求助,是否真的存在问题,若存在问题如何查找解决?
分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

1963

帖子

12

主题

5

精华

论坛跑堂

臭石头雪球

F 币
1357 元
贡献
574 点

美女勋章热心勋章星光勋章新人勋章贡献勋章管理勋章帅哥勋章爱心勋章规矩勋章元老勋章水王勋章

沙发
发表于 2017-2-10 12:40:52 | 只看该作者
是否用到了其他函数库?尤其是其他语言书写的函数库?或者混编?
有可能是堆栈不平衡。

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

板凳
发表于 2017-2-10 14:59:21 | 只看该作者
估摸着是数组索引或者指针越界

35

帖子

17

主题

0

精华

熟手

F 币
136 元
贡献
240 点
地板
 楼主| 发表于 2017-2-10 15:50:58 | 只看该作者
没有使用到其他的库,也不存在混编。
查看了https://software.intel.com/en-us ... 071#comment-1548436
也没有找到具体可行的方法。
原有代码比较复杂,有链表的指针,我去试试看能不能自己复现一样的bug出来。

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

5#
发表于 2017-2-10 16:09:42 | 只看该作者
ksfengjia 发表于 2017-2-10 15:50
没有使用到其他的库,也不存在混编。
查看了https://software.intel.com/en-us/forums/intel-visual-fortra ...

编译的时候,开启相关检查选项
譬如
https://gcc.gnu.org/onlinedocs/g ... ml#Code-Gen-Options
-fcheck=<keyword> Enable the generation of run-time checks; the argument shall be a comma-delimited list of the following keywords. Prefixing a check with no- disables it if it was activated by a previous specification. ‘all’Enable all run-time test of -fcheck.
‘array-temps’Warns at run time when for passing an actual argument a temporary array had to be generated. The information generated by this warning is sometimes useful in optimization, in order to avoid such temporaries.
Note: The warning is only printed once per location.

‘bounds’Enable generation of run-time checks for array subscripts and against the declared minimum and maximum values. It also checks array indices for assumed and deferred shape arrays against the actual allocated bounds and ensures that all string lengths are equal for character array constructors without an explicit typespec.
Some checks require that -fcheck=bounds is set for the compilation of the main program.

Note: In the future this may also include other forms of checking, e.g., checking substring references.

‘do’Enable generation of run-time checks for invalid modification of loop iteration variables.
‘mem’Enable generation of run-time checks for memory allocation. Note: This option does not affect explicit allocations using the ALLOCATE statement, which will be always checked.
‘pointer’Enable generation of run-time checks for pointers and allocatables.
‘recursion’Enable generation of run-time checks for recursively called subroutines and functions which are not marked as recursive. See also -frecursive. Note: This check does not work for OpenMP programs and is disabled if used together with -frecursive and -fopenmp.
Example: Assuming you have a file foo.f90, the command
            gfortran -fcheck=all,no-array-temps foo.f90


will compile the file with all checks enabled as specified above except warnings for generated array temporaries.

35

帖子

17

主题

0

精华

熟手

F 币
136 元
贡献
240 点
6#
 楼主| 发表于 2017-2-10 16:22:46 | 只看该作者
ivf选项check array and string bounds已开启,debug与release编译均不报错,
release版本运行时报错(157)Program Exception - access violation

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

7#
发表于 2017-2-10 16:31:40 来自移动端 | 只看该作者
ksfengjia 发表于 2017-2-10 16:22
ivf选项check array and string bounds已开启,debug与release编译均不报错,
release版本运行时报错(157) ...

指针 边界 内存分配呢?
ivf相关选项肯定更多

35

帖子

17

主题

0

精华

熟手

F 币
136 元
贡献
240 点
8#
 楼主| 发表于 2017-2-15 13:37:06 | 只看该作者
因为相关代码形似的,在其他例程中也使用过,边界、内存、指针都应该是可以的,但问题可定出在内存与指针这块,暂时找不到,先放一下了。
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-4-27 10:28

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表