-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solvespace-cli segfaults in GraphicsWindow::GetCamera() #567
Comments
I didn't look into this very closely, but it could be a logic bug (null pointer access) that by chance happens to work on Linux. I suggest tracing back the crashing access, it could be that in the CLI, the camera is not filled in for some reason. |
Update: identical behaviour on buster:
|
This comes down to guinone's Working diffdiff --git a/src/draw.cpp b/src/draw.cpp
index 907ca00..b9139f6 100644
--- a/src/draw.cpp
+++ b/src/draw.cpp
@@ -304,15 +304,25 @@ void GraphicsWindow::GroupSelection() {
}
Camera GraphicsWindow::GetCamera() const {
+ fprintf(stderr, "GetCamera(window=%p)\n", window.get());
Camera camera = {};
+ fprintf(stderr, "Camera\n");
window->GetContentSize(&camera.width, &camera.height);
+ fprintf(stderr, "GetContentSize\n");
camera.pixelRatio = window->GetDevicePixelRatio();
+ fprintf(stderr, "pixelRatio\n");
camera.gridFit = (window->GetDevicePixelRatio() == 1);
+ fprintf(stderr, "gridFit\n");
camera.offset = offset;
+ fprintf(stderr, "offset\n");
camera.projUp = projUp;
+ fprintf(stderr, "projUp\n");
camera.projRight = projRight;
+ fprintf(stderr, "projRight\n");
camera.scale = scale;
+ fprintf(stderr, "scale\n");
camera.tangent = SS.CameraTangent();
+ fprintf(stderr, "tangent\n");
return camera;
}
diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp
index 0d520dd..4e08553 100644
--- a/src/graphicswin.cpp
+++ b/src/graphicswin.cpp
@@ -404,7 +404,9 @@ void GraphicsWindow::Init() {
toolbarHovered = Command::NONE;
if(!window) {
+ printf("GW::Init(no window)\n");
window = Platform::CreateWindow();
+ printf("CreateWindow() = %p\n", window.get());
if(window) {
using namespace std::placeholders;
// Do this first, so that if it causes an onRender event we don't try to paint without
diff --git a/src/platform/entrycli.cpp b/src/platform/entrycli.cpp
index ad0665d..9b252ab 100644
--- a/src/platform/entrycli.cpp
+++ b/src/platform/entrycli.cpp
@@ -355,6 +355,7 @@ static bool RunCommand(const std::vector<std::string> args) {
Platform::Path absOutputFile = outputFile.Expand(/*fromCurrentDirectory=*/true);
SS.Init();
+ printf("SS.Init(SS.GW.window=%p)\n", SS.GW.window.get());
if(!SS.LoadFromFile(absInputFile)) {
fprintf(stderr, "Cannot load '%s'!\n", inputFile.raw.c_str());
return false;
diff --git a/src/platform/guigtk.cpp b/src/platform/guigtk.cpp
index 73fb01e..968be25 100644
--- a/src/platform/guigtk.cpp
+++ b/src/platform/guigtk.cpp
@@ -1022,6 +1022,7 @@ public:
WindowRef CreateWindow(Window::Kind kind, WindowRef parentWindow) {
auto window = std::make_shared<WindowImplGtk>(kind);
+ printf("CreateWindowGTK(%p)\n", window.get());
if(parentWindow) {
window->gtkWindow.set_transient_for(
std::static_pointer_cast<WindowImplGtk>(parentWindow)->gtkWindow);
diff --git a/src/platform/guinone.cpp b/src/platform/guinone.cpp
index 85beae3..2f259f2 100644
--- a/src/platform/guinone.cpp
+++ b/src/platform/guinone.cpp
@@ -112,7 +112,9 @@ MenuBarRef GetOrCreateMainMenu(bool *unique) {
//-----------------------------------------------------------------------------
WindowRef CreateWindow(Window::Kind kind, WindowRef parentWindow) {
- return std::shared_ptr<Window>();
+ auto window = std::shared_ptr<Window>();
+ printf("CreateWindowNone(%p)\n", window.get());
+ return window;
}
void Request3DConnexionEventsForWindow(WindowRef window) {}
diff --git a/src/platform/guiwin.cpp b/src/platform/guiwin.cpp
index 70160bb..01c04e3 100644
--- a/src/platform/guiwin.cpp
+++ b/src/platform/guiwin.cpp
@@ -1377,8 +1377,10 @@ EGLDisplay WindowImplWin32::eglDisplay = EGL_NO_DISPLAY;
#endif
WindowRef CreateWindow(Window::Kind kind, WindowRef parentWindow) {
- return std::make_shared<WindowImplWin32>(kind,
+ auto window = std::make_shared<WindowImplWin32>(kind,
std::static_pointer_cast<WindowImplWin32>(parentWindow));
+ printf("CreateWindowWin32(%p)\n", window.get());
+ return window;
}
//----------------------------------------------------------------------------- GDB on Windows
GDB on buster
|
Did you two ever get any further on this? Unfortunately the CLI works fine here on Fedora. |
That analysis is as far as I've gotten. I'll be able to test again after the week-end, maybe this was fixed in the mean-time. |
At c514dda, current HEAD:
|
Adding diff --git a/src/draw.cpp b/src/draw.cpp
index db2f33e..f40b80f 100644
--- a/src/draw.cpp
+++ b/src/draw.cpp
@@ -304,6 +304,7 @@ void GraphicsWindow::GroupSelection() {
}
Camera GraphicsWindow::GetCamera() const {
+ fprintf(stderr, "GetCamera(window=%p)\n", window.get());
Camera camera = {};
window->GetContentSize(&camera.width, &camera.height);
camera.pixelRatio = window->GetDevicePixelRatio(); Like in the first diff prints |
`window` is a `nullptr` with guinone.cpp - avoid dereferencing it. Fixes: solvespace#567
Camera GraphicsWindow::GetCamera() const {
Camera camera = {};
window->GetContentSize(&camera.width, &camera.height);
This happens because solvespace/src/graphicswin.cpp Line 413 in d72eba8
which ends up here: solvespace/src/platform/guinone.cpp Line 95 in d72eba8
What is more the virtual I wrote a fix that allows |
`window` is a `nullptr` with guinone.cpp - avoid dereferencing it. Fixes: #567
`window` is a `nullptr` with guinone.cpp - avoid dereferencing it. Fixes: solvespace#567
System information
SolveSpace version: HEAD (645353c)
Operating system: Windows 10
Expected behavior
solvespace-cli
exports a vector viewActual behavior
It segfaults
Additional information
I checked back throughout to HEAD~100 (346f004) and got similar results.
Working diff:
Result:
Seems to happen regardless of selected file (incl. empty), format, or view.
The text was updated successfully, but these errors were encountered: