Я экспериментирую с многопоточностью Bullet. В следующем простом примере я получаю сообщение об ошибке неизвестного адреса. btCollisionConfiguration инициализируется правильно, и я был бы признателен за понимание проблемы. вот код:
#include
#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.h"
#include "BulletCollision/CollisionDispatch/btCollisionDispatcherMt.h"
#include "BulletCollision/BroadphaseCollision/btDbvtBroadphase.h"
#include "BulletCollision/CollisionShapes/btBoxShape.h"
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorldMt.h"
int main() {
btDbvtBroadphase* broadphase = new btDbvtBroadphase();
btSequentialImpulseConstraintSolverMt* solver = new btSequentialImpulseConstraintSolverMt();
btDefaultCollisionConstructionInfo cci;
cci.m_defaultMaxPersistentManifoldPoolSize = 10;
cci.m_defaultMaxCollisionAlgorithmPoolSize = 10;
btCollisionConfiguration* collisionConfig = new btDefaultCollisionConfiguration(cci);
btCollisionDispatcher* dispatcher = new btCollisionDispatcherMt(collisionConfig);
btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfig);
dynamicsWorld->setGravity(btVector3(0, -10, 0));
btBoxShape* boxShape = new btBoxShape(btVector3(1, 1, 1));
btScalar mass = 1.0;
btVector3 localInertia(0, 0, 0);
boxShape->calculateLocalInertia(mass, localInertia);
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0, 50, 0));
btDefaultMotionState* motionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, motionState, boxShape, localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
dynamicsWorld->addRigidBody(body);
for (int i = 0; i < 100; ++i) {
dynamicsWorld->stepSimulation(1.f / 60.f, 10);
}
// Cleanup
delete body;
delete motionState;
delete boxShape;
delete dynamicsWorld;
delete solver;
delete broadphase;
delete dispatcher;
delete collisionConfig;
return 0;
}
вот мой файл Cmake:
cmake_minimum_required(VERSION 3.10)
project(PhysicsSimulation)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
ADD_DEFINITIONS( -DBT_THREADSAFE=1 )
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
find_package(Bullet REQUIRED)
message(STATUS "Bullet libraries: ${BULLET_LIBRARIES}")
message(STATUS "Bullet include directories: ${BULLET_INCLUDE_DIRS}")
add_executable(PhysicsSimulation PerformanceTest.cpp)
target_include_directories(PhysicsSimulation PUBLIC ${BULLET_INCLUDE_DIRS})
target_link_libraries(PhysicsSimulation PUBLIC ${BULLET_LIBRARIES})
set_target_properties(PhysicsSimulation PROPERTIES
DEBUG_POSTFIX "_Debug"
MINSIZEREL_POSTFIX "_MinsizeRel"
RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo"
)
Вот ошибка:
=================================================================
==10700==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00010473fff4 bp 0x00016b6db190 sp 0x00016b6db120 T0)
==10700==The signal is caused by a READ memory access.
==10700==Hint: address points to the zero page.
#0 0x10473fff4 in btCollisionDispatcherMt::btCollisionDispatcherMt(btCollisionConfiguration*, int)+0x64 (PhysicsSimulation_Debug:arm64+0x10001bff4)
#1 0x104727ccc in main PerformanceTest.cpp:54
#2 0x18bf320dc ()
==10700==Register values:
x[0] = 0x0000000000000000 x[1] = 0x0000000000000023 x[2] = 0x0000000000000023 x[3] = 0x0000000108400010
x[4] = 0x0000000108400280 x[5] = 0x0000000000000000 x[6] = 0x000000016aee0000 x[7] = 0x0000000000000001
x[8] = 0x0000000104770000 x[9] = 0x00000001081039d0 x[10] = 0x0000000000000005 x[11] = 0x00000000ffffffff
x[12] = 0x0000000000000000 x[13] = 0xda122256f3c39294 x[14] = 0x0000000000007e01 x[15] = 0x0000000000000006
x[16] = 0x0000000105044a98 x[17] = 0x00000001050840b8 x[18] = 0x0000000000000000 x[19] = 0x0000000108400200
x[20] = 0x0000000000000028 x[21] = 0x000000016b6db360 x[22] = 0x0000000104b9d910 x[23] = 0x000000016b6db3e0
x[24] = 0x0000000108405354 x[25] = 0x000000018bfa62db x[26] = 0x0000000000000000 x[27] = 0x0000000000000000
x[28] = 0x0000000000000000 fp = 0x000000016b6db190 lr = 0x000000010473fff4 sp = 0x000000016b6db120
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (PhysicsSimulation_Debug:arm64+0x10001bff4) in btCollisionDispatcherMt::btCollisionDispatcherMt(btCollisionConfiguration*, int)+0x64
==10700==ABORTING
zsh: abort
Также учтите, что на компьютере установлен чип M3. Я попытался проверить адресную память, но инициализация btCollisionDispatcherMt не удалась. Я не уверен, связано ли это с плохой настройкой Bullet3 в моем коде или с недостающими частями при построении SDK. Обратите внимание, что я создал SDK в режиме двойной точности.
ОБНОВЛЕНИЕ:
Я выполнил некоторую отладку с использованием lldb и вывод переменной кадра равен nullptr после перехода в новый btCollisionDispatcherMt(collisionConfig):
(lldb) run
Process 12734 launched: '/Users/.../Documents/InternalCode/PlayGround/Bullet/C++/Arena/MT1/build/PhysicsSimulation_Debug' (arm64)
Process 12734 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100003458 PhysicsSimulation_Debug`main at PerformanceTest.cpp:53:41
50 cci.m_defaultMaxPersistentManifoldPoolSize = 10;
51 cci.m_defaultMaxCollisionAlgorithmPoolSize = 10;
52 btCollisionConfiguration* collisionConfig = new btDefaultCollisionConfiguration(cci);
-> 53 btCollisionDispatcher* dispatcher = new btCollisionDispatcherMt(collisionConfig);
54 // btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfig);
55 // dynamicsWorld->setGravity(btVector3(0, -10, 0));
56
Target 0: (PhysicsSimulation_Debug) stopped.
(lldb) frame variable
(btDbvtBroadphase *) broadphase = 0x0000000103503ac0
(btSequentialImpulseConstraintSolverMt *) solver = 0x0000000100203790
(btDefaultCollisionConstructionInfo) cci = {
m_persistentManifoldPool = nullptr
m_collisionAlgorithmPool = nullptr
m_defaultMaxPersistentManifoldPoolSize = 10
m_defaultMaxCollisionAlgorithmPoolSize = 10
m_customCollisionAlgorithmMaxElementSize = 0
m_useEpaPenetrationAlgorithm = 1
}
(btCollisionConfiguration *) collisionConfig = 0x0000000103d03880
(btCollisionDispatcher *) dispatcher = 0x00000000000002c0
(lldb) step
Process 12734 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x00000001006613b4 libBulletCollision.3.26.dylib`btCollisionDispatcherMt::btCollisionDispatcherMt(btCollisionConfiguration*, int) + 108
libBulletCollision.3.26.dylib`btCollisionDispatcherMt::btCollisionDispatcherMt:
-> 0x1006613b4 : ldr x8, [x0]
0x1006613b8 : ldr x8, [x8, #0x18]
0x1006613bc : blr x8
0x1006613c0 : mov x21, x0
Target 0: (PhysicsSimulation_Debug) stopped.
(lldb) frame variable
(lldb)
Подробнее здесь: https://stackoverflow.com/questions/784 ... le-example
Ошибка памяти в многопоточном режиме Bullet3: простой пример ⇐ C++
Программы на C++. Форум разработчиков
-
Anonymous
1716237269
Anonymous
Я экспериментирую с многопоточностью Bullet. В следующем простом примере я получаю сообщение об ошибке неизвестного адреса. btCollisionConfiguration инициализируется правильно, и я был бы признателен за понимание проблемы. вот код:
#include
#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.h"
#include "BulletCollision/CollisionDispatch/btCollisionDispatcherMt.h"
#include "BulletCollision/BroadphaseCollision/btDbvtBroadphase.h"
#include "BulletCollision/CollisionShapes/btBoxShape.h"
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorldMt.h"
int main() {
btDbvtBroadphase* broadphase = new btDbvtBroadphase();
btSequentialImpulseConstraintSolverMt* solver = new btSequentialImpulseConstraintSolverMt();
btDefaultCollisionConstructionInfo cci;
cci.m_defaultMaxPersistentManifoldPoolSize = 10;
cci.m_defaultMaxCollisionAlgorithmPoolSize = 10;
btCollisionConfiguration* collisionConfig = new btDefaultCollisionConfiguration(cci);
btCollisionDispatcher* dispatcher = new btCollisionDispatcherMt(collisionConfig);
btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfig);
dynamicsWorld->setGravity(btVector3(0, -10, 0));
btBoxShape* boxShape = new btBoxShape(btVector3(1, 1, 1));
btScalar mass = 1.0;
btVector3 localInertia(0, 0, 0);
boxShape->calculateLocalInertia(mass, localInertia);
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0, 50, 0));
btDefaultMotionState* motionState = new btDefaultMotionState(startTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, motionState, boxShape, localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
dynamicsWorld->addRigidBody(body);
for (int i = 0; i < 100; ++i) {
dynamicsWorld->stepSimulation(1.f / 60.f, 10);
}
// Cleanup
delete body;
delete motionState;
delete boxShape;
delete dynamicsWorld;
delete solver;
delete broadphase;
delete dispatcher;
delete collisionConfig;
return 0;
}
вот мой файл Cmake:
cmake_minimum_required(VERSION 3.10)
project(PhysicsSimulation)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
ADD_DEFINITIONS( -DBT_THREADSAFE=1 )
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
find_package(Bullet REQUIRED)
message(STATUS "Bullet libraries: ${BULLET_LIBRARIES}")
message(STATUS "Bullet include directories: ${BULLET_INCLUDE_DIRS}")
add_executable(PhysicsSimulation PerformanceTest.cpp)
target_include_directories(PhysicsSimulation PUBLIC ${BULLET_INCLUDE_DIRS})
target_link_libraries(PhysicsSimulation PUBLIC ${BULLET_LIBRARIES})
set_target_properties(PhysicsSimulation PROPERTIES
DEBUG_POSTFIX "_Debug"
MINSIZEREL_POSTFIX "_MinsizeRel"
RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo"
)
Вот ошибка:
=================================================================
==10700==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00010473fff4 bp 0x00016b6db190 sp 0x00016b6db120 T0)
==10700==The signal is caused by a READ memory access.
==10700==Hint: address points to the zero page.
#0 0x10473fff4 in btCollisionDispatcherMt::btCollisionDispatcherMt(btCollisionConfiguration*, int)+0x64 (PhysicsSimulation_Debug:arm64+0x10001bff4)
#1 0x104727ccc in main PerformanceTest.cpp:54
#2 0x18bf320dc ()
==10700==Register values:
x[0] = 0x0000000000000000 x[1] = 0x0000000000000023 x[2] = 0x0000000000000023 x[3] = 0x0000000108400010
x[4] = 0x0000000108400280 x[5] = 0x0000000000000000 x[6] = 0x000000016aee0000 x[7] = 0x0000000000000001
x[8] = 0x0000000104770000 x[9] = 0x00000001081039d0 x[10] = 0x0000000000000005 x[11] = 0x00000000ffffffff
x[12] = 0x0000000000000000 x[13] = 0xda122256f3c39294 x[14] = 0x0000000000007e01 x[15] = 0x0000000000000006
x[16] = 0x0000000105044a98 x[17] = 0x00000001050840b8 x[18] = 0x0000000000000000 x[19] = 0x0000000108400200
x[20] = 0x0000000000000028 x[21] = 0x000000016b6db360 x[22] = 0x0000000104b9d910 x[23] = 0x000000016b6db3e0
x[24] = 0x0000000108405354 x[25] = 0x000000018bfa62db x[26] = 0x0000000000000000 x[27] = 0x0000000000000000
x[28] = 0x0000000000000000 fp = 0x000000016b6db190 lr = 0x000000010473fff4 sp = 0x000000016b6db120
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (PhysicsSimulation_Debug:arm64+0x10001bff4) in btCollisionDispatcherMt::btCollisionDispatcherMt(btCollisionConfiguration*, int)+0x64
==10700==ABORTING
zsh: abort
Также учтите, что на компьютере установлен чип M3. Я попытался проверить адресную память, но инициализация btCollisionDispatcherMt не удалась. Я не уверен, связано ли это с плохой настройкой Bullet3 в моем коде или с недостающими частями при построении SDK. Обратите внимание, что я создал SDK в режиме двойной точности.
[b]ОБНОВЛЕНИЕ:[/b]
Я выполнил некоторую отладку с использованием lldb и вывод переменной кадра равен nullptr после перехода в новый btCollisionDispatcherMt(collisionConfig):
(lldb) run
Process 12734 launched: '/Users/.../Documents/InternalCode/PlayGround/Bullet/C++/Arena/MT1/build/PhysicsSimulation_Debug' (arm64)
Process 12734 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100003458 PhysicsSimulation_Debug`main at PerformanceTest.cpp:53:41
50 cci.m_defaultMaxPersistentManifoldPoolSize = 10;
51 cci.m_defaultMaxCollisionAlgorithmPoolSize = 10;
52 btCollisionConfiguration* collisionConfig = new btDefaultCollisionConfiguration(cci);
-> 53 btCollisionDispatcher* dispatcher = new btCollisionDispatcherMt(collisionConfig);
54 // btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfig);
55 // dynamicsWorld->setGravity(btVector3(0, -10, 0));
56
Target 0: (PhysicsSimulation_Debug) stopped.
(lldb) frame variable
(btDbvtBroadphase *) broadphase = 0x0000000103503ac0
(btSequentialImpulseConstraintSolverMt *) solver = 0x0000000100203790
(btDefaultCollisionConstructionInfo) cci = {
m_persistentManifoldPool = nullptr
m_collisionAlgorithmPool = nullptr
m_defaultMaxPersistentManifoldPoolSize = 10
m_defaultMaxCollisionAlgorithmPoolSize = 10
m_customCollisionAlgorithmMaxElementSize = 0
m_useEpaPenetrationAlgorithm = 1
}
(btCollisionConfiguration *) collisionConfig = 0x0000000103d03880
(btCollisionDispatcher *) dispatcher = 0x00000000000002c0
(lldb) step
Process 12734 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x00000001006613b4 libBulletCollision.3.26.dylib`btCollisionDispatcherMt::btCollisionDispatcherMt(btCollisionConfiguration*, int) + 108
libBulletCollision.3.26.dylib`btCollisionDispatcherMt::btCollisionDispatcherMt:
-> 0x1006613b4 : ldr x8, [x0]
0x1006613b8 : ldr x8, [x8, #0x18]
0x1006613bc : blr x8
0x1006613c0 : mov x21, x0
Target 0: (PhysicsSimulation_Debug) stopped.
(lldb) frame variable
(lldb)
Подробнее здесь: [url]https://stackoverflow.com/questions/78457421/memory-error-in-multi-threading-mode-of-bullet3-a-simple-example[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия