Signal 11 (SIGSEGV)

Describe the bug
我在使用 ti.ext_arr()的时候遇到SIGSEGV。在我之前的程式码中,numpy array大小为(1, 3)时没有发生过这个问题。但是当我使用(n, 3)的array时(n <= 3),错误便出现了。错误不固定会出现在什麽时候(但一定会发生),但我的程式没有随机性在裡面。大部分的时候Taichi Compiler Stack Traceback是空的,但有时候会有下面的讯息。

To Reproduce

@ti.kernel
def substep(g: ti.f32, mass: ti.f32, is_collision: ti.i32, normal: ti.ext_arr(), dis: ti.ext_arr(), number: ti.i32, dir:ti.f32, new_p: ti.ext_arr(), new_v: ti.ext_arr(), r_fs: ti.ext_arr(), pivots: ti.ext_arr()):
    for i in ti.grouped(p):
        p[i] = ti.Vector([new_p[0],new_p[1],new_p[2]])
        v[i] = ti.Vector([new_v[0],new_v[1],new_v[2]])
        acc[i] = g * mass * ti.Vector([0.0, -1, 0.0])
        if number > 0:
            for j in range(number):
                I = r_fs[j] * mass
                f = (3200 * mass * dir * dis[j])/number * ti.Vector([normal[j, 0], normal[j, 1], normal[j, 2]])
                torque = r_fs[j] * f
                acc[i] += (3200 * mass * dir * dis[j])/number * ti.Vector([normal[j, 0], normal[j, 1], normal[j, 2]])
        acc[i] /= mass
        v[i] += acc[i] * dt
        p[i] += dt * v[i]
            normals = np.empty((len(collisions[tmodel]), 3), np.float32)
            distances = np.empty((len(collisions[tmodel])), np.float32)
            pivots = np.empty((len(collisions[tmodel]), 3), np.float32)
            r_fs = np.empty((len(collisions[tmodel])), np.float32)
            if len(collisions[tmodel]) == 0:
                normals = np.zeros((3), np.float32)
                pivots = np.zeros((3), np.float32)
            for i in range(len(collisions[tmodel])):
                normals[i] = collisions[tmodel][i].normal
                distances[i] = float(collisions[tmodel][i].depth)
                r_fs[i] = float(collisions[tmodel][i].r_f)
                pivots[i] = collisions[tmodel][i].pivot
            substep(gravity, float(formula.mass), is_collision, normals, distances, len(collisions[tmodel]), float(direction),new_p,new_v,r_fs,pivots)
PS E:\taichi_three-master> & C:/Users/KuPao/AppData/Local/Programs/Python/Python37/python.exe e:/taichi_three-master/examples/cylinder_test.py
[Tina] version 0.1.1
[Taichi] mode=release
[Taichi] version 0.7.14, llvm 10.0.0, commit 58feee37, win, python 3.7.6
[Tina] Taichi properties hacked
[Taichi] Starting on arch=cuda
[Tina] Hint: MMB to orbit, Shift+MMB to pan, wheel to zoom
[Taichi] materializing...
[Tina] Cooking skybox (1024x512 128 spp)...
[Tina] Baking IBL map (170x85 4096 spp) for Lambert...
[Tina] Denoising IBL map with KNN for Lambert...
[Tina] Baking IBL map for Lambert done
[Tina] Baking IBL map (820x410 292 spp) for CookTorrance with roughness 0.08...
[Tina] Baking IBL map (620x310 363 spp) for CookTorrance with roughness 0.18...
[Tina] Baking IBL map (386x193 563 spp) for CookTorrance with roughness 0.35...
[Tina] Baking IBL map (168x84 1188 spp) for CookTorrance with roughness 0.65...
[Tina] Baking IBL map (62x31 4439 spp) for CookTorrance with roughness 1.0...
[Tina] Baking IBL map for CookTorrance done
[E 10/07/21 14:02:04.206] Received signal 11 (SIGSEGV)


