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

segfault in cube example #13

Open
WebFreak001 opened this issue Feb 2, 2021 · 1 comment · Fixed by #26
Open

segfault in cube example #13

WebFreak001 opened this issue Feb 2, 2021 · 1 comment · Fixed by #26
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@WebFreak001
Copy link

I'm trying to run the cube example on linux, I built the libglfw3.a from the zip source file and placed it where dub expects it.

Upon running (compiled with DMD) it segfaults and investigation with GDB shows:

Starting program: /home/webfreak/dev/teraflop-d/bin/teraflop_cube 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Teraflop Cube Example
22:23:06.263  WARN: GFX-VK Optional layer VK_LAYER_LUNARG_core_validation is not present and won't be enabled
22:23:06.263  WARN: GFX-VK Optional layer VK_LAYER_LUNARG_standard_validation is not present and won't be enabled
22:23:06.263  WARN: GFX-VK Optional layer VK_LAYER_LUNARG_parameter_validation is not present and won't be enabled
22:23:06.263  WARN: GFX-VK Optional layer VK_LAYER_GOOGLE_threading is not present and won't be enabled
22:23:06.263  WARN: GFX-VK Optional layer VK_LAYER_LUNARG_object_tracker is not present and won't be enabled
22:23:06.263  WARN: GFX-VK Optional layer VK_LAYER_GOOGLE_unique_objects is not present and won't be enabled
22:23:06.263  WARN: GFX-VK Optional extension VK_KHR_debug_report is not present and won't be enabled
22:23:06.263  INFO: GFX-VK Opening Vulkan instance.
22:23:06.263  INFO: GFX-VK Vulkan layers:
22:23:06.263  INFO: GFX-VK     VK_LAYER_KHRONOS_validation
22:23:06.263  INFO: GFX-VK Vulkan extensions:
22:23:06.263  INFO: GFX-VK     VK_KHR_surface
22:23:06.263  INFO: GFX-VK     VK_KHR_xcb_surface
22:23:06.263  INFO: GFX-VK     VK_EXT_debug_report
[New Thread 0x7fffed9d0640 (LWP 77461)]
[New Thread 0x7fffe51cf640 (LWP 77462)]
[New Thread 0x7fffed1cf640 (LWP 77463)]
[New Thread 0x7fffec9ce640 (LWP 77464)]
[New Thread 0x7fffe7fff640 (LWP 77465)]


Thread 1 "teraflop_cube" received signal SIGSEGV, Segmentation fault.
[----------------------------------registers-----------------------------------]
RAX: 0x360 
RBX: 0x7ffff7937730 --> 0x555555af1ae8 --> 0x555555af1ac8 --> 0x555555ae14c0 --> 0x555555b12b10 --> 0x555555b12a60 (0x0000555555b12b10)
RCX: 0x360 
RDX: 0x7fffec109000 
RSI: 0x7ffff7933c00 --> 0xbf800000bf800000 
RDI: 0x7fffec109000 
RBP: 0x7fffffffd340 --> 0x7fffffffd4e0 --> 0x7fffffffd6d0 --> 0x7fffffffd8e0 --> 0x7fffffffdbc0 --> 0x7fffffffdbe0 (--> ...)
RSP: 0x7fffffffd2b0 --> 0x7ffff7937730 --> 0x555555af1ae8 --> 0x555555af1ac8 --> 0x555555ae14c0 --> 0x555555b12b10 (--> ...)
RIP: 0x55555586e026 (<_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+494>: rep movs BYTE PTR es:[rdi],BYTE PTR ds:[rsi])
R8 : 0x0 
R9 : 0x360 
R10: 0x360 
R11: 0x7fffec109360 
R12: 0x7fffffffde30 --> 0x0 
R13: 0x7fffffffdcff --> 0x200 
R14: 0x1 
R15: 0x1
EFLAGS: 0x10206 (carry PARITY adjust zero sign trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
   0x55555586e01e <_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+486>:    mov    rdi,rdx
   0x55555586e021 <_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+489>:    test   rcx,rcx
   0x55555586e024 <_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+492>:    je     0x55555586e028 <_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+496>
=> 0x55555586e026 <_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+494>:    rep movs BYTE PTR es:[rdi],BYTE PTR ds:[rsi]
   0x55555586e028 <_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+496>:    mov    rax,QWORD PTR [rbp-0x20]
   0x55555586e02c <_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+500>:    mov    QWORD PTR [rbp-0x30],rax
   0x55555586e030 <_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+504>:    cmp    rax,QWORD PTR [rbp-0x78]
   0x55555586e034 <_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+508>:    jae    0x55555586e051 <_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+537>
[------------------------------------stack-------------------------------------]
0000| 0x7fffffffd2b0 --> 0x7ffff7937730 --> 0x555555af1ae8 --> 0x555555af1ac8 --> 0x555555ae14c0 --> 0x555555b12b10 (--> ...)
0008| 0x7fffffffd2b8 --> 0x1 
0016| 0x7fffffffd2c0 --> 0x360 
0024| 0x7fffffffd2c8 --> 0x360 
0032| 0x7fffffffd2d0 --> 0x7fffffffd200 --> 0x220000000022 ('"')
0040| 0x7fffffffd2d8 --> 0x7ffff7936000 --> 0x555555afcfa0 --> 0x555555afcee0 --> 0x555555b12b10 --> 0x555555b12a60 (0x0000555555b12b10)
0048| 0x7fffffffd2e0 --> 0x220000000022 ('"')
0056| 0x7fffffffd2e8 --> 0x5555560b2e40 --> 0x555555fc9680 --> 0x7fffee4bcdb0 (<vkGetDeviceProcAddr(VkDevice, char const*)>:    jmp    0x7fffee4bca10 <_ZN20vulkan_layer_chassis17GetDeviceProcAddrEP10VkDevice_TPKc>)
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
Stopped reason: SIGSEGV
0x000055555586e026 in std.algorithm.mutation.copy!(const(ubyte)[], ubyte[]).copy(const(ubyte)[], ubyte[]) (target=..., source=...) at /usr/include/dlang/dmd/std/algorithm/mutation.d:392
392                 target[0 .. slen] = source[];
gdb-peda$ bt
#0  0x000055555586e026 in std.algorithm.mutation.copy!(const(ubyte)[], ubyte[]).copy(const(ubyte)[], ubyte[]) (target=..., source=...) at /usr/include/dlang/dmd/std/algorithm/mutation.d:392
#1  0x00005555558bfcfd in teraflop.graphics.MeshBase.initialize(scope gfx.graal.device.Device) (this=0x7ffff7937700, device=0x7ffff7927318) at source/teraflop/graphics/package.d:251
#2  0x00005555558da93b in teraflop.systems.ResourceInitializer.run() (this=0x7ffff792f9c0) at source/teraflop/systems/package.d:31
#3  0x000055555588e9b1 in teraflop.game.Game.update() (this=0x7ffff792d100) at source/teraflop/game.d:301
#4  0x000055555588d035 in teraflop.game.Game.run() (this=0x7ffff792d100) at source/teraflop/game.d:151
#5  0x000055555586bfb8 in D main () at examples/cube/source/app.d:13
#6  0x00005555559b972b in rt.dmain2._d_run_main2(char[][], ulong, extern(C) int(char[][]) function).runAll().__lambda1() ()
#7  0x00005555559b95cc in rt.dmain2._d_run_main2(char[][], ulong, extern(C) int(char[][]) function).tryExec(scope void() delegate) ()
#8  0x00005555559b96a7 in rt.dmain2._d_run_main2(char[][], ulong, extern(C) int(char[][]) function).runAll() ()
#9  0x00005555559b95cc in rt.dmain2._d_run_main2(char[][], ulong, extern(C) int(char[][]) function).tryExec(scope void() delegate) ()
#10 0x00005555559b9528 in _d_run_main2 ()
#11 0x00005555559b9282 in _d_run_main ()
#12 0x000055555586cdea in main (argc=0x1, argv=0x7fffffffdfa8) at /usr/include/dlang/dmd/core/internal/entrypoint.d:29
#13 0x00007ffff7a8b152 in __libc_start_main () from /usr/lib/libc.so.6
#14 0x000055555586bd8e in _start ()
gdb-peda$ p target
$1 = <error reading variable>
gdb-peda$ p source
$2 = "\000\000\200\277\000\000\200\277\000\000\200?\000\000\000\000\000\000\000\000\000\000\200?\000\000\200?\000\000\000\000\000\000\200?\000\000\200?\000\000\200\277\000\000\200?\000\000\000\000\000\000\000\000\000\000\200?\000\000\200?\000\000\000\000\000\000\200?\000\000\200?\000\000\200?\000\000\200?\000\000\000\000\000\000\000\000\000\000\200?\000\000\200?\000\000\000\000\000\000\200?\000\000\200\277\000\000\200?\000\000\200?\000\000\000\000\000\000\000\000\000\000\200?\000\000\200?\000\000\000\000\000\000\200?\000\000\200?\000\000\200\277\000\000\200\277\000\000\000\000\000\000\000\000\000\000\200\277\000\000\200?\000\000\000\000\000\000\200?\000\000\200\277\000\000\200\277\000\000\200\277\000\000\000\000\000\000\000\000\000\000"...
gdb-peda$ p this
No symbol "this" in current context.

When compiled with LDC this is the GDB log:

Starting program: /home/webfreak/dev/teraflop-d/bin/teraflop_cube 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Teraflop Cube Example
22:26:56.791  WARN: GFX-VK Optional layer VK_LAYER_LUNARG_core_validation is not present and won't be enabled
22:26:56.791  WARN: GFX-VK Optional layer VK_LAYER_LUNARG_standard_validation is not present and won't be enabled
22:26:56.791  WARN: GFX-VK Optional layer VK_LAYER_LUNARG_parameter_validation is not present and won't be enabled
22:26:56.791  WARN: GFX-VK Optional layer VK_LAYER_GOOGLE_threading is not present and won't be enabled
22:26:56.791  WARN: GFX-VK Optional layer VK_LAYER_LUNARG_object_tracker is not present and won't be enabled
22:26:56.791  WARN: GFX-VK Optional layer VK_LAYER_GOOGLE_unique_objects is not present and won't be enabled
22:26:56.791  WARN: GFX-VK Optional extension VK_KHR_debug_report is not present and won't be enabled
22:26:56.791  INFO: GFX-VK Opening Vulkan instance.
22:26:56.791  INFO: GFX-VK Vulkan layers:
22:26:56.791  INFO: GFX-VK     VK_LAYER_KHRONOS_validation
22:26:56.791  INFO: GFX-VK Vulkan extensions:
22:26:56.791  INFO: GFX-VK     VK_KHR_surface
22:26:56.791  INFO: GFX-VK     VK_KHR_xcb_surface
22:26:56.791  INFO: GFX-VK     VK_EXT_debug_report
[New Thread 0x7fffed41a640 (LWP 78676)]
[New Thread 0x7fffe7fff640 (LWP 78677)]
[New Thread 0x7fffecc19640 (LWP 78678)]
[New Thread 0x7fffe77fe640 (LWP 78679)]
[New Thread 0x7fffe6ffd640 (LWP 78681)]

Thread 1 "teraflop_cube" received signal SIGSEGV, Segmentation fault.
[----------------------------------registers-----------------------------------]
RAX: 0x7fffec354000 
RBX: 0x7fffffffdde0 --> 0x1 
RCX: 0x7fffec354340 
RDX: 0x2c0 
RSI: 0x7ffff737d8a0 --> 0xbf80000000000000 
RDI: 0x7fffec354020 
RBP: 0x7fffffffd610 --> 0x7fffffffd770 --> 0x7fffffffd880 --> 0x7fffffffda00 --> 0x7fffffffdd00 --> 0x7fffffffdd20 (--> ...)
RSP: 0x7fffffffd538 --> 0x555555625861 (<_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+593>:      mov    rax,QWORD PTR [rbp-0x90])
RIP: 0x7ffff7658c56 (<__memmove_avx_unaligned_erms+470>:        vmovdqa YMMWORD PTR [rdi],ymm0)
R8 : 0xffffffffffffffe0 
R9 : 0x1 
R10: 0x22 ('"')
R11: 0x7fffec354000 
R12: 0x2f ('/')
R13: 0x7fffffffe2df ("/home/webfreak/dev/teraflop-d/bin/teraflop_cube")
R14: 0x7fffffffddaf --> 0x21000 
R15: 0x1
EFLAGS: 0x10206 (carry PARITY adjust zero sign trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
   0x7ffff7658c43 <__memmove_avx_unaligned_erms+451>:   vmovdqu ymm3,YMMWORD PTR [rsi+0x60]
   0x7ffff7658c48 <__memmove_avx_unaligned_erms+456>:   add    rsi,0x80
   0x7ffff7658c4f <__memmove_avx_unaligned_erms+463>:   sub    rdx,0x80
=> 0x7ffff7658c56 <__memmove_avx_unaligned_erms+470>:   vmovdqa YMMWORD PTR [rdi],ymm0
   0x7ffff7658c5a <__memmove_avx_unaligned_erms+474>:   vmovdqa YMMWORD PTR [rdi+0x20],ymm1
   0x7ffff7658c5f <__memmove_avx_unaligned_erms+479>:   vmovdqa YMMWORD PTR [rdi+0x40],ymm2
   0x7ffff7658c64 <__memmove_avx_unaligned_erms+484>:   vmovdqa YMMWORD PTR [rdi+0x60],ymm3
   0x7ffff7658c69 <__memmove_avx_unaligned_erms+489>:   add    rdi,0x80
[------------------------------------stack-------------------------------------]
0000| 0x7fffffffd538 --> 0x555555625861 (<_D3std9algorithm8mutation__T4copyTAxhTAhZQnFNaNbNiNfQsQqZQt+593>:     mov    rax,QWORD PTR [rbp-0x90])
0008| 0x7fffffffd540 --> 0x555555d53340 --> 0x0 
0016| 0x7fffffffd548 --> 0x301 
0024| 0x7fffffffd550 --> 0x7fffec354000 
0032| 0x7fffffffd558 --> 0x360 
0040| 0x7fffffffd560 --> 0x7fffffffd610 --> 0x7fffffffd770 --> 0x7fffffffd880 --> 0x7fffffffda00 --> 0x7fffffffdd00 (--> ...)
0048| 0x7fffffffd568 --> 0x7fffffffdde0 --> 0x1 
0056| 0x7fffffffd570 --> 0x7fffffffd5c0 --> 0x360 
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
Stopped reason: SIGSEGV
0x00007ffff7658c56 in __memmove_avx_unaligned_erms () from /usr/lib/libc.so.6
gdb-peda$ bt
#0  0x00007ffff7658c56 in __memmove_avx_unaligned_erms () from /usr/lib/libc.so.6
#1  0x0000555555625861 in std.algorithm.mutation.copy!(const(ubyte)[], ubyte[]).copy(const(ubyte)[], ubyte[]) (source=..., target=...) at /usr/include/dlang/ldc/std/algorithm/mutation.d:392
#2  0x000055555562531a in teraflop.graphics.MeshBase.initialize(scope gfx.graal.device.Device) (this=0x7ffff7381480, device=0x7ffff7371318) at /home/webfreak/dev/teraflop-d/source/teraflop/graphics/package.d:251
#3  0x00005555555e641b in teraflop.systems.ResourceInitializer.run() (this=0x7ffff73799c0) at /home/webfreak/dev/teraflop-d/source/teraflop/systems/package.d:31
#4  0x0000555555629ed8 in teraflop.game.Game.update() (this=0x7ffff7377100) at game.d:301
#5  0x0000555555628598 in teraflop.game.Game.run() (this=0x7ffff7377100) at game.d:151
#6  0x000055555564971e in D main () at /home/webfreak/dev/teraflop-d/examples/cube/source/app.d:13
#7  0x00007ffff791b08c in rt.dmain2._d_run_main2(char[][], ulong, extern(C) int(char[][]) function).runAll() () from /usr/lib/libdruntime-ldc-shared.so.94
#8  0x00007ffff791aea8 in _d_run_main2 () from /usr/lib/libdruntime-ldc-shared.so.94
#9  0x00007ffff791acfe in _d_run_main () from /usr/lib/libdruntime-ldc-shared.so.94
#10 0x00005555556498b5 in main (argc=0x1, argv=0x7fffffffdfa8) at /usr/include/dlang/ldc/core/internal/entrypoint.d:42
#11 0x00007ffff751b152 in __libc_start_main () from /usr/lib/libc.so.6
#12 0x00005555555e10ae in _start ()
gdb-peda$ f 1
#1  0x0000555555625861 in std.algorithm.mutation.copy!(const(ubyte)[], ubyte[]).copy(const(ubyte)[], ubyte[]) (source=..., target=...) at /usr/include/dlang/ldc/std/algorithm/mutation.d:392
392                 target[0 .. slen] = source[];
gdb-peda$ p target
$1 = <error reading variable>
gdb-peda$ p source
$2 = "\000\000\200\277\000\000\200\277\000\000\200?\000\000\000\000\000\000\000\000\000\000\200?\000\000\000\000\000\000\200?\000\000\000\000\000\000\200?\000\000\200\277\000\000\200?\000\000\000\000\000\000\000\000\000\000\200?\000\000\000\000\000\000\200?\000\000\000\000\000\000\200?\000\000\200?\000\000\200?\000\000\000\000\000\000\000\000\000\000\200?\000\000\000\000\000\000\200?\000\000\000\000\000\000\200\277\000\000\200?\000\000\200?\000\000\000\000\000\000\000\000\000\000\200?\000\000\000\000\000\000\200?\000\000\000\000\000\000\200?\000\000\200\277\000\000\200\277\000\000\000\000\000\000\000\000\000\000\200\277\000\000\000\000\000\000\200?\000\000\000\000\000\000\200\277\000\000\200\277\000\000\200\277\000\000\000\000\000\000\000\000\000\000"...

Vulkan info: https://gist.github.com/WebFreak001/2a9e8af8d31993a6fc9b8433c24741de

@chances chances added the bug Something isn't working label Feb 3, 2021
@chances
Copy link
Owner

chances commented Feb 4, 2021

I've made some changes to help address this issue in #26. However, I cannot reproduce the specific segfault you cited in MeshBase.

@WebFreak001 What happens if you run:

  1. git clone --single-branch --branch "issue/13-segfault" https://github.com/chances/teraflop-d.git
  2. cd teraflop-d
  3. dub run teraflop:cube

@chances chances self-assigned this Jun 28, 2021
@chances chances linked a pull request Jun 28, 2021 that will close this issue
@chances chances added the question Further information is requested label Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants