I've just fixed it. The whole problem was the dynamic allocation of page tables on non-mapped addresses. My solution was to make an array with as big as all the possible page tables + the page directory. It's not clean, but it works