(win) Memory Access Violation in Release Mode
Monkey Forums/Monkey Programming/(win) Memory Access Violation in Release Mode
| ||
| Hey guys, I am getting a MAV in Release Mode for the Desktop Target (glfw3). No error message or line number. Debug Builds work fine, as do Html5 builds. I have narrowed the error down to a code section using Print statements. The problem now is that it actually works after inserting Print statements. This leads me to believe there is an issue with memory alignment in c++ (as also suggested by Gerry Quinn here: http://www.monkey-x.com/Community/posts.php?topic=12342) I am using just a bit of custom c++ code, don't think that's the issue:
GLFWwindow* getWindow() {
return BBGlfwGame::GlfwGame()->GetGLFWwindow();
}
class MouseWheelInfo {
public:
Float x;
Float y;
MouseWheelInfo() : x(0.0), y(0.0) {}
};
MouseWheelInfo* wheelInfo;
void scrollwheelCallback(GLFWwindow* window, double xoffset, double yoffset) {
wheelInfo->x = Float(xoffset);
wheelInfo->y = Float(yoffset);
}
void NativeInit() {
GLFWwindow* window = getWindow();
glfwSetScrollCallback(window, &scrollwheelCallback);
wheelInfo = new MouseWheelInfo();
}
Float MouseZUnsafe() {
if (wheelInfo != 0) {
float z = wheelInfo->y;
wheelInfo->y = 0.0;
return z;
}
return 0.0;
}
bool SuperKey() {
return glfwGetKey(getWindow(), GLFW_KEY_LEFT_SUPER) == GLFW_PRESS ||
glfwGetKey(getWindow(), GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS;
}
bool AltKey() {
return glfwGetKey(getWindow(), GLFW_KEY_LEFT_ALT) == GLFW_PRESS ||
glfwGetKey(getWindow(), GLFW_KEY_RIGHT_ALT) == GLFW_PRESS;
}
void ClipboardSet(String data) {
glfwSetClipboardString(getWindow(), data.ToCString<char>());
}
String ClipboardGet() {
const char* s = glfwGetClipboardString(getWindow());
return String(s);
}
void ClipboardClear() {
glfwSetClipboardString(getWindow(), "");
}
void SeekMusic(int ms) {
gxtkChannel *channel = &(gxtkAudio::audio->channels[32]);
if (channel && channel->state == 1) {
alSourcef(channel->source, AL_SEC_OFFSET, (float)(ms / 1000.0));
}
}
EDIT: Also I have used the x64dbg debugger, but couldn't find out much because I can't read assembly. But when it crashes, it shows "TileObjectData" as info, which is a class in my project. Here the relevant class:
Class TileObjectData Extends Component
Field collides:Bool
Field look:String
Field facing:Int = TILE_DOWN
Field refName:String
Field data:String
Field type:Int = TYPE_NONE
Const TYPE_NONE:Int = 0
Const TYPE_SCRIPT:Int = 1
Const TYPE_SCRIPT_REF:Int = 2
Const TYPE_SAVEPOINT:Int = 3
Const TYPE_SHIP:Int = 6
Const TYPE_DOCK:Int = 7
End
Class Component Abstract
Field entity:Entity
Field active:Bool = True
End
Class Entity
Field name:String
Field attributes:StringMap<String>
Field tags:Int
Field position:Vec2 = New Vec2
Field scale:Vec2 = New Vec2(1.0, 1.0)
Field rotation:Float
Field visible:Bool = True
End
|
| ||
| I "solved" this by using the Microsoft Compiler. |
| ||
| I had an error like this. I fixed it by changing a method into a function. |