I did not find a bug in bmap_process, but I found one in effect_load. This command:

effect_load(mat,name)

should not get a pointer to mat->effect as second parameter. So if you want to reload the effect, store the name in a string or copy it to a char array and pass the copy. This is probably the reason of the errors in your screenshots.