***********************************
* Taichi Compiler Stack Traceback *
***********************************
0x7ffeb35be277: taichi::create_instance_placement<taichi::Benchmark> in taichi_core.pyd
0x7ffeb3676d13: taichi::create_instance_placement<taichi::Benchmark> in taichi_core.pyd
0x7ffeb367da82: taichi::create_instance_placement<taichi::Benchmark> in taichi_core.pyd
0x7fff23b50ef5: seh_filter_exe in ucrtbase.dll
0x7ff66f4223d8: Unknown Function in python.exe
0x7fff173cc720: _C_specific_handler in VCRUNTIME140.dll
0x7fff2641217f: _chkstk in ntdll.dll
0x7fff263c1454: RtlRaiseException in ntdll.dll
0x7fff26410cae: KiUserExceptionDispatcher in ntdll.dll
0x7fff2639e414: RtlAllocateHeap in ntdll.dll
0x7fff2639b44d: RtlAllocateHeap in ntdll.dll
0x7fff23aefde6: malloc_base in ucrtbase.dll
0x7ffeb546a6eb: taichi::create_instance_placement<taichi::Benchmark> in taichi_core.pyd
0x7ffeb337ec45: taichi::create_instance_placement<taichi::Benchmark> in taichi_core.pyd
0x7ffeb3661aba: taichi::create_instance_placement<taichi::Benchmark> in taichi_core.pyd
0x7ffeb35a0968: taichi::create_instance_placement<taichi::Benchmark> in taichi_core.pyd
0x7ffeb359929f: taichi::create_instance_placement<taichi::Benchmark> in taichi_core.pyd
0x7ffeb358d116: taichi::create_instance_placement<taichi::Benchmark> in taichi_core.pyd
0x7ffeb3406772: taichi::create_instance_placement<taichi::Benchmark> in taichi_core.pyd
0x7ffee7a68c55: PyMethodDef_RawFastCallKeywords in python37.dll
0x7ffee7a7a96e: PyCFunction_FastCallKeywords in python37.dll
0x7ffee7a695fe: PyMethodDef_RawFastCallKeywords in python37.dll
0x7ffee7a69fe2: PyEval_EvalFrameDefault in python37.dll
0x7ffee7a51766: PyEval_EvalCodeWithName in python37.dll
0x7ffee7a513ea: PyFunction_FastCallDict in python37.dll
0x7ffee7a5039a: PyMethodDef_RawFastCallDict in python37.dll
0x7ffee7a4d6ac: PyObject_SetAttr in python37.dll
0x7ffee7a6a8a5: PyEval_EvalFrameDefault in python37.dll
0x7ffee7a51766: PyEval_EvalCodeWithName in python37.dll
0x7ffee7a695cc: PyMethodDef_RawFastCallKeywords in python37.dll
0x7ffee7a69b33: PyEval_EvalFrameDefault in python37.dll
0x7ffee7a51766: PyEval_EvalCodeWithName in python37.dll
0x7ffee7a23637: PyEval_EvalCodeEx in python37.dll
0x7ffee7a23595: PyEval_EvalCode in python37.dll
0x7ffee7a2353f: PyArena_Free in python37.dll
0x7ffee7bc525d: PyRun_FileExFlags in python37.dll
0x7ffee7bc5a84: PyRun_SimpleFileExFlags in python37.dll
0x7ffee7bc512b: PyRun_AnyFileExFlags in python37.dll
0x7ffee7b11047: Py_UnixMain in python37.dll
0x7ffee7b110ef: Py_UnixMain in python37.dll
0x7ffee7a80b02: PyErr_NoMemory in python37.dll
0x7ffee7a21077: Py_Main in python37.dll
0x7ffee7a21052: Py_Main in python37.dll
0x7ff66f421258: Unknown Function in python.exe
0x7fff24757034: BaseThreadInitThunk in KERNEL32.DLL
0x7fff263c2651: RtlUserThreadStart in ntdll.dll

Internal error occurred. Check out this page for possible solutions:
https://taichi.readthedocs.io/en/stable/install.html#troubleshooting

你好,欢迎来到Taichi社区!我尝试去复现问题,但是代码好像没给全,方便给一份完整的代码供调试吗? :slightly_smiling_face:

目前的信息确实很难看出问题出在哪儿,可以贴一下完整代码链接。

除此之外给你一些建议,你先尝试一下

  1. 升级Taichi版本到0.8.2(目前最新)
  2. ti.kernel的参数在OpenGL和CC后端有参数个数限制,你可以把参数个数减少到<8个,然后尝试一下。