Page MenuHome

Again 2.8 crash by segmentation fault under Ubuntu
Closed, ResolvedPublicBUG

Description

With today 64 Linux buildbot (blender-2.80-9422db7796e-linux-glibc219-x86_64), it crashes as I switch to Eevee or instantly by starting with Factory settings:


env@env-K50ID:~$ '/home/env/blender_download/blender-2.80-9422db7796e-linux-glibc219-x86_64/blender'
Received X11 Error:
error code: 8
request code: 154
minor code: 34
error text: BadMatch (invalid parameter attributes)
Received X11 Error:
error code: 2
request code: 154
minor code: 34
error text: BadValue (integer parameter out of range for operation)
Received X11 Error:
error code: 2
request code: 154
minor code: 34
error text: BadValue (integer parameter out of range for operation)
Received X11 Error:
error code: 2
request code: 154
minor code: 34
error text: BadValue (integer parameter out of range for operation)
Received X11 Error:
error code: 2
request code: 154
minor code: 34
error text: BadValue (integer parameter out of range for operation)
Received X11 Error:
error code: 2
request code: 154
minor code: 34
error text: BadValue (integer parameter out of range for operation)
found bundled python: /home/env/blender_download/blender-2.80-9422db7796e-linux-glibc219-x86_64/2.80/python
CUDA cuInit: Unknown error
GPUShader: compile error:
0(978) : error C0105: Syntax error in #if
0(978) : error C0105: Syntax error in #if
0(979) : error C0000: syntax error, unexpected $undefined, expecting "::" at token "<undefined>"

GPUShader: compile error:
0(979) : error C0105: Syntax error in #if
0(979) : error C0105: Syntax error in #if
0(980) : error C0000: syntax error, unexpected $undefined, expecting "::" at token "<undefined>"

Writing: /tmp/blender.crash.txt
Errore di segmentazione ("segmentation fault")

Under Ubuntu 15.04 Mate 64 bit - Nvidia Geforce GT 320M

Revisions and Commits

Event Timeline

Joshua Leung (aligorith) lowered the priority of this task from 90 to 50.EditedOct 4 2017, 2:20 PM

I'm getting a segfault here on Windows 8.1, Nvidia GeForce GT 740M too (after updating GP branch today - I hadn't updated since last Thursday).

Note: This seems unrelated to the other GL/driver related crash-on-startup issues I had been able to work around till now. This time, the segfault is in blender.exe and not the nvidia dlls.

EDIT: I managed to load some old 2.7x files, and can confirm that the problem seems restricted to Eevee. Clay/Blender Render load fine.

@Joshua Leung (aligorith) could you bisect it? Clement is on his own hardware and likely is not even running into this.

Also @Enrico Valenza (env) can you confirm that do you get the crash if you run it with ./blender --factory-startup as well without doing any further changes?

Dalai Felinto (dfelinto) lowered the priority of this task from 50 to 30.EditedOct 4 2017, 4:56 PM

And also, @Enrico Valenza (env) / @Joshua Leung (aligorith) if you run with --debug --debug-gpu you will see the exactly shader error the compiler error line is referring to (spoiler alert, shares are > 5k lines)

