armory3d / armory

3D Engine with Blender Integration
https://armory3d.org
zlib License
3.05k stars 317 forks source link

A breakpoint has been triggered. #2831

Closed chuiliuyiyi closed 1 year ago

chuiliuyiyi commented 1 year ago

Thank you for contributing to Armory!

Description A breakpoint has been triggered.

To Reproduce Steps to reproduce the behavior.

Expected behavior

#include "SystemMicrosoft.h"

#include <kinc/error.h>
#include <kinc/libs/stb_sprintf.h>

#define S_OK ((HRESULT)0L)

static void winerror(HRESULT result) {
    LPVOID buffer = NULL;
    DWORD dw = GetLastError();

    __debugbreak();//A breakpoint has been triggered here.
//A breakpoint has been triggered here.
//A breakpoint has been triggered here.
//A breakpoint has been triggered here.

#if defined(KORE_WINDOWS) || defined(KORE_WINDOWSAPP)
    if (dw != 0) {
        FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw,
                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, NULL);

        kinc_error_message("Error: %s", buffer);
    }
    else {
#endif
        kinc_error_message("Unknown Windows error, return value was 0x%x.", result);
#if defined(KORE_WINDOWS) || defined(KORE_WINDOWSAPP)
    }
#endif
}

void kinc_microsoft_affirm(HRESULT result) {
    if (result != S_OK) {
        winerror(result);
    }
}

void kinc_microsoft_affirm_message(HRESULT result, const char *format, ...) {
    va_list args;
    va_start(args, format);
    kinc_affirm_args(result == S_OK, format, args);
    va_end(args);
}

void kinc_microsoft_format(const char *format, va_list args, wchar_t *buffer) {
    char cbuffer[4096];
    vsprintf(cbuffer, format, args);
    MultiByteToWideChar(CP_UTF8, 0, cbuffer, -1, buffer, 4096);
}

System Blender:3.3.0 Armory:ArmorySDK2303 OS:Windows10,vs2017compiler Graphics card:integrated graphics

Test File (drag & drop the zipped .blend file here) blender.zip

MoritzBrueckner commented 1 year ago

Hi, I can't reproduce the error with your file (I'm using VS2022 though), could you please share more details? The file you shared is only configured to export to Krom so I added windows-hl as a target. If you changed anything from the default exporter settings for HL and that causes the issue, it will not happen to others.

When Visual Studio reaches a breakpoint, it will usually show you a call stack which looks like this: Call Stack example

Could you please share the call stack in your case? The position in which the debug break was triggered unfortunately doesn't help, since __debugbreak() is called as part of a routine that reacts to errors (winerror()), but we currently do not know what is leading to that error.

I noticed that you have a file called ╣Ñ╗¸┴ª1.png, please avoid special characters as they are usually prone to issues. The same goes for "球体" as the name of your sphere object, I'm not sure if all parts of Armory and Kha can handle these characters well. However, it works for me, so there might not be an issue with that in this case :)

Edit: I took the liberty of editing your post above in order to properly format/highlight the code you shared.

MoritzBrueckner commented 1 year ago

Duplicate of https://github.com/armory3d/armory/issues/2832.

chuiliuyiyi commented 1 year ago

I am not very good at operating VS C++. I just open the. sln file, click on compile and run directly, and the breakpoint location will appear