Project Chrono 0xC0000005 Crash - Access violation on vehicle.Initialize() (Custom JSON Loading Issue)

52 views
Skip to first unread message

Emrullah Cebeci

unread,
Nov 10, 2025, 9:39:44 AMNov 10
to ProjectChrono

Hello, I am trying to load a custom vehicle in Project Chrono using JSON files, but I am receiving a 0xC0000005: Access violation (Null Pointer) error that I cannot solve.

The program always crashes when it reaches the vehicle.Initialize(...) line. This indicates that the WheeledVehicle constructor failed, and the vehicle object is being created as a null pointer (nullptr).

I believe the file references in my JSON files and my main.cpp code are correct. My JSON file structure is as follows:   C:/Projects/vehicle_project/data/temp/vehicle/vehicle.json

Here is the relevant section of my main.cpp:

#include "chrono_vehicle/ChVehicleModelData.h"
// ... other includes ...

using namespace chrono;
using namespace chrono::vehicle;

int main() {

    // SetDataPath points to the 'data' directory from the file tree above
    const std::string vehicle_data_path = "C:/Projects/vehicle_project/data";
    chrono::vehicle::SetDataPath(vehicle_data_path);

    // The vehicle JSON is called relative to the 'data' directory
    const std::string vehfile = "temp/vehicle/Vehicle.json";
    WheeledVehicle vehicle(vehfile, ChContactMethod::SMC, false, false);

    // THE ERROR OCCURS ON THIS EXACT LINE
    vehicle.Initialize(ChCoordsys<>(ChVector3d(0, 0, 0.6), QuatFromAngleZ(0)));

    // ... (rest of the code)
}

I would greatly appreciate it if you could tell me what is causing this problem and how to solve it. Thank you.  



Radu Serban

unread,
Nov 11, 2025, 4:23:06 AMNov 11
to ProjectChrono

This kind of issues are difficult to debug without a full working example.

My suspicion is that some JSON file is not found as expected.  Note that the JSON files referenced from the top-level vehicle JSON file must be provided relative to the vehicle data directory.

 

But all of this is not that relevant. Such an issue can *very* easily be identified by building the code in *Debug* mode and stepping through it with a debugger.  Step through each subsystem constructor and ensure that the JSON file it attempts to use is what you expect. Have you done that?

 

Radu

--
You received this message because you are subscribed to the Google Groups "ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectchron...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/projectchrono/4726cd2f-6b05-4bb9-8f99-66708abb54d5n%40googlegroups.com.

Emrullah Cebeci

unread,
Nov 12, 2025, 2:34:32 AMNov 12
to ProjectChrono

Yes, I did what you suggested. When I debugged the code, I noticed that the 'vehicle.json' file could not be read, and the system was returning a null value. I checked the location and content of all other files referenced in the 'vehicle.json' file and could not see any issues.

Initially, I thought the GetDataFile function wasn't returning the correct file directory. However, I encountered the same problem even when I bypassed that function and manually hard-coded the direct path into the code.

To check if the problem was with the JSON files I created, I tried using the standard HMMWV JSON files that come with the Chrono installation, but the issue persisted.


11 Kasım 2025 Salı tarihinde saat 12:23:06 UTC+3 itibarıyla Radu Serban şunları yazdı:
Reply all
Reply to author
Forward
0 new messages