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 on if statement

Hello,

I am experiencing a problem in my c++ project. I added a Widget blueprint from another project, and it started crashing and giving me an "Access violation" error. I removed the widget and every reference to it, but the project is still crashing. This happens both in standalone and in selected viewport mode. The bug is reported in my "Inventory" class, which I haven't edited in a while. In the "Diagnostics.txt" file, there is no source code appearing between the [SOURCE START] and the [SOURCE END] tags.

Here is a code sample which causes the probem : uint8 Number = Items.Num(); if (Index >= Number) {

 }
 if (Index >= Number){                         // This line is crashing
     if (EmptyItem->GetTexture() == nullptr) {
         EmptyItem->InitParams(ItemParams);
     }
     return EmptyItem;
 }
 return Items[Index];

This bug is strange, because the line causing the error is caused by the second "if" statement, although it is the same as the first one. I added the first "if" statement to show the strangeness of the bug. I have never seen an error like that while trying to compare two ints. However, if i replace the "Number" local variable by a literal integer (e.g if Index >= 5 ), then the project seems to find an error at the next line instead.

I have been trying to find a solution for the past 3 hours, and the only logical explanations I could find were either corrupted memory, or a corrupted project. I also tried rebooting my pc, and rebuilding the project multiple times, to no avail.

Product Version: UE 4.10
Tags:
more ▼

asked Apr 23 '16 at 08:07 PM in Bug Reports

avatar image

MutualWolf
10 5 6 9

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

2 answers: sort voted first

After trying for a while to understand the problem, I took a backup from 4 days ago, copied all my new code and it now works. I don't know what the problem was, I'll probably at some point compare the two projects, but definitely not now.

more ▼

answered Apr 24 '16 at 06:22 PM

avatar image

MutualWolf
10 5 6 9

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

Something tells me EmptyItem might be null, this is only reason i can see calling on null pointer cause crash so do EmptyItem && EmptyItem->GetTexture() == nullptr. It might pointing wrong line due to buggus PDB files generated by VS compiler, but thats VS bug. Also run without debugging and after crash check the logs Saved/Logs in project directory, if log is cut without any message then i'm 99.9% procent sure EmptyItem is the cause

more ▼

answered Apr 24 '16 at 12:56 AM

avatar image

Shadowriver
35.2k 921 166 1098

avatar image MutualWolf Apr 24 '16 at 01:37 AM

Thank you for the swift response. I added a test to verify that EmptyItem is not null, I even called a function on it before the line causing trouble, but the error still happens on the same line. I added a bit of code to see what caused the error : uint8 Number = Items.Num(); if (EmptyItem) { if (EmptyItem->GetTexture() == nullptr) { //EmptyItem->InitParams(ItemParams); } }

if (Index >= Number){ // This line is crashing

When that 4th line is commented, the error still occurs on the same line as before. However, when i uncomment the 4th line, the error occurs on the 2nd line... I thought the problem was that ItemParams might be null too, but when I added a test for that too, the error moved to the first line. Then, when I removed that one, the error moved to the 2nd line...

I know that sounds very confusing...

avatar image MutualWolf Apr 24 '16 at 01:41 AM
  1. uint8 Number = Items.Num();

  2. if (EmptyItem) {

  3.  if (EmptyItem->GetTexture() == nullptr) {
    
  4.     //EmptyItem->InitParams(ItemParams);
    
  5.  }
    
  6. }

  7. if (Index >= Number){ // This line is crashing

Sorry looks like my indentation has been killed

(comments are locked)
10|2000 characters needed characters left
Your answer
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