Dalai Felinto, yes, it crashes also by running it with "./blender --factory-startup" and without doing any further changes; and here is last part of the console by starting it with "--debug --debug-gpu" (sorry, the console doesn't keep the first 623 lines):

P.S.: also, the new crash file appended.


624 void main()
625 {
626 Closure cl = nodetree_exec();
627 fragColor = vec4(cl.radiance, cl.opacity);
628 ssrNormals = cl.ssr_normal.xyyy;
629 ssrData = cl.ssr_data;
630 }
631
632 #endif /* MESH_SHADER && !SHADOW_SHADER */
633
634 #endif /* VOLUMETRICS */
635
636 Closure nodetree_exec(void); /* Prototype */
637
638 /* TODO find a better place */
639 #ifdef USE_MULTIPLY
640
641 out vec4 fragColor;
642
643 #define NODETREE_EXEC
644 void main()
645 {
646 Closure cl = nodetree_exec();
647 fragColor = vec4(mix(vec3(1.0), cl.radiance, cl.opacity), 1.0);
648 }
649 #endif
650 /* Based on Practical Realtime Strategies for Accurate Indirect Occlusion
651 * http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pdf
652 * http://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pptx */
653
654 #define MAX_PHI_STEP 32
655 #define MAX_SEARCH_ITER 32
656 #define MAX_LOD 6.0
657
658 #ifndef UTIL_TEX
659 #define UTIL_TEX
660 uniform sampler2DArray utilTex;
661 #endif /* UTIL_TEX */
662
663 uniform vec4 aoParameters[2];
664 uniform sampler2DArray horizonBuffer;
665
666 /* Cannot use textureSize(horizonBuffer) when rendering to it */
667 uniform ivec2 aoHorizonTexSize;
668
669 #define aoDistance aoParameters[0].x
670 #define aoSamples aoParameters[0].y
671 #define aoFactor aoParameters[0].z
672 #define aoInvSamples aoParameters[0].w
673
674 #define aoOffset aoParameters[1].x /* UNUSED */
675 #define aoBounceFac aoParameters[1].y
676 #define aoQuality aoParameters[1].z
677 #define aoSettings aoParameters[1].w
678
679 #define USE_AO 1
680 #define USE_BENT_NORMAL 2
681 #define USE_DENOISE 4
682
683 vec2 pack_horizons(vec2 v) { return v * 0.5 + 0.5; }
684 vec2 unpack_horizons(vec2 v) { return v * 2.0 - 1.0; }
685
686 /* Returns the texel coordinate in horizonBuffer
687 * for a given fullscreen coord */
688 ivec2 get_hr_co(ivec2 fs_co)
689 {
690 bvec2 quarter = notEqual(fs_co & ivec2(1), ivec2(0));
691
692 ivec2 hr_co = fs_co / 2;
693 hr_co += ivec2(quarter) * (aoHorizonTexSize / 2);
694
695 return hr_co;
696 }
697
698 /* Returns the texel coordinate in fullscreen (depthBuffer)
699 * for a given horizonBuffer coord */
700 ivec2 get_fs_co(ivec2 hr_co)
701 {
702 hr_co *= 2;
703 bvec2 quarter = greaterThanEqual(hr_co, aoHorizonTexSize);
704
705 hr_co -= ivec2(quarter) * (aoHorizonTexSize - 1);
706
707 return hr_co;
708 }
709
710 /* Returns the phi angle in horizonBuffer
711 * for a given horizonBuffer coord */
712 float get_phi(ivec2 hr_co, ivec2 fs_co, float sample)
713 {
714 bvec2 quarter = greaterThanEqual(hr_co, aoHorizonTexSize / 2);
715 ivec2 tex_co = ((int(aoSettings) & USE_DENOISE) != 0) ? hr_co - ivec2(quarter) * (aoHorizonTexSize / 2) : fs_co;
716 float blue_noise = texture(utilTex, vec3((vec2(tex_co) + 0.5) / LUT_SIZE, 2.0)).r;
717
718 float phi = sample * aoInvSamples;
719
720 if ((int(aoSettings) & USE_DENOISE) != 0) {
721 /* Interleaved jitter for spatial 2x2 denoising */
722 phi += 0.25 * aoInvSamples * (float(quarter.x) + 2.0 * float(quarter.y));
723 blue_noise *= 0.25;
724 }
725 /* Blue noise is scaled to cover the rest of the range. */
726 phi += aoInvSamples * blue_noise;
727 phi *= M_PI;
728
729 return phi;
730 }
731
732 /* Returns direction jittered offset for a given fullscreen coord */
733 float get_offset(ivec2 fs_co, float sample)
734 {
735 float offset = sample * aoInvSamples;
736
737 /* Interleaved jitter for spatial 2x2 denoising */
738 offset += 0.25 * dot(vec2(1.0), vec2(fs_co & 1));
739 offset += texture(utilTex, vec3((vec2(fs_co / 2) + 0.5 + 16.0) / LUT_SIZE, 2.0)).r;
740 return offset;
741 }
742
743 /* Returns maximum screen distance an AO ray can travel for a given view depth */
744 vec2 get_max_dir(float view_depth)
745 {
746 float homcco = ProjectionMatrix[2][3] * view_depth + ProjectionMatrix[3][3];
747 float max_dist = aoDistance / homcco;
748 return vec2(ProjectionMatrix[0][0], ProjectionMatrix[1][1]) * max_dist;
749 }
750
751 void get_max_horizon_grouped(vec4 co1, vec4 co2, vec3 x, float lod, inout float h)
752 {
753 co1 *= mipRatio[int(lod + 1.0)].xyxy; /* +1 because we are using half res top level */
754 co2 *= mipRatio[int(lod + 1.0)].xyxy; /* +1 because we are using half res top level */
755
756 float depth1 = textureLod(maxzBuffer, co1.xy, floor(lod)).r;
757 float depth2 = textureLod(maxzBuffer, co1.zw, floor(lod)).r;
758 float depth3 = textureLod(maxzBuffer, co2.xy, floor(lod)).r;
759 float depth4 = textureLod(maxzBuffer, co2.zw, floor(lod)).r;
760
761 vec4 len, s_h;
762
763 vec3 s1 = get_view_space_from_depth(co1.xy, depth1); /* s View coordinate */
764 vec3 omega_s1 = s1 - x;
765 len.x = length(omega_s1);
766 s_h.x = omega_s1.z / len.x;
767
768 vec3 s2 = get_view_space_from_depth(co1.zw, depth2); /* s View coordinate */
769 vec3 omega_s2 = s2 - x;
770 len.y = length(omega_s2);
771 s_h.y = omega_s2.z / len.y;
772
773 vec3 s3 = get_view_space_from_depth(co2.xy, depth3); /* s View coordinate */
774 vec3 omega_s3 = s3 - x;
775 len.z = length(omega_s3);
776 s_h.z = omega_s3.z / len.z;
777
778 vec3 s4 = get_view_space_from_depth(co2.zw, depth4); /* s View coordinate */
779 vec3 omega_s4 = s4 - x;
780 len.w = length(omega_s4);
781 s_h.w = omega_s4.z / len.w;
782
783 /* Blend weight after half the aoDistance to fade artifacts */
784 vec4 blend = saturate((1.0 - len / aoDistance) * 2.0);
785
786 h = mix(h, max(h, s_h.x), blend.x);
787 h = mix(h, max(h, s_h.y), blend.y);
788 h = mix(h, max(h, s_h.z), blend.z);
789 h = mix(h, max(h, s_h.w), blend.w);
790 }
791
792 vec2 search_horizon_sweep(float phi, vec3 pos, vec2 uvs, float jitter, vec2 max_dir)
793 {
794 vec2 t_phi = vec2(cos(phi), sin(phi)); /* Screen space direction */
795
796 max_dir *= max_v2(abs(t_phi));
797
798 /* Convert to pixel space. */
799 t_phi /= vec2(textureSize(maxzBuffer, 0));
800
801 /* Avoid division by 0 */
802 t_phi += vec2(1e-5);
803
804 jitter *= 0.25;
805
806 /* Compute end points */
807 vec2 corner1 = min(vec2(1.0) - uvs, max_dir); /* Top right */
808 vec2 corner2 = max(vec2(0.0) - uvs, -max_dir); /* Bottom left */
809 vec2 iter1 = corner1 / t_phi;
810 vec2 iter2 = corner2 / t_phi;
811
812 vec2 min_iter = max(-iter1, -iter2);
813 vec2 max_iter = max( iter1, iter2);
814
815 vec2 times = vec2(-min_v2(min_iter), min_v2(max_iter));
816
817 vec2 h = vec2(-1.0); /* init at cos(pi) */
818
819 /* This is freaking sexy optimized. */
820 for (float i = 0.0, ofs = 4.0, time = -1.0;
821 i < MAX_SEARCH_ITER && time > times.x;
822 i++, time -= ofs, ofs = min(exp2(MAX_LOD) * 4.0, ofs + ofs * aoQuality))
823 {
824 vec4 t = max(times.xxxx, vec4(time) - (vec4(0.25, 0.5, 0.75, 1.0) - jitter) * ofs);
825 vec4 cos1 = uvs.xyxy + t_phi.xyxy * t.xxyy;
826 vec4 cos2 = uvs.xyxy + t_phi.xyxy * t.zzww;
827 float lod = min(MAX_LOD, max(i - jitter * 4.0, 0.0) * aoQuality);
828 get_max_horizon_grouped(cos1, cos2, pos, lod, h.y);
829 }
830
831 for (float i = 0.0, ofs = 4.0, time = 1.0;
832 i < MAX_SEARCH_ITER && time < times.y;
833 i++, time += ofs, ofs = min(exp2(MAX_LOD) * 4.0, ofs + ofs * aoQuality))
834 {
835 vec4 t = min(times.yyyy, vec4(time) + (vec4(0.25, 0.5, 0.75, 1.0) - jitter) * ofs);
836 vec4 cos1 = uvs.xyxy + t_phi.xyxy * t.xxyy;
837 vec4 cos2 = uvs.xyxy + t_phi.xyxy * t.zzww;
838 float lod = min(MAX_LOD, max(i - jitter * 4.0, 0.0) * aoQuality);
839 get_max_horizon_grouped(cos1, cos2, pos, lod, h.x);
840 }
841
842 return h;
843 }
844
845 void integrate_slice(vec3 normal, float phi, vec2 horizons, inout float visibility, inout vec3 bent_normal)
846 {
847 /* TODO OPTI Could be precomputed. */
848 vec2 t_phi = vec2(cos(phi), sin(phi)); /* Screen space direction */
849
850 /* Projecting Normal to Plane P defined by t_phi and omega_o */
851 vec3 np = vec3(t_phi.y, -t_phi.x, 0.0); /* Normal vector to Integration plane */
852 vec3 t = vec3(-t_phi, 0.0);
853 vec3 n_proj = normal - np * dot(np, normal);
854 float n_proj_len = max(1e-16, length(n_proj));
855
856 float cos_n = clamp(n_proj.z / n_proj_len, -1.0, 1.0);
857 float n = sign(dot(n_proj, t)) * fast_acos(cos_n); /* Angle between view vec and normal */
858
859 /* (Slide 54) */
860 vec2 h = fast_acos(horizons);
861 h.x = -h.x;
862
863 /* Clamping thetas (slide 58) */
864 h.x = n + max(h.x - n, -M_PI_2);
865 h.y = n + min(h.y - n, M_PI_2);
866
867 /* Solving inner integral */
868 vec2 h_2 = 2.0 * h;
869 vec2 vd = -cos(h_2 - n) + cos_n + h_2 * sin(n);
870 float vis = (vd.x + vd.y) * 0.25 * n_proj_len;
871
872 visibility += vis;
873
874 /* Finding Bent normal */
875 float b_angle = (h.x + h.y) * 0.5;
876 /* The 0.5 factor below is here to equilibrate the accumulated vectors.
877 * (sin(b_angle) * -t_phi) will accumulate to (phi_step * result_nor.xy * 0.5).
878 * (cos(b_angle) * 0.5) will accumulate to (phi_step * result_nor.z * 0.5). */
879 bent_normal += vec3(sin(b_angle) * -t_phi, cos(b_angle) * 0.5);
880 }
881
882 void denoise_ao(vec3 normal, float frag_depth, inout float visibility, inout vec3 bent_normal)
883 {
884 vec2 d_sign = vec2(ivec2(gl_FragCoord.xy) & 1) - 0.5;
885
886 if ((int(aoSettings) & USE_DENOISE) == 0) {
887 d_sign *= 0.0;
888 }
889
890 /* 2x2 Bilateral Filter using derivatives. */
891 vec2 n_step = step(-0.2, -abs(vec2(length(dFdx(normal)), length(dFdy(normal)))));
892 vec2 z_step = step(-0.1, -abs(vec2(dFdx(frag_depth), dFdy(frag_depth))));
893
894 visibility -= dFdx(visibility) * d_sign.x * z_step.x * n_step.x;
895 visibility -= dFdy(visibility) * d_sign.y * z_step.y * n_step.y;
896
897 bent_normal -= dFdx(bent_normal) * d_sign.x * z_step.x * n_step.x;
898 bent_normal -= dFdy(bent_normal) * d_sign.y * z_step.y * n_step.y;
899 }
900
901 void gtao_deferred(vec3 normal, vec3 position, float frag_depth, out float visibility, out vec3 bent_normal)
902 {
903 vec2 uvs = get_uvs_from_view(position);
904
905 vec4 texel_size = vec4(-1.0, -1.0, 1.0, 1.0) / vec2(textureSize(depthBuffer, 0)).xyxy;
906
907 ivec2 fs_co = ivec2(gl_FragCoord.xy);
908 ivec2 hr_co = get_hr_co(fs_co);
909
910 bent_normal = vec3(0.0);
911 visibility = 0.0;
912
913 for (float i = 0.0; i < MAX_PHI_STEP; i++) {
914 if (i >= aoSamples) break;
915
916 vec2 horiz = unpack_horizons(texelFetch(horizonBuffer, ivec3(hr_co, int(i)), 0).rg);
917 float phi = get_phi(hr_co, fs_co, i);
918
919 integrate_slice(normal, phi, horiz.xy, visibility, bent_normal);
920 }
921
922 visibility *= aoInvSamples;
923 bent_normal = normalize(bent_normal);
924 }
925
926 void gtao(vec3 normal, vec3 position, vec2 noise, out float visibility, out vec3 bent_normal)
927 {
928 vec2 uvs = get_uvs_from_view(position);
929
930 float homcco = ProjectionMatrix[2][3] * position.z + ProjectionMatrix[3][3];
931 float max_dist = aoDistance / homcco; /* Search distance */
932 vec2 max_dir = max_dist * vec2(ProjectionMatrix[0][0], ProjectionMatrix[1][1]);
933
934 bent_normal = vec3(0.0);
935 visibility = 0.0;
936
937 for (float i = 0.0; i < MAX_PHI_STEP; i++) {
938 if (i >= aoSamples) break;
939
940 float phi = M_PI * (i + noise.x) * aoInvSamples;
941 vec2 horizons = search_horizon_sweep(phi, position, uvs, noise.g, max_dir);
942
943 integrate_slice(normal, phi, horizons, visibility, bent_normal);
944 }
945
946 visibility *= aoInvSamples;
947 bent_normal = normalize(bent_normal);
948 }
949
950 /* Multibounce approximation base on surface albedo.
951 * Page 78 in the .pdf version. */
952 float gtao_multibounce(float visibility, vec3 albedo)
953 {
954 if (aoBounceFac == 0.0) return visibility;
955
956 /* Median luminance. Because Colored multibounce looks bad. */
957 float lum = dot(albedo, vec3(0.3333));
958
959 float a = 2.0404 * lum - 0.3324;
960 float b = -4.7951 * lum + 0.6417;
961 float c = 2.7552 * lum + 0.6903;
962
963 float x = visibility;
964 return max(x, ((x * a + b) * x + c) * x);
965 }
966
967 /* Use the right occlusion */
968 float occlusion_compute(vec3 N, vec3 vpos, float user_occlusion, vec2 randuv, out vec3 bent_normal)
969 {
970 if ((int(aoSettings) & USE_AO) == 0) {
971 bent_normal = N;
972 return user_occlusion;
973 }
974 else {
975 float visibility;
976 vec3 vnor = mat3(ViewMatrix) * N;
977
978 #if (defined(MESH_SHADER) && \
979 !defined(USE_ALPHA_HASH) && \
980 !defined(USE_ALPHA_CLIP) && \
981 !defined(SHADOW_SHADER) && \
982 !defined(USE_MULTIPLY) && \
983 !defined(USE_ALPHA_BLEND)) \
984 || defined(STEP_RESOLVE)
985 gtao_deferred(vnor, vpos, gl_FragCoord.z, visibility, bent_normal);
986 #else
987 gtao(vnor, vpos, randuv, visibility, bent_normal);
988 #endif
989 denoise_ao(vnor, gl_FragCoord.z, visibility, bent_normal);
990
991 /* Prevent some problems down the road. */
992 visibility = max(1e-3, visibility);
993
994 if ((int(aoSettings) & USE_BENT_NORMAL) != 0) {
995 /* The bent normal will show the facet look of the mesh. Try to minimize this. */
996 float mix_fac = visibility * visibility;
997 bent_normal = normalize(mix(bent_normal, vnor, mix_fac));
998
999 bent_normal = transform_direction(ViewMatrixInverse, bent_normal);
1000 }
1001 else {
1002 bent_normal = N;
1003 }
1004
1005 /* Scale by user factor */
1006 visibility = pow(visibility, aoFactor);
1007
1008 return min(visibility, user_occlusion);
1009 }
1010 }
1011 /
1012 * This shader only compute maximum horizon angles for each directions.
1013 * The final integration is done at the resolve stage with the shading normal.
1014
/
1015
1016 uniform float rotationOffset;
1017
1018 out vec4 FragColor;
1019
1020 #ifdef DEBUG_AO
1021 uniform sampler2D normalBuffer;
1022
1023 void main()
1024 {
1025 vec4 texel_size = 1.0 / vec2(textureSize(depthBuffer, 0)).xyxy;
1026 vec2 uvs = saturate(gl_FragCoord.xy * texel_size.xy);
1027
1028 float depth = textureLod(depthBuffer, uvs, 0.0).r;
1029
1030 vec3 viewPosition = get_view_space_from_depth(uvs, depth);
1031 vec3 V = viewCameraVec;
1032 vec3 normal = normal_decode(texture(normalBuffer, uvs).rg, V);
1033
1034 vec3 bent_normal;
1035 float visibility;
1036 #if 1
1037 gtao_deferred(normal, viewPosition, depth, visibility, bent_normal);
1038 #else
1039 vec2 rand = vec2((1.0 / 4.0) * float((int(gl_FragCoord.y) & 0x1) * 2 + (int(gl_FragCoord.x) & 0x1)), 0.5);
1040 rand = fract(rand.x + texture(utilTex, vec3(floor(gl_FragCoord.xy * 0.5) / LUT_SIZE, 2.0)).rg);
1041 gtao(normal, viewPosition, rand, visibility, bent_normal);
1042 #endif
1043 denoise_ao(normal, depth, visibility, bent_normal);
1044
1045 FragColor = vec4(visibility);
1046 }
1047
1048 #else
1049 uniform float sampleNbr;
1050
1051 void main()
1052 {
1053 ivec2 hr_co = ivec2(gl_FragCoord.xy);
1054 ivec2 fs_co = get_fs_co(hr_co);
1055
1056 vec2 uvs = saturate((vec2(fs_co) + 0.5) / vec2(textureSize(depthBuffer, 0)));
1057 float depth = textureLod(depthBuffer, uvs, 0.0).r;
1058
1059 if (depth == 1.0) {
1060 /* Do not trace for background */
1061 FragColor = vec4(0.0);
1062 return;
1063 }
1064
1065 /* Avoid self shadowing. */
1066 depth = saturate(depth - 3e-6); /* Tweaked for 24bit depth buffer. */
1067
1068 vec3 viewPosition = get_view_space_from_depth(uvs, depth);
1069
1070 float phi = get_phi(hr_co, fs_co, sampleNbr);
1071 float offset = get_offset(fs_co, sampleNbr);
1072 vec2 max_dir = get_max_dir(viewPosition.z);
1073
1074 FragColor.xy = search_horizon_sweep(phi, viewPosition, uvs, offset, max_dir);
1075
1076 /* Resize output for integer texture. */
1077 FragColor = pack_horizons(FragColor.xy).xyxy;
1078 }
1079 #endif
0(979) : error C0105: Syntax error in #if
0(979) : error C0105: Syntax error in #if
0(980) : error C0000: syntax error, unexpected $undefined, expecting "::" at token "<undefined>"

Uniform 'texelSize' not found!
Writing: /tmp/blender.crash.txt
Errore di segmentazione


Clément Foucault (fclem) raised the priority of this task from 30 to Unbreak Now!.Oct 4 2017, 9:03 PM

It's the multiline preprocessor directive that is causing problem on THIS compiler! pffff