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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Crash (this was nullptr, access violation)

Hello,

I already got some Access Violation but I can't figure out why I get one this one time. On VS Debug I got a this was nullptr error, but I don't use pointer in the method so I don't get why I get it. And on error stacks side, I got an Access Violation.

The problem is here (AC_MovementManager.cpp):

 void UAC_MovementManager::SetMovementMode(const EMovementEnum& NewValue)
 {
     if (MovementMode == NewValue) return; // It crashes here
 
     PrevMovementMode = MovementMode;
     MovementMode = NewValue;
     OnMovementModeChanged();
 }

Here is the previous stack (LabyrinthCharacter.cpp):

 void ALabyrinthCharacter::OnMovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode)
 {
     Super::OnMovementModeChanged(PrevMovementMode, PreviousCustomMode);
 
     if (CharacterMovement->MovementMode == MOVE_Walking || CharacterMovement->MovementMode == MOVE_NavWalking) MovementComponent->SetMovementMode(EMovementEnum::MM_Grounded);
     else if (CharacterMovement->MovementMode == MOVE_Falling) MovementComponent->SetMovementMode(EMovementEnum::MM_Falling);
 }


MovementMode is declared as below (AC_MovementManager.h):

 public:
 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "State Values")
         EMovementEnum MovementMode;

and initialized as EMovementEnum::MM_Grounded in UAC_MovementManager() (constructor).

EMovementEnum is declared (and included) in a separate header as following:

 UENUM(BlueprintType)
 enum class EMovementEnum : uint8
 {
     MM_None UMETA(DisplayName = "None"),
     MM_Grounded UMETA(DisplayName = "Grounded"),
     MM_Falling UMETA(DisplayName = "Falling"),
     MM_Ragdoll UMETA(DisplayName = "Ragdoll")
 };
Product Version: UE 4.20
Tags:
more ▼

asked Aug 28 '18 at 09:30 PM in C++ Programming

avatar image

Ticki84
1 1 1 3

avatar image Shadowriver Aug 28 '18 at 09:55 PM

Move back in call stack and see if "MovementComponent" is not invalid pointer, i case of invalid pointer function may still pass but they may operate on junk data and eventually crash in midway of it

(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