You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segmentation fault when unpacking DXT5Crunched texture #214
importosimportUnityPyenv=UnityPy.load("./my_asset_bundle")
forobjinenv.objects:
# process specific object typesifobj.type.namein ["Texture2D", "Sprite"]:
# parse the object datadata=obj.read()
# create destination pathdest=os.path.join("./dest", data.name)
# make sure that the extension is correct# you probably only want to do so with images/texturesdest, _=os.path.splitext(dest)
dest=dest+".png"img=data.imageimg.save(dest)
Error
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
This error is happening on the line img = data.image
Bug
The image should be read successfully without crashing the whole script. When I checked m_TextureFormat attribute, the returned value was 29. I've tried with others tools like AssetRipper, and they can extract everything without issue. Also, I tried to disable the C-typetree reader, but the segmentation fault is still occurring.
To Reproduce my_asset_bundle.zip
I zipped the file to make GitHub accepts it. You need to unzip it first.
This is a bit tricky to fix, as this is one of the kinds of segfaults that are a bit random and happen only under hard to reproduce conditions. (Or in other words, I can't reproduce the issue, but I see that it could happen due to potato code in dependencies)
I've asked a colleague to test on his PC, and for him everything worked. He is on Windows while I'm on an M1 MacBook Pro. The difference might come from different OS + different architecture (arm vs amd).
I will try to debug ASAP to tell you from which line it's coming.
PS: Sorry for the delay, I didn't get any notification.
And, well, this is pretty troublesome then, because the de-crunching is pure Unity code, so bug hunting it will be a nightmare.
The only "simple" solution would be making a python wrapper for the Rust rewrite of the texture2ddecoder, which includes a rewrite of the crunch code. This version is memory safe for sure.
It might take some time until I come around to this though.
Activity
K0lb3 commentedon Oct 22, 2023
This is a bit tricky to fix, as this is one of the kinds of segfaults that are a bit random and happen only under hard to reproduce conditions. (Or in other words, I can't reproduce the issue, but I see that it could happen due to potato code in dependencies)
Can you check where the segfault happens specifically, during de-crunching or during the texture parsing by PIL?
na-ji commentedon Nov 6, 2023
I've asked a colleague to test on his PC, and for him everything worked. He is on Windows while I'm on an M1 MacBook Pro. The difference might come from different OS + different architecture (arm vs amd).
I will try to debug ASAP to tell you from which line it's coming.
PS: Sorry for the delay, I didn't get any notification.
na-ji commentedon Nov 6, 2023
The segfault happens during de-crunching on this line
UnityPy/UnityPy/export/Texture2DConverter.py
Line 128 in 99c240c
K0lb3 commentedon Nov 10, 2023
Thanks for the info.
And, well, this is pretty troublesome then, because the de-crunching is pure Unity code, so bug hunting it will be a nightmare.
The only "simple" solution would be making a python wrapper for the Rust rewrite of the texture2ddecoder, which includes a rewrite of the crunch code. This version is memory safe for sure.
It might take some time until I come around to this though.
K0lb3 commentedon Nov 22, 2023
Finished soon™️

Render Fort: bump texture2ddecoder to 1.0.6, drop decode blacklist