Exception thrown when initializing ChLinkMotor in debug mode but not in release

36 views
Skip to first unread message

Geoffroy ALEXANDRE

unread,
Jun 29, 2021, 5:49:02 AM6/29/21
to ProjectChrono

Hi,

I'm working on implementing kinematic simulation with Chrono in a CAD software

Using ChronoEngine.dll, I have an issue when debugging my application.

When debugging this simple bit of code (copied from demo_IRR_motors.cpp):

    chrono::ChVector<> positionA2(-3, 2, -2);
    std::shared_ptr<chrono::ChBody> stator2;
    std::shared_ptr<chrono::ChBody> rotor2;
    // Create the motor
    auto rotmotor2 = chrono_types::make_shared<chrono::ChLinkMotorRotationAngle>();
    // Connect the rotor and the stator and add the motor to the system:
    rotmotor2->Initialize(rotor2, stator2, chrono::ChFrame<>(positionA2));

I have an "Access violation reading location 0x000..." in the Initialize function at the last line...
I have no problem when executing the code in release mode however, and the motor seems to behave correctly in the simulation (most of the time).
No issues (in release or debug) with other links in my system (such as ChLinkLockPrismatic for example).

Is it a known issue? Do you have any idea what could possibly cause this on my side?

Thank you,
Geoffroy ALEXANDRE

David Anderson

unread,
Aug 9, 2022, 12:49:40 PM8/9/22
to ProjectChrono
Hi Geoffroy,

I hope that you've already worked this out, but I ran into the same problem and am posting here now in case someone else encounters the problem.

For me, what caused the issue was copying over the Release DLLs for ChronoEngine.dll etc. to my  C:/workspace/my_project_build/Debug folder instead of the Debug dlls/pdbs. These should be located in your  C:/workspace/chrono_build/bin/Debug folder (assuming you compiled both Release and Debug versions of Chrono when you installed, which you should do). Replacing these files allowed me to compile and run in debug mode. This is written up in the tutorial page "Building a Project that uses Chrono" located here under the heading "Important Information for Windows Users", but I found it rather difficult to parse.

Anyway, hope this helps someone!
David
Reply all
Reply to author
Forward
0 new messages