Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault in async wrap, if shape has emitter AND bsdf #843

Open
georgy95 opened this issue Aug 7, 2023 · 0 comments
Open

Segmentation fault in async wrap, if shape has emitter AND bsdf #843

georgy95 opened this issue Aug 7, 2023 · 0 comments

Comments

@georgy95
Copy link

georgy95 commented Aug 7, 2023

Summary

I mainly write asynchronous code, and discovered a bug that results in a segmentation fault.

When a shape has:

  • emitter only - works is fine
  • bsdf only - works fine
  • BOTH - results in a segmentation fault in async wrap only.

System configuration

System information:

OS: 13.2.1
CPU: b'Apple M1'
Python: 3.10.1 (main, Mar 24 2023, 21:25:11) [Clang 14.0.0 (clang-1400.0.29.202)]
LLVM: 16.0.6

Dr.Jit: 0.4.2
Mitsuba: 3.3.0
Is custom build? False
Compiled with: AppleClang 14.0.0.14000029
Variants:
scalar_rgb
scalar_spectral
llvm_ad_rgb

Description

I'd like to be able to render in a non blocking IO way. Currently the scene processes fine if I specify either the emitter or bsdf for the shape. I'm curious why the segmentation fault arises, because it works as expected in sync mode.

Also, I used asyncer library, which seems to work, but can also be the culprit here.

Steps to reproduce

The code below should work as is if you:

  • Create the shape
  • Provide a path to any image

shape.obj

v  1 -1 -1
v  1  1 -1
v -1  1 -1
v -1 -1 -1
vt 1 0
vt 1 1
vt 0 1
vt 0 0
vn 0 0 1
f 1/1/1 2/2/1 3/3/1 4/4/1

code.py

import mitsuba as mi
mi.set_variant("scalar_rgb")

import anyio
from asyncer import asyncify

PATH_TO_OBJ = ""
PATH_TO_BM = ""

scene = {
    'bsdf_id': {'type': 'diffuse', 'reflectance': {'type': 'rgb', 'value': [0.1, 0.1, 0.1]}},
    "type": "scene",
    "integrator": {
            "type": "path",
            "max_depth": 20,
            "rr_depth": 5,
        },
        "sensor": {
        "type": "perspective",
        "to_world": mi.ScalarTransform4f.look_at(
                    origin=[0,0,4],
                    target=[0,0,0],
                    up=[0,1,0]
                    ),
        "fov": 40,
        'sampler': {
            'type': 'independent',
            'sample_count': 128
        },
        'film': {
            'type': 'hdrfilm',
            'width': 256,
            'height': 256,
            'rfilter': {
                'type': 'box',
            },
            'pixel_format': 'rgb',
        },
    },
    "texture_id": {
        "type": "bitmap",
        "bitmap": mi.Bitmap(PATH_TO_BM),
        "wrap_mode": "clamp",
        "filter_type": "nearest"
    },
    "backwall": {
        "type": "obj",
        "filename": PATH_TO_OBJ,
        "light": {
            "type": "area",
            "radiance": {
                "type": "ref",
                "id": "texture_id"
            }
        },
        "bsdf": {
            "type": "ref",
            "id": "bsdf_id"
        }
    },
    "env": {
        'type': 'constant',
        'radiance': {
            "type": "rgb",
            "value": 1.0
        }
    },
}

scene = mi.load_dict(scene)

async def main():
    await asyncify(mi.render)(scene, sensor=0, spp=10)

anyio.run(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant