Fortran Coder

标题: release版本access violaton [打印本页]

作者: ksfengjia    时间: 2017-2-10 12:02
标题: release版本access violaton
具体的代码不贴了,估计是个很诡异的问题,看看是不是通病。

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

求助,是否真的存在问题,若存在问题如何查找解决?

作者: fcode    时间: 2017-2-10 12:40
是否用到了其他函数库?尤其是其他语言书写的函数库?或者混编?
有可能是堆栈不平衡。
作者: pasuka    时间: 2017-2-10 14:59
估摸着是数组索引或者指针越界
作者: ksfengjia    时间: 2017-2-10 15:50
没有使用到其他的库,也不存在混编。
查看了https://software.intel.com/en-us ... 071#comment-1548436
也没有找到具体可行的方法。
原有代码比较复杂,有链表的指针,我去试试看能不能自己复现一样的bug出来。
作者: pasuka    时间: 2017-2-10 16:09
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.

作者: ksfengjia    时间: 2017-2-10 16:22
ivf选项check array and string bounds已开启,debug与release编译均不报错,
release版本运行时报错(157)Program Exception - access violation
作者: pasuka    时间: 2017-2-10 16:31
ksfengjia 发表于 2017-2-10 16:22
ivf选项check array and string bounds已开启,debug与release编译均不报错,
release版本运行时报错(157) ...

指针 边界 内存分配呢?
ivf相关选项肯定更多
作者: ksfengjia    时间: 2017-2-15 13:37
因为相关代码形似的,在其他例程中也使用过,边界、内存、指针都应该是可以的,但问题可定出在内存与指针这块,暂时找不到,先放一下了。




欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2