Skip to content

Segmentation fault when unpacking DXT5Crunched texture #214

@na-ji

Description

@na-ji

Code

import os
import UnityPy

env = UnityPy.load("./my_asset_bundle")

for obj in env.objects:
    # process specific object types
    if obj.type.name in ["Texture2D", "Sprite"]:
        # parse the object data
        data = obj.read()

        # create destination path
        dest = os.path.join("./dest", data.name)

        # make sure that the extension is correct
        # you probably only want to do so with images/textures
        dest, _ = os.path.splitext(dest)
        dest = dest + ".png"

        img = data.image
        img.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.

  • Python version: 3.10.6
  • UnityPy version: 1.10.3
  • OS: macos Sonoma 14.0 on M1 Macbook pro

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions