assimp / assimp

The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one unified and clean data structure.
https://www.assimp.org
Other
10.85k stars 2.91k forks source link

Bug: Rapidjson crash when parsing GLTF2 .glb files with MSVC in Release mode only. #5769

Open volcoma opened 1 month ago

volcoma commented 1 month ago

Describe the bug So i am getting crashes during gltf2 json parse when in release mode with latest msvc compiler. I tracked the causing commit to the one that updated rapidjson. I also tested with earlier version of rapidjson and didn't get any crashes. For now i have forked assimp and reverted the rapidjson to an earlier version but this should be fixed or reverted.

Platform (please complete the following information):

volcoma commented 1 week ago

Since that library seems unsupported may i suggest https://github.com/simdjson/simdjson as a faster and safer alternative

tellypresence commented 4 days ago

@volcoma Please provide

volcoma commented 4 days ago

hi it is basically any big model with animations. The one i am testing with is the Dancing Troll glb from the 3D Viewer app which comes with Windows 11 installed. There you can find a library of animated models and export them to glb. The file is 30mb so i cant attach it here. Basically with max optimizations i get the crashes every time, but when i lower the optimization levels a bit for when building assimp seems to not crash any more. Note the only thing i am changing is how i build the assimp library and nothing more

In my cmake file.

if(MSVC)
      #Currently assimp crashes in full release build

    # Remove the /O2 optimization flag from the default Release flags
    string(REPLACE "/O2" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
    string(REPLACE "/O2" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
    # Set lower optimization level for Release mode (for MSVC)
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O1")  # Optimize for size (lower optimization than /O2)
    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O1")

endif()

add_subdirectory( assimp )
tellypresence commented 4 days ago

...I tracked the causing commit to the one that updated rapidjson.

Please provide full url for that commit so others may understand exactly where you are referring to

tellypresence commented 4 days ago

There you can find a library of animated models and export them to glb.

Could the process of exporting to glb be contributing to the issue? Are you able to demonstrate the problem with a simple 3D model that is already available and doesn't require any additional processing?

... with max optimizations i get the crashes every time, but when i lower the optimization levels a bit for when building assimp seems to not crash any more.

It sounds like you think that the level of optimization is affecting rapidjson? Please attach logs of exactly where rapidjson is crashing.

volcoma commented 2 days ago

After pulling latest version i tried to reproduce it and i couldn't, after that i tried again without lowering the optimzation levels and worked fine. Maybe it was a mistake on my end, some misbuild or something. You can close this i am sorry for wasting your time.

volcoma commented 2 days ago

Still my suggestion on using simdjson remains as it is still actively supported and way faster, but requires a newer standard.