在调试模式下,程序运行良好,但在发布模式下,memcpy操作出错
echo -n $uuid
对此没有任何想法。我总是在调试模式下工作,当决定使Release出现此类错误时。 程序停止在这一行代码上:
:: memcpy(hCellList,CellList.data(),CellSize);
在OgreCu_0.01.exe中的0x00007FFB9820C447(vcruntime140.dll)处引发的异常:0xC0000005:访问冲突写入位置0x0000000000000000。
Visual Studio在memcpy.asm中显示错误 线标记**
CellBot *hCellList;
CellBot *dCellList;
size_t CellSize = WorldConst.numberOfCells * sizeof(CellBot);
assert(!((hCellList = (CellBot *)malloc(CellSize)) == NULL));
gpuAssert(cudaMalloc((void**)&dCellList, CellSize));
::memcpy(hCellList, CellList.data(), CellSize);
gpuAssert(cudaMemcpy(dCellList, hCellList, CellSize, cudaMemcpyHostToDevice));
我将 CopyUp:
cmp r8, 128
jbe XmmCopySmall
bt __favor, __FAVOR_ENFSTRG ; check for ENFSTRG (enhanced fast strings)
jnc XmmCopyUp ; If Enhanced Fast String not available, use XMM
; use Enhanced Fast Strings
; but first align the destination dst to 16 byte alignment
mov rax, r11 ; return original destination pointer
mov r11, rdi ; save rdi in r11
mov rdi, rcx ; move destination pointer to rdi
mov rcx, r8 ; move length to rcx
mov r8, rsi ; save rsi in r8
mov rsi, r10 ; move source pointer to rsi
**rep movsb ; copy source to destination buffer**
mov rsi, r8 ; restore rsi
mov rdi, r11 ; restore rdi
ret
更改为
::memcpy(hCellList, CellList.data(), CellSize);
还有for (int e = 0; e < WorldConst.numberOfCells; e++)
{
hCellList[e] = CellList[e];
}
CellBot的结构
hCellList[e] = CellList[e];
Vec3:
struct CellBot
{
int mainId;
int subId;
Vec3 coord;
Vec3 speed;
Vec3 nspeed;
Vec3 velocity;
Vec3 nvelocity;
float radiusView;
float radiusAttraction;
float radiusRepulsion;
float forceAttraction;
float forceRepulsion;
float radius;
float mass;
float frictionBounce;
int colorId;
int groupId;
};
答案 0 :(得分:3)
很难理解您的问题。请写出更完整的错误消息,并说明您下次的工作!
但是,我的猜测是,您遇到以下问题:<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
语句运行缓慢,因此通常仅在调试模式下编译到您的代码中。在发布模式下,通常只需忽略它们即可。
但是,在您的代码中,您正在19:28:27.282 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Found javax.persistence.Persistence on classpath containing 'getPersistenceUtil'. Assuming JPA 2 environment. Trying to instantiate JPA aware TraversableResolver
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Instantiated JPA aware TraversableResolver of type org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Unable to load or instantiate JPA aware resolver org.hibernate.validator.internal.engine.resolver.JPATraversableResolver. All properties will per default be traversable.
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper - Trying to load META-INF/validation.xml via TCCL
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper - Trying to load META-INF/validation.xml via Hibernate Validator's class loader
19:28:27.298 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser - No META-INF/validation.xml found. Using annotation based configuration only.
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator - Loaded expression factory via original TCCL
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator as ValidatorFactory-scoped message interpolator.
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.resolver.TraverseAllTraversableResolver as ValidatorFactory-scoped traversable resolver.
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.util.ExecutableParameterNameProvider as ValidatorFactory-scoped parameter name provider.
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.DefaultClockProvider as ValidatorFactory-scoped clock provider.
19:28:27.704 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.
内使用assert
。因此,在调试版本中,您将获得所需的内存,而在发行版本中,您将一无所获,并且程序崩溃。该行是:
malloc
您应该做的是:
assert