Bug - Fixed Null pointer exceptions after upgrading to KoLmafia-19794M.jar

Ethelred

Member
I started getting null pointer expections from BatBrain, I think, after upgrading from KoLmafia-19790M.jar to KoLmafia-19794.ash. I don't know if the problem is from mafia or BatBrain, but they stopped happening after I downgraded. I've attached a debug log.
 

Attachments

  • DEBUG_20200302.txt
    31.3 KB · Views: 9

fronobulax

Developer
Staff member
Minor nit - the suffix M suggests you are building your own jar and you have local modifications. At some point you may be asked about your modifications.

I did not see anything like this with 19792. Looking at the commit messages, I might wonder if 19794 is a factor?

It will be about 12 hours before I can get a chance to look at this so if anyone else does, thank you.
 

Malibu Stacey

Active member
I got the same, renamed the offending file (data/BatMan_happenings_YOUR-USERNAME.txt) and it fixed after recreating the file.

Also I've never had a custom mafia build but I am running r19794. In super-long aftercore as DB (ascension was HC AoSP over a year ago now).
 

Veracity

Developer
Staff member
This report says the error is in BatMan at line 2249:

Code:
   map_to_file(happenings,"BatMan_happenings_"+replace_string(my_name()," ","_")+".txt");   // do this here (once) rather than in set_happened()
happenings is a map with 4 indices. It looks like this:

Code:
boolean[monster, int, string, int] happenings;  // m, lastCombatStarted, action id, round => playeraction
file_to_map("BatMan_happenings_"+replace_string(my_name()," ","_")+".txt",happenings);
So, if there is an error reading in the previous data with file_to_map() such that a null is placed in the structure, then line 119 in CompositeVale.java:

Code:
			value.dump( writer, first, compact );
Will throw the NPE you reported.

I am suspicious about the "monster" argument. Did I, somehow, make some particular monster be unparseable, such that it returns a null, rather than a monster object?

Could I see your BatMan_happenings_YOUR_NAME.txt file, please?
 

zarqon

Well-known member
I'm getting these as well. My happenings file attached below. I'll do some poking myself -- I'd rather not lose all my combat history by nuking the file since I frequently make use of BatMan RE's "submit previous combat vs. this monster" macro button.
 

Attachments

  • BatMan_happenings_zarqon.txt
    330.9 KB · Views: 4

Veracity

Developer
Staff member
Thank you. I will track this down.

happenings.ash:

Code:
boolean[monster, int, string, int] happenings;  // m, lastCombatStarted, action id, round => playeraction

string infile = "BatMan_happenings_zarqon.txt";
file_to_map( infile, happenings );

string outfile = "test-happenings.txt";
map_to_file( happenings, outfile );
yields:

Code:
[color=green]> happenings.ash[/color]

Unexpected error, debug log printed.
[color=red]Script execution aborted (java.lang.NullPointerException): (happenings.ash, line 7)[/color]
 

Veracity

Developer
Staff member
Yeah, a misguided 2-character change. The issue showed up with Ed the Undying (1) - which has a monster ID of 0.
With revision 19795:

Code:
boolean[monster, int, string, int] happenings;  // m, lastCombatStarted, action id, round => playeraction

string infile = "BatMan_happenings_zarqon.txt";
file_to_map( infile, happenings );

foreach m, lastCombatStarted, id, round, val in happenings {
    if ( m == $monster[ Ed the Undying (1) ] ) {
	print( m + " " + lastCombatStarted + " " + id + " " +  round + " => " + val );
    }
}

string outfile = "test-happenings.txt";
map_to_file( happenings, outfile );

Code:
[color=green]> happenings[/color]

Ed the Undying (1) 20200214164326 crit 3 => false
Ed the Undying (1) 20200214164326 skill 1032 2 => true
Ed the Undying (1) 20200214164326 skill 1032 3 => true
Ed the Undying (1) 20200214164326 skill 7297 1 => true
Ed the Undying (1) 20200214164326 win 3 => false
Ed the Undying (1) 20200214164326 win 4 => false
Ed the Undying (1) 20200218173432 attack 2 => true
Ed the Undying (1) 20200218173432 attack 3 => true
Ed the Undying (1) 20200218173432 crit 3 => false
Ed the Undying (1) 20200218173432 skill 7297 1 => true
Ed the Undying (1) 20200218173432 win 3 => false
Ed the Undying (1) 20200218173432 win 4 => false
Ed the Undying (1) 20200302152701 attack 2 => true
Ed the Undying (1) 20200302152701 attack 3 => true
Ed the Undying (1) 20200302152701 crit 3 => false
Ed the Undying (1) 20200302152701 skill 7297 1 => true
Ed the Undying (1) 20200302152701 win 3 => false
Ed the Undying (1) 20200302152701 win 4 => false
After I converted your file to have Unix line breaks (like my OS uses):

Code:
bash-3.2$ ls -l BatMan_happenings_zarqon.txt test-happenings.txt
-rw-r--r--  1 me  staff  331711 Mar  3 03:03 BatMan_happenings_zarqon.txt
-rw-r--r--  1 me  staff  331711 Mar  3 02:53 test-happenings.txt
bash-3.2$ diff BatMan_happenings_zarqon.txt test-happenings.txt
bash-3.2$
 

zarqon

Well-known member
Excellent, thank you! I only got as far as determining the error occurred even after loading everything in as strings, performing various verification checks, then converting to monster and attempting to save the map.
 

Ethelred

Member
KoLmafia-19795M.jar fixed the problem for me. Things ran fine today. Thanks for the prompt fix and all the work you do keeping mafia alive and humming.
 
Top