x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Access violation crashes when using third party library code.

Hey all,

Some background information first.

I'm currently trying to write a c++ class that can parse a file and generate a tree structure from it that I will be able to use for Inverse Kinematics. To do this I'm making use of some ROS libraries that are able to incorporate the functionality that I need, namely urdf and kdl.

I've managed to link the libraries into the build system through following the instructions here https://wiki.unrealengine.com/Linking_Static_Libraries_Using_The_Build_System

My class can now recognize the structures that I want to make use of, and compiles successfully, but unfortunately Unreal crashes when I try to stop it running,

The code below is from my c++ file, and the issue seems to revolve around garbage collection of my urdf model, as it manages to successfully parse the file only to crash on stopping.

    #include "AIKTester.h"
     #include "Runtime/Core/Public/Misc/Paths.h"
     #include "Runtime/Core/Public/HAL/FileManager.h"
     #include <string>
     
     // Sets default values
     AAIKTester::AAIKTester()
     {
          // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
         PrimaryActorTick.bCanEverTick = true;
     
     }
     
     // Called when the game starts or when spawned
     void AAIKTester::BeginPlay()
     {
         Super::BeginPlay();
         urdfParser();
     }
     
     // Called every frame
     void AAIKTester::Tick(float DeltaTime)
     {
         Super::Tick(DeltaTime);
     
     }
     
     bool AAIKTester::urdfParser()
     {
         // Grab relative project path for file system and convert to string
         FString RelativeProjPath = FPaths::ProjectDir();
         std::string ProjPath(TCHAR_TO_UTF8(*RelativeProjPath));
     
         // Try parse urdf file into model using relative project path and urdf file location
         if (!my_model.initFile(ProjPath + "Source/Project/robot.urdf")) {
             UE_LOG(LogTemp, Log, TEXT("Failed to parse urdf file"));
             return false;
         }
         else {
             UE_LOG(LogTemp, Log, TEXT("Parsed the urdf file"));
             return true;
         }
     }

And here is the included header file:

 #pragma once
 
 #include "CoreMinimal.h"
 #include "GameFramework/Actor.h"
 #include "../../ThirdParty/ROS2/Includes/urdf/model.h"
 #include "../../ThirdParty/ROS2/Includes/kdl/tree.hpp"
 #include "../../ThirdParty/ROS2/Includes/kdl_parser/kdl_parser.hpp"
 #include "AIKTester.generated.h"
 
 
 UCLASS()
 class PROJECT_API AAIKTester : public AActor
 {
     GENERATED_BODY()
     
 public:    
     // Sets default values for this actor's properties
     AAIKTester();
 
 protected:
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
 
 public:    
     // Called every frame
     virtual void Tick(float DeltaTime) override;
 
     urdf::Model my_model;
     bool urdfParser();
 };

I've tried to get my head around the call stack, but unfortunately I can't get any clarity about how to solve this problem. The error code and call stack seem to change every other time running it, most recently displaying:

Exception thrown at 0x00007FF80FEE731E (nvwgf2umx.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

Any help would be greatly appreciated, thanks.

Product Version: UE 4.18
Tags:
more ▼

asked Mar 27 '18 at 08:33 PM in C++ Programming

avatar image

bradmatt
1 1 1

avatar image vijaykam Apr 02 '18 at 05:18 PM

Hello bradmatt,

I am having a similar issue with Unreal crashing when a 3rd party DLL is incorporated. Were you able to resolve it? I am stumped.

avatar image bradmatt Apr 02 '18 at 05:39 PM

Hi,

Unfortunately not. The issue in my case seems to be linked to how Unreal handles the garbage collection of UClasses, and it not being able to delete the objects created through the 3rd party library.

I've not spent any more time looking at the issue as of late, so haven't made any progress past that point yet. I may have another look if time permits.

avatar image vijaykam Apr 02 '18 at 07:09 PM

Hi, I managed to "discover" a resolution to my issue - might be useful to you as well. Apparently, third party libraries (DLLs) can only work if they are compiled in release configuration - i.e. no debug info present. I was compiling my DLL in debug mode. With one line change in CMakeLists.txt "set(CMAKE_BUILD_TYPE Release)", I was able to resolve all my issues! This site helped: http://www.valentinkraft.de/including-the-point-cloud-library-into-unreal-tutorial/

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question