Closed YuweiXiao closed 1 year ago
Thank you for the report!
I didn't thing know was possible to trigger stack alignment errors from reasonable C++ code (maybe it's the code is not reasonable?).
I'm guessing this is within your own project---are you using any unusual compiler flags?
I haven't seen this while building/testing before, and don't have a Catalina machine, so this might be hard for me to reproduce. Could you verify that that the issue persists if you either (a) build and run the tests, or (b) build and run the demo app?
Thanks for the reply!
I tested the demo and tests. It works and no error reported.
My project is just a toy example trying polyscope. I found the following setting of the c++ flag caused the segment fault.
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -march=native")
By manually setting both the optimization and asking the compiler to choose the native instruction set, the compiled program will meet stack alignment. The same problem happens for the demo app. Removing either (or both) of the flag settings solves the error.
I am not sure why is it. But I guess it is not a good practice to specify optimization level manually.
Hmmmm, I think those flags should be safe, so there may still be a Polyscope issue here, perhaps an alignment problem with those material buffers. It could also be the case that the march=native
flag isn't getting propagated to the dependencies correctly, leading to alignment issues when linking. I can try to reproduce the crash with those flags.
Closing old issue. Feel free to reopen if it's still an issue.
polyscope::init(); polyscope::show();
[polyscope] Backend: openGL3_glfw -- Loaded openGL version: 4.1 ATI-3.5.5 [1] 5910 segmentation fault ./demo
exception: stack_not_16_byte_aligned_error stb_image.h: stbiload_and_postprocess_8bit stb_image.h: stbiloadf_main stb_image.h: stbi_loadf_from_memory engine.cpp: loadDefaultMaterial engine.cpp: loadDefaultMaterials engine.cpp: allocateGlobalBuffersAndPrograms
MacOS Catalina 10.15.3, compiler: apple clang v11
comment out following material load in engine.cpp:
loadDefaultMaterial("mud"); loadDefaultMaterial("ceramic"); loadDefaultMaterial("jade"); loadDefaultMaterial("normal");