Application crashes when using vtkSmartVolumeMapper::New() - qt

Crash happens in runtime on vtkSmartVolumeMapper::New() step.
And it goes deep to vtkFixedPointVolumeRayCastMapper constructor. Don't understand how to tackle such an issue, please help
Exception thrown at 0x00007FF73A60735A in smop-ptqt.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
Qt 5.15.6, VTK 9.1.0, ITK 5.2.1

Finally fixed crash on vtkSmartVolumeMapper::New() by using VTK9's new module approach in cmakelists.
So previously, while project used some vtk7.1 version.
CmakeLists treated VTK like this
find_package(VTK CONFIG REQUIRED PATHS "<some_path>/3rd_party/VTK/build/install_dir/lib/cmake/vtk-9.1" )
then used and so on.
target_link_libraries( ...${VTK_LIBRARIES} )
Now I applied module way
find_package(VTK CONFIG REQUIRED
COMPONENTS
GUISupportQt
CommonCore
ViewsCore
ViewsInfovis
DICOM
RenderingCore
RenderingLabel
CommonExecutionModel
RenderingOpenGL2
InteractionWidgets
IOPLY
IOGeometry
RenderingQt
RenderingVolumeOpenGL2
IOImport )
...
target_link_libraries(${PROJECT_NAME} ...
VTK::GUISupportQt
VTK::CommonCore
VTK::ViewsCore
VTK::ViewsInfovis
VTK::DICOM
VTK::RenderingCore
VTK::RenderingLabel
VTK::CommonExecutionModel
VTK::RenderingOpenGL2
VTK::InteractionWidgets
VTK::IOCore
VTK::IOPLY
VTK::IOGeometry
VTK::RenderingQt
VTK::RenderingVolumeOpenGL2
VTK::IOImport
)
...
vtk_module_autoinit(
TARGETS ${PROJECT_NAME}
MODULES VTK::GUISupportQt
VTK::CommonCore
VTK::ViewsCore
VTK::ViewsInfovis
VTK::DICOM
VTK::RenderingCore
VTK::RenderingLabel
VTK::CommonExecutionModel
VTK::RenderingOpenGL2
VTK::InteractionWidgets
VTK::IOCore
VTK::IOPLY
VTK::IOGeometry
VTK::RenderingQt
VTK::RenderingVolumeOpenGL2
VTK::IOImport
)
( was inspired by this script, thank you Qt-VTK-viewer developer(s) who worked on that script https://github.com/martijnkoopman/Qt-VTK-viewer/blob/master/CMakeLists.txt )

Related

How to fix the coredump for 'ProfileInfoCommand' of CLIPS?

CLIPS version: 6.31 .
language: c++ clips C API .
I get a coredump file when execute ProfileInfoCommand after EnvRun.
Why is this error happening? Is there any usage error here? Or this is a bug?
The c++ code 1:
#define PROFILING_FUNCTIONS 1
// ...
EnvReset(clips);
// ...
EnvLoadFactsFromString(clips, facts.str().c_str(), -1);
// ...
EnvRun(clips, 100000);
ProfileInfoCommand(clips);
I know if PROFILING_FUNCTIONS is defined as 1, the EnvRun function will start profile automatically.So I use ProfileInfoCommand after EnvRun,but the coredump has occurred!
And I also tried using another method,but the process also generated a core dump(the same backtrace like the c++ code 1).
The c++ code 2:
EnvReset(clips);
Profile(clips, "constructs");
// ...
EnvLoadFactsFromString(clips, facts.str().c_str(), -1);
// ...
EnvRun(clips, max_iters);
Profile(clips, "off");
ProfileInfoCommand(clips);
The coredump file is following:
Core was generated by `/mnt/home/worker/project/ae-arbiter/dist/bin/arbiter-8003 --flagfile=flags.'.
Program terminated with signal 11, Segmentation fault.
#0 0x0000000000bc6b80 in EnvRtnArgCount (theEnv=Cannot access memory at address 0x7f879c3f6af8
) at /mnt/home/worker/project/ae-arbiter/src/clips/argacces.cc:306
306 for (argPtr = EvaluationData(theEnv)->CurrentExpression->argList;
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6.x86_64
(gdb) bt
#0 0x0000000000bc6b80 in EnvRtnArgCount (theEnv=0x7f85e6454f70) at /mnt/home/worker/project/ae-arbiter/src/clips/argacces.cc:306
#1 0x0000000000bc6bcd in EnvArgCountCheck (theEnv=0x7f85e6454f70, functionName=0xda1188 "profile", countRelation=2, expectedNumber=1) at /mnt/home/worker/project/ae-arbiter/src/clips/argacces.cc:337
#2 0x0000000000c40803 in ProfileInfoCommand (theEnv=0x7f85e6454f70) at /mnt/home/worker/project/ae-arbiter/src/clips/proflfun.cc:245
#3 0x0000000000b62d12 in arbiter::lib::ClipsModuleExecute (clips=0x7f85e6454f70, features=..., max_iters=100000, result_func=..., module_name=..., halt=#0x7f879c3f6fdc)
at /mnt/home/worker/project/ae-arbiter/src/lib/clips-utils.cc:357
...
...
Setting PROFILING_FUNCTIONS to 1 does not automatically profile code when EnvRun is called. It determines whether the profiling functions are included in the CLIPS executable. See Section 2.2 of the Advanced Programming Guide. The functions available for profiling from the CLIPS command are documented in Section 13.15, Profiling Commands, of the Basic Programming Guide. The ProfileInfoCommand can't be called directly. If you want to call a CLIPS command/function that isn't part of the API described in the Advanced Programming Guide, use the EnvEval API:
DATA_OBJECT returnValue;
EnvEval(theEnv,"(profile-info)",&returnValue);

posix_fallocate() failed: Operation not permitted while opening .realm file

I get the below error when i try to open and download .realm file in /tmp directory of serverless framework.
{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: posix_fallocate() failed: Operation not permitted" }
Below is the code:
let realm = new Realm({path: '/tmp/custom.realm', schema: [schema1, schema2]});
realm.write(() => {
console.log('completed==');
});
EDIT: this might soon be finally fixed in Realm-Core: see issue 4957.
In case you'll run into this problem elsewhere, here's a workaround.
This caused by AWS Lambda not supporting the fallocate and fallocate64 system calls. Instead of returning the correct error code in this case, which would be EINVAL for not supported on this file system, Amazon has blocked the system call so that it returns EPERM. Realm-Core has code that handles EINVAL return value correctly but will be bewildered by the unexpected EPERM returned from the system call.
The solution is to add a small shared library as a layer to the lambda: compile the following C file on Linux machine or inside lambda-ci Docker image:
#include <errno.h>
#include <fcntl.h>
int posix_fallocate(int __fd, off_t __offset, off_t __len) {
return EINVAL;
}
int posix_fallocate64(int __fd, off_t __offset, off_t __len) {
return EINVAL;
}
Now, compile this to a shared object with something like
gcc -shared fix.c -o fix.so
Then add it to a root of a ZIP file:
zip layer.zip fix.so
Create a new lambda layer from this zip
Add the lambda layer to your lambda function
Finally make the shared object be loaded by configuring the environment value LD_PRELOAD with value /opt/fix.so to your Lambda.
Enjoy.

How do I suppress warnings about the Unsafe API when compiling with SBT

I have a project including both Java and Scala sources. The Java sources include one file which uses the sun.misc.Unsafe API. We are well aware of the risks of using this API and want to suppress the warnings in this file. However, we also want to treat warnings as errors on the rest of the Java and Scala code.
My build.sbt includes these lines:
lazy val root = (project in file(".")).
settings(
// ...
Compile / javacOptions ++= Seq(
"-Xlint:all",
"-Werror",
"-XDenableSunApiLintControl"
),
Compile / fork := true,
Compile / javaOptions += "-XDenableSunApiLintControl",
// ...
)
I understand from an SO comment on a related post that I must fork a new JVM for -XDenableSunApiLintControl to take effect. For this reason, I specified Compile / fork := true and respecified the option in the Compile / javaOptions.
Unfortunately, I still see the warning reported as an error.
My Java file starts this way:
package is.hail.annotations;
import sun.misc.Unsafe;
import java.lang.reflect.Field;
#SuppressWarnings("sunapi")
public final class Memory {
Which successfully suppresses the warnings when using Gradle with
compileJava {
options.compilerArgs << "-Xlint:all" << "-Werror" << "-XDenableSunApiLintControl"
}
tasks.withType(JavaCompile) {
options.fork = true // necessary to make -XDenableSunApiLintControl work
}
How do I enable suppression of the sun.misc.Unsafe API in SBT?

"undefined reference to `boost::system::generic_category()" qtcreator with cmake

I try to use boost in qtcreator(windows) with Cmake, Cmake can find boost "system" and "thread" sucessfully, but there is there is a problem "undefined reference to `boost::system::generic_category()" while compiling. I searched problem like this, adding "-lboost_system" maybe a solution,but there is no ".pro" file in my project,so how to add it in CMakeLists.
Below is part of my CmakeLists:
project(demo)
cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(DEBUG_FLAG _d)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(Qt5Declarative)
find_package(OpenGL REQUIRED)
find_package(Boost 1.58 REQUIRED COMPONENTS system thread)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
set(OGRE_RESOURCE_FOLDER ${PROJECT_SOURCE_DIR}/resources)
set(OGRE_HOME "D:/3rd/OGRE")
set(OGRE_PLUGIN_FOLDER "${OGRE_HOME}\\bin")
include_directories(
"${OGRE_HOME}\\include"
"${OGRE_HOME}\\include\\OGRE"
"${OGRE_HOME}\\include\\OGRE\\RenderSystems\\GL"
"${OGRE_HOME}\\boost")
link_directories(${LINK_DIRECORIES} "${OGRE_HOME}\\lib" "${OGRE_HOME}\\lib\\opt")
include_directories("C:/3rd/Eigen" "C:/3rd/robotics/include" "D:/3rd/Eigen" "D:/3rd/robotics/include")
link_directories("C:/3rd/robotics/lib" "D:/3rd/robotics/lib")
add_library(robot src/robot.cpp)
add_library(QOgre src/QOgreWidget.cpp)
qt5_use_modules(QOgre OpenGL Widgets Xml)
add_executable(OGREDemo src/QOgreWidgetDemo.cpp src/ogredemo.cpp )
qt5_use_modules(OGREDemo OpenGL Widgets Xml)
target_link_libraries(OGREDemo ${OPENGL_LIBRARIES} ${BOOST_LINK_LIBS_DEBUG}
OgreMain${DEBUG_FLAG} OIS${DEBUG_FLAG}
orocos-kdl${DEBUG_FLAG} robot QOgre )
file(GLOB_RECURSE QMLS "." "*.qml")
qt5_add_resources(RESOURCES_ADDED resources/qml.qrc)
set_source_files_properties(${RESOURCE_ADDED} PROPERTIES GENERATED ON)
add_executable(recat src/main.cpp src/QmlOgre.cpp ${RESOURCES_ADDED} ${QMLS})
qt5_use_modules(recat Widgets Xml Quick Qml Core Gui Declarative)
target_link_libraries(recat ${OPENGL_LIBRARIES} ${BOOST_LINK_LIBS_DEBUG}
OgreMain${DEBUG_FLAG} OIS${DEBUG_FLAG} RenderSystem_GL${DEBUG_FLAG}
orocos-kdl${DEBUG_FLAG} robot)
configure_file (
"${PROJECT_SOURCE_DIR}/plugins.cfg.in"
"${PROJECT_BINARY_DIR}/plugins.cfg"
)
configure_file (
"${PROJECT_SOURCE_DIR}/resources.cfg.in"
"${PROJECT_BINARY_DIR}/resources.cfg"
)
And detailed problem description:
D:\3rd\robotics_android\src\QOgreWidgetDemo.cpp:-1: error: undefined reference to `boost::system::generic_category()'
error: CMakeFiles\OGREDemo.dir/objects.a(QOgreWidgetDemo.cpp.obj): bad reloc address 0x1b in section `.text$_ZNK5boost6system10error_code7messageEv[__ZNK5boost6system10error_code7messageEv]'
The right variable to link against is Boost_SYSTEM_LIBRARY_DEBUG. As #usr1234567 stated it is not necessary to use link_directories.
For reference see: https://cmake.org/cmake/help/v3.0/module/FindBoost.html

How to generate good crash log report for Qt application in windows

I got such crash log in one of Qt application, Any idea how qt application is implemented to get such good crash report ?
//=====================================================
Crash Time: Fri Aug 20 15:05:51 2010
Tool Version: 1.6 (08/21/09)
Exception code: C0000005 ACCESS_VIOLATION
Fault address: 06706000 00:01FED9E4
Registers:
EAX:067689A0
EBX:00000000
ECX:067689A0
EDX:026304C0
ESI:00000012
EDI:01FEF018
CS:EIP:001B:06706000
SS:ESP:0023:01FEE4B4 EBP:01FEE4CC
DS:0023 ES:0023 FS:003B GS:0000
Flags:00010206
Call stack:
Address Frame
06706000 01FEE4B0 0000:00000000
39DE15ED 01FEE4CC QWidget::reparent+2D
39E7F560 01FEE6F4 QMenuBar::calculateRects+2D0
39E7E4B1 01FEE708 QMenuBar::performDelayedContentsChanged+41
39E7E600 01FEE714 QMenuBar::performDelayedChanges+20
39E7FF24 01FEE88C QMenuBar::drawContents+24
39E4162E 01FEEA88 QFrame::paintEvent+3BE
39DE060E 01FEEB00 QWidget::event+39E
39D56AE8 01FEEB38 QApplication::internalNotify+1E8
39D56785 01FEEC68 QApplication::notify+865
39D0A89B 01FEEC7C QApplication::sendSpontaneousEvent+3B
39D13DEF 01FEED2C QApplication::winMouseButtonUp+20DF
39D1095E 01FEEFB0 QApplication::winFocus+FBE
7E418734 01FEEFDC GetDC+6D
7E418816 01FEF044 GetDC+14F
7E41B4C0 01FEF098 DefWindowProcW+184
7E41B50C 01FEF0C0 DefWindowProcW+1D0
7C90EAE3 01FEF12C KiUserCallbackDispatcher+13
7E418A10 01FEF13C DispatchMessageW+F
39D25EED 01FEF194 QEventLoop::processEvents+2AD
39D76814 01FEF1AC QEventLoop::enterLoop+74
39D766CD 01FEF1B8 QEventLoop::exec+1D
39D56CCC 01FEF1C8 QApplication::exec+1C
0044847A 01FEFED8 0001:0004747A c:\QtTest\too\main.exe
004465C0 01FEFEE8 0001:000455C0 c:\QtTest\too\main.exe
00F17729 01FEFF18 0001:00B16729 c:\QtTest\too\main.exe
00F148E7 01FEFFC0 0001:00B138E7 c:\QtTest\too\main.exe
7C816FD7 01FEFFF0 RegisterWaitForInputIdle+49
Crash Log:
( 54350.189194700) T> Compile_And_Link_User_Code_Body
( 54350.191276250) T> Create_Header_Expanded_Driver called for: testQt
( 54350.197348809) T> computil.adb:Get_Preprocessed_File called SOURCE_FILE=QtTest_TMP.8.20.54350.2.10156.40.c
( 54350.786834903) T> Create_Header_Expanded_Driver called for: testQt
( 54350.792789012) T> computil.adb:Get_Preprocessed_File called SOURCE_FILE=QtTest_TMP.8.20.54350.8.10156.49.c,
( 54351.056315801) G> add_all_testcase_user_code_to_harness failure COMPILER_PKG.COMPILE_ERROR_EXCEPTION
( 54351.056962252) G> HierarchyView::initCoverage() ...
( 54351.068467625) G> starting Parser::build_testobjectlist_from_xml()
There is no crash report creation provided as part of Qt.
The application in question probably just registers an exception filter with the operating system, e.g. SetUnhandledExceptionFilter on Windows, and compiles and writes this crash report out itself.
If you didn't fancy rolling your own crash reporter, there are some nice open source libraries you could use for generating verbose crash reports like Google's Breakpad.
http://code.google.com/p/google-breakpad/

Resources