简体   繁体   English

VS程序在调试而不是发布模式下崩溃?

[英]VS program crashes in debug but not release mode?

I am running the following program in VS 2012 to try out the Thrust function find: 我正在VS 2012中运行以下程序以尝试Thrust函数查找:

#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <thrust/find.h>
#include <thrust/device_vector.h>
#include <stdio.h>

int main() {
    thrust::device_vector<char> input(4);

    input[0] = 'a';
    input[1] = 'b';
    input[2] = 'c';
    input[3] = 'd';

    thrust::device_vector<char>::iterator iter;

    iter = thrust::find(input.begin(), input.end(), 'a');

    std::cout << "Index of a = " << iter - input.begin() << std::endl;

    return 0;
}

This is a modified version of a code example taken from http://docs.thrust.googlecode.com/hg/group__searching.html#ga99c7a59cef5b9f4cdbc70f37b2e221be 这是取自http://docs.thrust.googlecode.com/hg/group__searching.html#ga99c7a59cef5b9f4cdbc70f37b2e221be的代码示例的修改版本

When I run this in Debug mode, my program crashes and I get the error Debug Error! ... R6010 - abort() has been called 当我在“调试”模式下运行此程序时,程序崩溃,并且出现错误“ Debug Error! ... R6010 - abort() has been called Debug Error! ... R6010 - abort() has been called . Debug Error! ... R6010 - abort() has been called However, running this in Release mode I just get my expected output Index of a = 0 . 但是,在Release模式下运行它,我得到的期望输出Index of a = 0

I know that the crash happens because of the line that includes the find function. 我知道崩溃是由于包含find函数的行而发生的。

What might cause this to happen? 是什么原因导致这种情况发生?

There are a few similar questions eg here 有一些类似的问题,例如这里

To quote a comment : "Thrust is known to not compile and run correctly when built for debugging" 引用一条评论:“已知在构建调试时,Thrust无法编译并正确运行”

And from the docs : "nvcc does not support device debugging Thrust code. Thrust functions compiled with (eg, nvcc -G, nvcc --device-debug 0, etc.) will likely crash." 并且从文档中得出:“ nvcc不支持设备调试Thrust代码。使用(例如nvcc -G,nvcc --device-debug 0等)编译的Thrust函数可能会崩溃。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SFML 2.1程序在调试模式下运行良好,但在发布模式下崩溃 - SFML 2.1 program runs fine in debug mode, but crashes in release mode QT Creator:程序在调试模式下崩溃,但在发布模式和调试模式下工作,带有基于QThread的程序的断点 - QT Creator : Program crashes in debug mode but working in Release mode and in DEBUG Mode with breakpoints for QThread based program ActiveX控件在发布模式下崩溃,但在调试模式下不崩溃 - ActiveX control that crashes in release mode but not in debug mode 程序仅在发布版本时崩溃——如何调试? - Program only crashes as release build — how to debug? 程序仅在调试器外部的发布模式下崩溃 - Program crashes only in Release mode outside debugger QPainter :: begin在调试模式下使程序崩溃 - QPainter::begin crashes the program in debug mode 小字符串优化(调试与发布模式) - Small String Optimisation (Debug vs Release mode) vs 2008中的#ifdef _DEBUG发行模式 - #ifdef _DEBUG release mode in vs 2008 dll在调试模式下,在发布模式下调用程序(反之亦然) - dll in debug mode, calling program in release mode (and vice versa) 在发布模式下OpenAL Soft崩溃(调试工作正常) - OpenAL Soft crashes in release mode (debug works fine)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM