Closed manuelxmarquez closed 6 years ago
I'm sorry for your bad experience, but probably it can be resolved using the proper system configuration. I do not exclude a GLX-related bug since usually I don't run on Linux, and currently I don't have a Linux system to test.
I'm noticing that DeviceContextGLX
is not mentioned in the log linked by you. The Error in mono: free(): invalid pointer
is not related to the assertion you get, and I suspect that OpenGL.Net is not involved at all in this exception ("C" free() is managed completely by Mono).
To get more detailed information, you should clone the repository, link the debug library and enable functions logging as each sample does, so we can get the exact function sequences (some fundamental state is dependent on the actual libraries you have installed).
I.e. Are you forcing EGL? Do you have EGL library installed? Do you have a GLX driver? What is your glxinfo
? Have you tried skipping EGL/GLX/GL initialization (and execute them explicitly)?
No worries about the bad experience. I'm still learning OpenGL and Linux and so some of could be my inexperience.
I was running the HelloTriangle example and did compile everything in Debug mode. I just remembered that I did make one small change because of another exception I was getting below:
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00057] in <9790d962aaad40deb63d33029ba0d2f6>:0
at System.Number.ParseInt64 (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) [0x00016] in <9790d962aaad40deb63d33029ba0d2f6>:0
at System.Int64.Parse (System.String s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <9790d962aaad40deb63d33029ba0d2f6>:0
at System.Convert.ToInt64 (System.String value, System.IFormatProvider provider) [0x00006] in <9790d962aaad40deb63d33029ba0d2f6>:0
at System.String.System.IConvertible.ToInt64 (System.IFormatProvider provider) [0x00000] in <9790d962aaad40deb63d33029ba0d2f6>:0
at Khronos.KhronosLogContext.QueryLogContext (System.Type khronoApiType) [0x000ab] in <2a726728d2a74240b7a9c2b156706813>:0
at Khronos.KhronosLogContext..ctor (System.Type khronoApiType) [0x00008] in <2a726728d2a74240b7a9c2b156706813>:0
at OpenGL.Glx.LogCommand (System.String name, System.Object returnValue, System.Object[] args) [0x0000d] in <2a726728d2a74240b7a9c2b156706813>:0
at OpenGL.Glx.QueryVersion (System.IntPtr dpy, System.Int32[] maj, System.Int32[] min) [0x00057] in <2a726728d2a74240b7a9c2b156706813>:0
at OpenGL.DeviceContextGLX.QueryVersion () [0x00023] in <2a726728d2a74240b7a9c2b156706813>:0
at OpenGL.DeviceContextGLX..ctor (System.IntPtr display, System.IntPtr windowHandle) [0x00054] in <2a726728d2a74240b7a9c2b156706813>:0
at OpenGL.DeviceContext.Create (System.IntPtr display, System.IntPtr windowHandle) [0x00031] in <2a726728d2a74240b7a9c2b156706813>:0
at OpenGL.GlControl.CreateDeviceContext (OpenGL.DevicePixelFormat controlReqFormat) [0x0003b] in <354b4104652a4ff792fcef07b9fc6efd>:0
at OpenGL.GlControl.CreateDeviceContext () [0x00008] in <354b4104652a4ff792fcef07b9fc6efd>:0
at OpenGL.GlControl.OnHandleCreated (System.EventArgs e) [0x0000f] in <354b4104652a4ff792fcef07b9fc6efd>:0
at System.Windows.Forms.Control.WmCreate (System.Windows.Forms.Message& m) [0x00000] in <b99add59884c4a44a02ee27e15a44f95>:0
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x0021c] in <b99add59884c4a44a02ee27e15a44f95>:0
at System.Windows.Forms.ScrollableControl.WndProc (System.Windows.Forms.Message& m) [0x00000] in <b99add59884c4a44a02ee27e15a44f95>:0
at System.Windows.Forms.ContainerControl.WndProc (System.Windows.Forms.Message& m) [0x00029] in <b99add59884c4a44a02ee27e15a44f95>:0
at System.Windows.Forms.UserControl.WndProc (System.Windows.Forms.Message& m) [0x00027] in <b99add59884c4a44a02ee27e15a44f95>:0
at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in <b99add59884c4a44a02ee27e15a44f95>:0
at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x0000b] in <b99add59884c4a44a02ee27e15a44f95>:0
at System.Windows.Forms.NativeWindow.WndProc (System.IntPtr hWnd, System.Windows.Forms.Msg msg, System.IntPtr wParam, System.IntPtr lParam) [0x00085] in <b99add59884c4a44a02ee27e15a44f95>:0
*** Error in `mono': free(): invalid pointer: 0x00007f9a3d168880 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f9a48ebe7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f9a48ec737a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f9a48ecb53c]
mono[0x421812]
mono(mono_conc_hashtable_destroy+0x5b)[0x68f5bb]
mono[0x42169c]
mono(mono_domain_free+0x31c)[0x5f002c]
mono[0x42325d]
mono(mono_main+0x1270)[0x478b70]
mono[0x4208ce]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f9a48e67830]
mono(_start+0x29)[0x420e89]
======= Memory map: ========
00400000-007c2000 r-xp 00000000 08:01 398251 /usr/bin/mono-sgen
009c1000-009c2000 r--p 003c1000 08:01 398251 /usr/bin/mono-sgen
009c2000-009c5000 rw-p 003c2000 08:01 398251 /usr/bin/mono-sgen
009c5000-00a1b000 rw-p 00000000 00:00 0
0165e000-02027000 rw-p 00000000 00:00 0 [heap]
40813000-40823000 rwxp 00000000 00:00 0
415be000-41692000 rwxp 00000000 00:00 0
7f9a28000000-7f9a28021000 rw-p 00000000 00:00 0
7f9a28021000-7f9a2c000000 ---p 00000000 00:00 0
7f9a2fca8000-7f9a2fcac000 rw-p 00000000 00:00 0
7f9a2fcb0000-7f9a2fcb4000 rw-p 00000000 00:00 0
7f9a2fcb8000-7f9a2fcbc000 rw-p 00000000 00:00 0
7f9a2fcc0000-7f9a2fcc4000 rw-p 00000000 00:00 0
7f9a2fcc8000-7f9a2fccc000 rw-p 00000000 00:00 0
7f9a2fcd0000-7f9a2fcd4000 rw-p 00000000 00:00 0
7f9a2fcd8000-7f9a2fd58000 rw-p 00000000 00:00 0
7f9a2fd5a000-7f9a2fd91000 r-xp 00000000 08:01 8426 /usr/lib/x86_64-linux-gnu/libtxc_dxtn_s2tc.so.0.0.0
7f9a2fd91000-7f9a2ff90000 ---p 00037000 08:01 8426 /usr/lib/x86_64-linux-gnu/libtxc_dxtn_s2tc.so.0.0.0
7f9a2ff90000-7f9a2ff91000 r--p 00036000 08:01 8426 /usr/lib/x86_64-linux-gnu/libtxc_dxtn_s2tc.so.0.0.0
7f9a2ff91000-7f9a2ff92000 rw-p 00037000 08:01 8426 /usr/lib/x86_64-linux-gnu/libtxc_dxtn_s2tc.so.0.0.0
7f9a2ff92000-7f9a2ffa5000 r-xp 00000000 08:01 268892 /lib/x86_64-linux-gnu/libbsd.so.0.8.2
7f9a2ffa5000-7f9a301a4000 ---p 00013000 08:01 268892 /lib/x86_64-linux-gnu/libbsd.so.0.8.2
7f9a301a4000-7f9a301a5000 r--p 00012000 08:01 268892 /lib/x86_64-linux-gnu/libbsd.so.0.8.2
7f9a301a5000-7f9a301a6000 rw-p 00013000 08:01 268892 /lib/x86_64-linux-gnu/libbsd.so.0.8.2
7f9a301a6000-7f9a301a7000 rw-p 00000000 00:00 0
7f9a301a7000-7f9a301cc000 r-xp 00000000 08:01 269067 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f9a301cc000-7f9a303cb000 ---p 00025000 08:01 269067 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f9a303cb000-7f9a303cf000 r--p 00024000 08:01 269067 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f9a303cf000-7f9a303d0000 rw-p 00028000 08:01 269067 /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f9a303d0000-7f9a30401000 r-xp 00000000 08:01 7356 /usr/lib/x86_64-linux-gnu/libedit.so.2.0.53
7f9a30401000-7f9a30601000 ---p 00031000 08:01 7356 /usr/lib/x86_64-linux-gnu/libedit.so.2.0.53
7f9a30601000-7f9a30603000 r--p 00031000 08:01 7356 /usr/lib/x86_64-linux-gnu/libedit.so.2.0.53
7f9a30603000-7f9a30604000 rw-p 00033000 08:01 7356 /usr/lib/x86_64-linux-gnu/libedit.so.2.0.53
7f9a30604000-7f9a30608000 rw-p 00000000 00:00 0
7f9a30608000-7f9a3077a000 r-xp 00000000 08:01 8360 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f9a3077a000-7f9a3097a000 ---p 00172000 08:01 8360 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f9a3097a000-7f9a30984000 r--p 00172000 08:01 8360 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f9a30984000-7f9a30986000 rw-p 0017c000 08:01 8360 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f9a30986000-7f9a3098a000 rw-p 00000000 00:00 0
7f9a3098a000-7f9a33568000 r-xp 00000000 08:01 6894 /usr/lib/x86_64-linux-gnu/libLLVM-4.0.so.1
7f9a33568000-7f9a33569000 ---p 02bde000 08:01 6894 /usr/lib/x86_64-linux-gnu/libLLVM-4.0.so.1
7f9a33569000-7f9a3387d000 r--p 02bde000 08:01 6894 /usr/lib/x86_64-linux-gnu/libLLVM-4.0.so.1
7f9a3387d000-7f9a33882000 rw-p 02ef2000 08:01 6894 /usr/lib/x86_64-linux-gnu/libLLVM-4.0.so.1
7f9a33882000-7f9a338d1000 rw-p 00000000 00:00 0
7f9a338d1000-7f9a338e8000 r-xp 00000000 08:01 7361 /usr/lib/x86_64-linux-gnu/libelf-0.165.so
7f9a338e8000-7f9a33ae7000 ---p 00017000 08:01 7361 /usr/lib/x86_64-linux-gnu/libelf-0.165.so
7f9a33ae7000-7f9a33ae8000 r--p 00016000 08:01 7361 /usr/lib/x86_64-linux-gnu/libelf-0.165.so
7f9a33ae8000-7f9a33ae9000 rw-p 00017000 08:01 7361 /usr/lib/x86_64-linux-gnu/libelf-0.165.so
7f9a33ae9000-7f9a33af2000 r-xp 00000000 08:01 7324 /usr/lib/x86_64-linux-gnu/libdrm_amdgpu.so.1.0.0
7f9a33af2000-7f9a33cf1000 ---p 00009000 08:01 7324 /usr/lib/x86_64-linux-gnu/libdrm_amdgpu.so.1.0.0
7f9a33cf1000-7f9a33cf2000 r--p 00008000 08:01 7324 /usr/lib/x86_64-linux-gnu/libdrm_amdgpu.so.1.0.0
7f9a33cf2000-7f9a33cf3000 rw-p 00009000 08:01 7324 /usr/lib/x86_64-linux-gnu/libdrm_amdgpu.so.1.0.0
7f9a33cf3000-7f9a33cfe000 r-xp 00000000 08:01 7330 /usr/lib/x86_64-linux-gnu/libdrm_radeon.so.1.0.1
7f9a33cfe000-7f9a33efd000 ---p 0000b000 08:01 7330 /usr/lib/x86_64-linux-gnu/libdrm_radeon.so.1.0.1
7f9a33efd000-7f9a33efe000 r--p 0000a000 08:01 7330 /usr/lib/x86_64-linux-gnu/libdrm_radeon.so.1.0.1
7f9a33efe000-7f9a33eff000 rw-p 0000b000 08:01 7330 /usr/lib/x86_64-linux-gnu/libdrm_radeon.so.1.0.1
7f9a33eff000-7f9a33f06000 r-xp 00000000 08:01 7328 /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0
7f9a33f06000-7f9a34105000 ---p 00007000 08:01 7328 /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0
7f9a34105000-7f9a34106000 r--p 00006000 08:01 7328 /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0
7f9a34106000-7f9a34107000 rw-p 00007000 08:01 7328 /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0
7f9a34107000-7f9a34115000 r-xp 00000000 08:01 8290 /usr/lib/x86_64-linux-gnu/libsensors.so.4.4.0
7f9a34115000-7f9a34314000 ---p 0000e000 08:01 8290 /usr/lib/x86_64-linux-gnu/libsensors.so.4.4.0
7f9a34314000-7f9a34315000 r--p 0000d000 08:01 8290 /usr/lib/x86_64-linux-gnu/libsensors.so.4.4.0
7f9a34315000-7f9a34316000 rw-p 0000e000 08:01 8290 /usr/lib/x86_64-linux-gnu/libsensors.so.4.4.0
7f9a34316000-7f9a34ca3000 r-xp 00000000 08:01 269695 /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
7f9a34ca3000-7f9a34ea3000 ---p 0098d000 08:01 269695 /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
7f9a34ea3000-7f9a34ede000 r--p 0098d000 08:01 269695 /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
7f9a34ede000-7f9a34eea000 rw-p 009c8000 08:01 269695 /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
7f9a34eea000-7f9a350e1000 rw-p 00000000 00:00 0
7f9a350e1000-7f9a350f1000 r-xp 00000000 08:01 7322 /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7f9a350f1000-7f9a352f0000 ---p 00010000 08:01 7322 /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7f9a352f0000-7f9a352f1000 r--p 0000f000 08:01 7322 /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7f9a352f1000-7f9a352f2000 rw-p 00010000 08:01 7322 /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7f9a352f2000-7f9a352f7000 r-xp 00000000 08:01 7024 /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
7f9a352f7000-7f9a354f6000 ---p 00005000 08:01 7024 /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
7f9a354f6000-7f9a354f7000 r--p 00004000 08:01 7024 /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
7f9a354f7000-7f9a354f8000 rw-p 00005000 08:01 7024 /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
7f9a354f8000-7f9a354fc000 r-xp 00000000 08:01 8565 /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0.0.0
7f9a354fc000-7f9a356fb000 ---p 00004000 08:01 8565 /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0.0.0
7f9a356fb000-7f9a356fc000 r--p 00003000 08:01 8565 /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0.0.0
7f9a356fc000-7f9a356fd000 rw-p 00004000 08:01 8565 /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0.0.0
7f9a356fd000-7f9a35714000 r-xp 00000000 08:01 8569 /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7f9a35714000-7f9a35913000 ---p 00017000 08:01 8569 /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7f9a35913000-7f9a35915000 r--p 00016000 08:01 8569 /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7f9a35915000-7f9a35916000 rw-p 00018000 08:01 8569 /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7f9a35916000-7f9a35917000 r-xp 00000000 08:01 6967 /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7f9a35917000-7f9a35b16000 ---p 00001000 08:01 6967 /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7f9a35b16000-7f9a35b17000 r--p 00000000 08:01 6967 /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7f9a35b17000-7f9a35b18000 rw-p 00001000 08:01 6967 /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7f9a35b18000-7f9a35b42000 r-xp 00000000 08:01 7557 /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7f9a35b42000-7f9a35d41000 ---p 0002a000 08:01 7557 /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7f9a35d41000-7f9a35d45000 r--p 00029000 08:01 7557 /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7f9a35d45000-7f9a35d46000 rw-p 0002d000 08:01 7557 /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7f9a35d46000-7f9a35d47000 rw-p 00000000 00:00 0
7f9a35d47000-7f9a35d48000 r-xp 00000000 08:01 8613 /usr/lib/x86_64-linux-gnu/libxshmfence.so.1.0.0
7f9a35d48000-7f9a35f48000 ---p 00001000 08:01 8613 /usr/lib/x86_64-linux-gnu/libxshmfence.so.1.0.0
7f9a35f48000-7f9a35f49000 r--p 00001000 08:01 8613 /usr/lib/x86_64-linux-gnu/libxshmfence.so.1.0.0
7f9a35f49000-7f9a35f4a000 rw-p 00002000 08:01 8613 /usr/lib/x86_64-linux-gnu/libxshmfence.so.1.0.0
7f9a35f4a000-7f9a35f4f000 r-xp 00000000 08:01 8589 /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1.0.0
7f9a35f4f000-7f9a3614f000 ---p 00005000 08:01 8589 /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1.0.0
7f9a3614f000-7f9a36150000 r--p 00005000 08:01 8589 /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1.0.0
7f9a36150000-7f9a36151000 rw-p 00006000 08:01 8589 /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1.0.0
7f9a36151000-7f9a36153000 r-xp 00000000 08:01 8577 /usr/lib/x86_64-linux-gnu/libxcb-present.so.0.0.0
7f9a36153000-7f9a36352000 ---p 00002000 08:01 8577 /usr/lib/x86_64-linux-gnu/libxcb-present.so.0.0.0
7f9a36352000-7f9a36353000 r--p 00001000 08:01 8577 /usr/lib/x86_64-linux-gnu/libxcb-present.so.0.0.0
7f9a36353000-7f9a36354000 rw-p 00002000 08:01 8577 /usr/lib/x86_64-linux-gnu/libxcb-present.so.0.0.0
7f9a36354000-7f9a36356000 r-xp 00000000 08:01 8567 /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0.0.0
7f9a36356000-7f9a36555000 ---p 00002000 08:01 8567 /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0.0.0
7f9a36555000-7f9a36556000 r--p 00001000 08:01 8567 /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0.0.0
7f9a36556000-7f9a36557000 rw-p 00002000 08:01 8567 /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0.0.0
7f9a36557000-7f9a365c5000 r-xp 00000000 08:01 271454 /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0
7f9a365c5000-7f9a367c4000 ---p 0006e000 08:01 271454 /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0
7f9a367c4000-7f9a367c7000 r--p 0006d000 08:01 271454 /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0
7f9a367c7000-7f9a367c8000 rw-p 00070000 08:01 271454 /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2.0
7f9a367c8000-7f9a367c9000 rw-p 00000000 00:00 0
7f9a367c9000-7f9a368c1000 r--p 00000000 08:01 9854 /usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
7f9a368c1000-7f9a368e1000 r-xp 00000000 08:01 398303 /usr/lib/libMonoSupportW.so
7f9a368e1000-7f9a36ae0000 ---p 00020000 08:01 398303 /usr/lib/libMonoSupportW.so
7f9a36ae0000-7f9a36ae1000 r--p 0001f000 08:01 398303 /usr/lib/libMonoSupportW.so
7f9a36ae1000-7f9a36ae2000 rw-p 00020000 08:01 398303 /usr/lib/libMonoSupportW.so
7f9a36ae2000-7f9a36b9b000 r--p 00000000 08:01 145100 /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
7f9a36b9b000-7f9a36ba2000 r-xp 00000000 08:01 8077 /usr/lib/x86_64-linux-gnu/libogg.so.0.8.2
7f9a36ba2000-7f9a36da2000 ---p 00007000 08:01 8077 /usr/lib/x86_64-linux-gnu/libogg.so.0.8.2
7f9a36da2000-7f9a36da3000 r--p 00007000 08:01 8077 /usr/lib/x86_64-linux-gnu/libogg.so.0.8.2
7f9a36da3000-7f9a36da4000 rw-p 00008000 08:01 8077 /usr/lib/x86_64-linux-gnu/libogg.so.0.8.2
7f9a36da4000-7f9a36dce000 r-xp 00000000 08:01 8480 /usr/lib/x86_64-linux-gnu/libvorbis.so.0.4.8
7f9a36dce000-7f9a36fce000 ---p 0002a000 08:01 8480 /usr/lib/x86_64-linux-gnu/libvorbis.so.0.4.8
7f9a36fce000-7f9a36fcf000 r--p 0002a000 08:01 8480 /usr/lib/x86_64-linux-gnu/libvorbis.so.0.4.8
7f9a36fcf000-7f9a36fd0000 rw-p 0002b000 08:01 8480 /usr/lib/x86_64-linux-gnu/libvorbis.so.0.4.8
7f9a36fd0000-7f9a36fd9000 r-xp 00000000 08:01 7912 /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.1
7f9a36fd9000-7f9a371d8000 ---p 00009000 08:01 7912 /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.1
7f9a371d8000-7f9a371d9000 r--p 00008000 08:01 7912 /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.1
7f9a371d9000-7f9a371da000 rw-p 00009000 08:01 7912 /usr/lib/x86_64-linux-gnu/libltdl.so.7.3.1
7f9a371da000-7f9a371ee000 r-xp 00000000 08:01 8380 /usr/lib/x86_64-linux-gnu/libtdb.so.1.3.8
7f9a371ee000-7f9a373ed000 ---p 00014000 08:01 8380 /usr/lib/x86_64-linux-gnu/libtdb.so.1.3.8
7f9a373ed000-7f9a373ee000 r--p 00013000 08:01 8380 /usr/lib/x86_64-linux-gnu/libtdb.so.1.3.8
7f9a373ee000-7f9a373ef000 rw-p 00014000 08:01 8380 /usr/lib/x86_64-linux-gnu/libtdb.so.1.3.8
7f9a373ef000-7f9a373f6000 r-xp 00000000 08:01 8484 /usr/lib/x86_64-linux-gnu/libvorbisfile.so.3.3.7
7f9a373f6000-7f9a375f6000 ---p 00007000 08:01 8484 /usr/lib/x86_64-linux-gnu/libvorbisfile.so.3.3.7
7f9a375f6000-7f9a375f7000 r--p 00007000 08:01 8484 /usr/lib/x86_64-linux-gnu/libvorbisfile.so.3.3.7
7f9a375f7000-7f9a375f8000 rw-p 00008000 08:01 8484 /usr/lib/x86_64-linux-gnu/libvorbisfile.so.3.3.7
7f9a375f8000-7f9a37608000 r-xp 00000000 08:01 7176 /usr/lib/x86_64-linux-gnu/libcanberra.so.0.2.5
7f9a37608000-7f9a37807000 ---p 00010000 08:01 7176 /usr/lib/x86_64-linux-gnu/libcanberra.so.0.2.5
7f9a37807000-7f9a37808000 r--p 0000f000 08:01 7176 /usr/lib/x86_64-linux-gnu/libcanberra.so.0.2.5
7f9a37808000-7f9a37809000 rw-p 00010000 08:01 7176 /usr/lib/x86_64-linux-gnu/libcanberra.so.0.2.5
7f9a37809000-7f9a3780d000 r-xp 00000000 08:01 7172 /usr/lib/x86_64-linux-gnu/libcanberra-gtk.so.0.1.9
7f9a3780d000-7f9a37a0c000 ---p 00004000 08:01 7172 /usr/lib/x86_64-linux-gnu/libcanberra-gtk.so.0.1.9
7f9a37a0c000-7f9a37a0d000 r--p 00003000 08:01 7172 /usr/lib/x86_64-linux-gnu/libcanberra-gtk.so.0.1.9
7f9a37a0d000-7f9a37a0e000 rw-p 00004000 08:01 7172 /usr/lib/x86_64-linux-gnu/libcanberra-gtk.so.0.1.9
7f9a37a0e000-7f9a37a13000 r-xp 00000000 08:01 270986 /usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so
7f9a37a13000-7f9a37c12000 ---p 00005000 08:01 270986 /usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so
7f9a37c12000-7f9a37c13000 r--p 00004000 08:01 270986 /usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so
7f9a37c13000-7f9a37c14000 rw-p 00005000 08:01 270986 /usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so
7f9a37c14000-7f9a37c44000 r-xp 00000000 08:01 270967 /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/engines/libmurrine.so
7f9a37c44000-7f9a37e44000 ---p 00030000 08:01 270967 /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/engines/libmurrine.so
7f9a37e44000-7f9a37e45000 r--p 00030000 08:01 270967 /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/engines/libmurrine.so
7f9a37e45000-7f9a37e46000 rw-p 00031000 08:01 270967 /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/engines/libmurrine.so
7f9a37e46000-7f9a37e50000 r-xp 00000000 08:01 270968 /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/engines/libpixmap.so
7f9a37e50000-7f9a3804f000 ---p 0000a000 08:01 270968 /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/engines/libpixmap.so
7f9a3804f000-7f9a38050000 r--p 00009000 08:01 270968 /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/engines/libpixmap.so
7f9a38050000-7f9a38051000 rw-p 0000a000 08:01 270968 /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/engines/libpixmap.soAborted (core dumped)
I was able to trace this back to KhronosLogContext.QueryLogContext on this line: Int64 enumValueKey = fieldInfoValue.ToInt64(System.Globalization.NumberFormatInfo.InvariantInfo);
The field causing the problem is in Glx
/// <summary>
/// [GLX] Value of GLX_EXTENSION_NAME symbol.
/// </summary>
[RequiredByFeature("GLX_VERSION_1_0")]
public const string EXTENSION_NAME = "GLX";
Can't convert GLX to int! So I commented this constant and tried executing but still got the same exception.
I studied all the big OpenGL wrappers for .NET and actually decided to convert the OpenGL xml data to my own wrappers and learn a bit more how OpenGL works. It appears OpenGL.NET works the same way because the source of the error is in glx.xml
<enums namespace="GLXStrings">
<enum value=""GLX"" name="GLX_EXTENSION_NAME" comment="This is modest abuse of the enum tag mechanism, maybe a string tag?"/>
</enums>
I'm not sure about the last part but I did manage to get a bare bones example working. I'll post in another reply since this one is getting long.
I was able to get this example working. Ignore the fact that it's SharpGL (and a bit messy), I don't think SharpGL has Glx, it's just something I hacked together since I was mixing languages. I copied the relevant PInvokes below.
Dim display = SharpGL.Linux.Glx.XOpenDisplay(IntPtr.Zero)
Console.WriteLine($"display: {display}")
Dim screen = SharpGL.Linux.Glx.XDefaultScreen(display)
Console.WriteLine($"screen: {screen}")
Dim attributes = {4,' GLX_RGBA
12,' GLX_DEPTH_SIZE
24,' 24
5,' GLX_DOUBLEBUFFER
0' None
}
Dim vis = SharpGL.Linux.Glx.ChooseVisual(display, screen, attributes)
Console.WriteLine($"vis: {vis}")
Dim hrDC = SharpGL.Linux.Glx.CreateContext(display, vis, IntPtr.Zero, True)
Console.WriteLine($"hrDC: {hrDC}")
Dim extensionString = SharpGL.Linux.Glx.QueryExtensionsString(display, screen)
Console.WriteLine($"extensionString: {extensionString}")
SharpGL.Linux.Glx.MakeCurrent(display, window.Handle, hrDC)
Console.WriteLine("MakeCurrent")
Dim glClearColorPtr = SharpGL.Linux.Glx.GetProcAddress("glClearColor")
Console.WriteLine($"glClearColor: {glClearColorPtr}")
Dim glClearColorFun = CType(Marshal.GetDelegateForFunctionPointer(glClearColorPtr, GetType(glClearColorDelegate)), glClearColorDelegate)
'SharpGL.Linux.Glx.ClearColor(1, 0, 0, 1)
glClearColorFun(1, 0, 0, 1)
SharpGL.Linux.Glx.Clear(SharpGL.Enumerations.AttributeMask.ColorBuffer Or SharpGL.Enumerations.AttributeMask.DepthBuffer)
SharpGL.Linux.Glx.SwapBuffers(display, window.Handle)
'SharpGL.Linux.Glx.ClearColor(0, 1, 0, 1)
glClearColorFun(0, 1, 0, 1)
SharpGL.Linux.Glx.Clear(SharpGL.Enumerations.AttributeMask.ColorBuffer Or SharpGL.Enumerations.AttributeMask.DepthBuffer)
Public Delegate Sub glClearColorDelegate(red As Single, green As Single, blue As Single, alpha As Single)
And the relevant PInvokes
private const string Library = "libGL.so.1";
[DllImport("libX11", EntryPoint = "XOpenDisplay")]
public extern static IntPtr XOpenDisplay(IntPtr display);
[DllImport("libX11", EntryPoint = "XDefaultScreen")]
public extern static int XDefaultScreen(IntPtr display);
[DllImport(Library, EntryPoint = "glXChooseVisual")]
public extern static IntPtr ChooseVisual(IntPtr dpy, int screen, IntPtr attriblist);
[DllImport(Library, EntryPoint = "glXChooseVisual")]
public extern static IntPtr ChooseVisual(IntPtr dpy, int screen, ref int attriblist);
public static IntPtr ChooseVisual(IntPtr dpy, int screen, int[] attriblist)
{
unsafe
{
fixed (int* attriblist_ptr = attriblist)
{
return ChooseVisual(dpy, screen, (IntPtr)attriblist_ptr);
}
}
}
[DllImport(Library, EntryPoint = "glXCreateContext")]
public static extern IntPtr CreateContext(IntPtr dpy, IntPtr vis, IntPtr shareList, bool direct);
[DllImport(Library, EntryPoint = "glXQueryExtensionsString")]
private static extern IntPtr QueryExtensionsStringInternal(IntPtr dpy, int screen);
public static string QueryExtensionsString(IntPtr dpy, int screen)
{
return Marshal.PtrToStringAnsi(QueryExtensionsStringInternal(dpy, screen));
}
[DllImport(Library, EntryPoint = "glXMakeCurrent")]
public static extern bool MakeCurrent(IntPtr display, IntPtr drawable, IntPtr context);
[DllImport(Library, EntryPoint = "glXGetProcAddress")]
public static extern IntPtr GetProcAddress([MarshalAs(UnmanagedType.LPTStr)] string procName);
[DllImport(Library, EntryPoint = "glXGetProcAddress")]
public static extern IntPtr GetProcAddress(IntPtr procName);
I hope that gives you some idea of what works and what the problem might be. Let me know if you would like me to try something out on Linux.
Yesterday I've restored my Linux box and tried to restore compilation status and execution in my Linux environment (I've made some changes that broke compilation on Linux). The bug you've found is already "fixed" (really I mask the exception) on HEAD (the correct way is to avoid generation of enum fields having a string type)..
Currently I use the last mono/monodevelop releases (instead the ones shipped with Ubuntu 16.04, which are quite old). I got the same problems you have found (stability), and probably this is because memory get corrupted at some point, breaking the execution environment (i.e. JIT).
I suspect that the culprit is the string marshaling management (glGetString, glXQueryExtensions...), but I need some time to investigate on it. Tonight and tomorrow I'l try to get a stable execution, and I'll report the result here when I get something relevant.
I believe I was having issues on older mono versions as well. The version I was testing is Mono JIT compiler version 5.4.0.201 which should be the latest.
Also, I was compiling on Windows and running in Linux, not sure if that makes a difference.
Currently I debug the HelloTriangle execution using the following environment:
export DEBUG=GL
export OPENGL_NET_EGL_STATIC_INIT=NO
mono HelloTriangle.exe
I've noticed the EGL platform backend cause more problems. The application will output all GL/GLX commands executed.
What I get, when not running correctly, is the following output:
OpenGL.Net is initializing XOpenDisplay(0x00000000) = 0x02A5B300 XDefaultScreen(0x02A5B300) = 0 glXChooseFBConfig(0x02A5B300, 0, {32784,1,32785,1,5,-1,8,1,9,1,10,1,0}, {132}) = 0x02B3B280 Choosen config is 0x02A99ED0 glXGetVisualFromFBConfig(0x02A5B300, 0x02A99ED0) = XVisualInfo { visual=0x2A66FD8 id=0x6D, screen=0, depth=24, class=TrueColor colormap_size=256 bits_per_rgb=8 } Choosen visual is XVisualInfo { visual=0x2A66FD8 id=0x6D, screen=0, depth=24, class=TrueColor colormap_size=256 bits_per_rgb=8 } XFree(0x02B3B280) = 1 XRootWindow(0x02A5B300, 0) = 0x000002C2 XCreateColormap(0x02A5B300, 0x000002C2, 0x02A66FD8, 0, 0x04C00001) = 0x04C00001 XCreateWindow(0x02A5B300, 0x000002C2, 0, 0, 16, 16, 0, 24, 0, 0x02A66FD8, 10248, OpenGL.Glx+XSetWindowAttributes) = 0x04C00002 glXQueryVersion(0x02A5B300, {1}, {4}) = True XDefaultScreen(0x02A5B300) = 0 glXQueryDrawable(0x02A5B300, 0x04C00003, 32787, {341}) glXChooseFBConfig(0x02A5B300, 0, {32787,341,0}, {1}) = 0x02DFAFA0 glXGetVisualFromFBConfig(0x02A5B300, 0x02A99ED0) = XVisualInfo { visual=0x2A66FD8 id=0x6D, screen=0, depth=24, class=TrueColor colormap_size=256 bits_per_rgb=8 } XFree(0x02DFAFA0) = 1 glXCreateContext(0x02A5B300, XVisualInfo { visual=0x2A66FD8 id=0x6D, screen=0, depth=24, class=TrueColor colormap_size=256 bits_per_rgb=8 }, 0x00000000, True) = 0x02B4E070 glXMakeCurrent(0x02A5B300, 0x04C00003, 0x02B4E070) = True glXGetCurrentContext() = 0x02B4E070 Unable to initialize OpenGL.Net: System.ExecutionEngineException: String conversion error: Partial byte sequence encountered in the input. at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal:PtrToStringAnsi (intptr) at OpenGL.Gl.GetString (OpenGL.StringName name) [0x0000c] in <31448e1fc0e74ae3b63c682ec60a4320>:0 at OpenGL.Gl.QueryContextVersion () [0x0001e] in <31448e1fc0e74ae3b63c682ec60a4320>:0 at OpenGL.Gl.QueryContextVersionCore () [0x00069] in <31448e1fc0e74ae3b63c682ec60a4320>:0 at OpenGL.Gl.BindAPI () [0x00000] in <31448e1fc0e74ae3b63c682ec60a4320>:0 at OpenGL.DeviceContext.MakeCurrent (System.IntPtr ctx) [0x00037] in <31448e1fc0e74ae3b63c682ec60a4320>:0 at OpenGL.Gl.Initialize () [0x00086] in <31448e1fc0e74ae3b63c682ec60a4320>:0 glXQueryVersion(0x0247F890, {1}, {4}) = True Query GLX extensions. glXQueryVersion(0x0247F890, {1}, {4}) = True glXQueryExtensionsString(0x0247F890, 0) = GLX_EXT_visual_info GLX_EXT_visual_rating GLX_SGIX_fbconfig GLX_SGIX_pbuffer GLX_SGI_video_sync GLX_SGI_swap_control GLX_EXT_swap_control GLX_EXT_swap_control_tear GLX_EXT_texture_from_pixmap GLX_EXT_buffer_age GLX_ARB_create_context GLX_ARB_create_context_profile GLX_EXT_create_context_es_profile GLX_EXT_create_context_es2_profile GLX_ARB_create_context_robustness GLX_NV_delay_before_swap GLX_EXT_stereo_tree GLX_ARB_context_flush_control GLX_ARB_multisample GLX_NV_float_buffer GLX_ARB_fbconfig_float GLX_EXT_framebuffer_sRGB GLX_NV_multisample_coverage GLX_NV_copy_image GLX_ARB_get_proc_address glXGetFBConfigs(0x0247F890, 0, 311) = 0x031836A0 glXGetFBConfigAttrib(0x0247F890, 0x02B39060, 32785, 1) = 0 glXGetFBConfigAttrib(0x0247F890, 0x02B39060, 32, 32768) = 0 glXGetVisualFromFBConfig(0x0247F890, 0x02B39060) = XVisualInfo { visual=0x2488B60 id=0x65, screen=0, depth=24, class=TrueColor colormap_size=256 bits_per_rgb=8 } glXGetFBConfigAttrib(0x0247F890, 0x02B39060, 32784, 7) = 0 glXGetFBConfigAttrib(0x0247F890, 0x02B39060, 32787, 329) = 0 glXGetFBConfigAttrib(0x0247F890, 0x02B39060, 2, 24) = 0 glXGetFBConfigAttrib(0x0247F890, 0x02B39060, 12, 24) = 0 glXGetFBConfigAttrib(0x0247F890, 0x02B39060, 13, 8) = 0 glXGetFBConfigAttrib(0x0247F890, 0x02B39060, 100000, 0) = 0 glXGetFBConfigAttrib(0x0247F890, 0x02B39060, 5, 1) = 0 glXGetFBConfigAttrib(0x0247F890, 0x02B39060, 6, 0) = 0 glXGetFBConfigAttrib(0x0247F890, 0x02B396E0, 32785, 1) = 0 glXGetFBConfigAttrib(0x0247F890, 0x02B396E0, 32, 32768) = 0 glXGetVisualFromFBConfig(0x0247F890, 0x02B396E0) = XVisualInfo { visual=0x2488B98 id=0x66, screen=0, depth=24, class=DirectColor colormap_size=256 bits_per_rgb=8 }
The exception System.ExecutionEngineException: String conversion error: Partial byte sequence encountered in the input.
is caused by GetString
, which calls Marshal.PtrToStringAnsi
. Essentially glGetString
is returning garbage, which cannot be decoded as ANSI (which should be UTF8 anyway, but this is not the culprit).
The commit seems to solve issue with mono on Linux. But I need to exclude EGL initialization to run properly (export OPENGL_NET_EGL_STATIC_INIT=NO
). It also resolved some issue on Windows when running in x86.
I am getting the following exception on Linux (Ubuntu and ZorinOS VMs).
System.NullReferenceException: Object reference not set to an instance of an object at OpenGL.Glx.CreateContextAttribsARB (System.IntPtr dpy, System.IntPtr config, System.IntPtr share_context, System.Boolean direct, System.Int32[] attrib_list) [0x00018] in:0
at OpenGL.DeviceContextGLX.CreateContextAttrib (System.IntPtr sharedContext, System.Int32[] attribsList, OpenGL.KhronosVersion api) [0x00283] in :0
at OpenGL.DeviceContextGLX.CreateContextAttrib (System.IntPtr sharedContext, System.Int32[] attribsList) [0x00010] in :0
at WindowTester.Program.Main (System.String[] args) [0x00314] in <09e86c9ac2f3497a919935f4eb8eae49>:0
Segmentation fault (core dumped)
I was able to trace it back to the following delegate being null, Delegates.pglXCreateContextAttribsARB, when calling DeviceContext.CreateContextAttrib.
It was actually difficult to trace it since I'm new to OpenGL and Linux. It appears Debug.Assert does not do anything on mono and it's just ignored. Maybe throwing an exception instead is better for compatibility? The are some fixes posted online but the only one that worked for me was attaching a listener to the console.
I tried different package versions and found that 0.5.2 worked but 0.6.0 did not, if that helps narrow it down.
However, even in that version it only works sometimes. Randomly it crashes with *** Error in `mono': free(): invalid pointer
Full dump is attached since it is quite long. CrashDump.txt
I spent a day trying to get this to work but I have no idea how to debug as I'm not a Linux or OpenGL user (coming form Windows Direct3D) but wanted to at least post my findings. I think I will have to use OpenTK for it's stability but I really liked the OpenGL.NET library.