diff options
| author | 2018-12-19 12:52:32 +1100 | |
|---|---|---|
| committer | 2018-12-19 12:52:32 +1100 | |
| commit | fdd649e2ef56ea473e253511d35fe6c10e0fb241 (patch) | |
| tree | 82bf8e6a7cd1dd344c9bb0b3a728fc17c38de629 | |
| parent | Merge pull request #1913 from MerryMage/default-fpcr (diff) | |
| download | yuzu-fdd649e2ef56ea473e253511d35fe6c10e0fb241.tar.gz yuzu-fdd649e2ef56ea473e253511d35fe6c10e0fb241.tar.xz yuzu-fdd649e2ef56ea473e253511d35fe6c10e0fb241.zip | |
Fixed uninitialized memory due to missing returns in canary
Functions which are suppose to crash on non canary builds usually don't return anything which lead to uninitialized memory being used.
| -rw-r--r-- | src/core/file_sys/savedata_factory.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/object.cpp | 1 | ||||
| -rw-r--r-- | src/core/memory.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 2 | ||||
| -rw-r--r-- | src/video_core/engines/shader_bytecode.h | 2 | ||||
| -rw-r--r-- | src/video_core/gpu.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/macro_interpreter.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/morton.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 11 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/surface.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/textures/decoders.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/debugger/graphics/graphics_surface.cpp | 1 |
14 files changed, 33 insertions, 3 deletions
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index bd50fedc7..d63b7f19b 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -128,6 +128,7 @@ std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType typ | |||
| 128 | return fmt::format("{}save/cache/{:016X}", out, title_id); | 128 | return fmt::format("{}save/cache/{:016X}", out, title_id); |
| 129 | default: | 129 | default: |
| 130 | ASSERT_MSG(false, "Unrecognized SaveDataType: {:02X}", static_cast<u8>(type)); | 130 | ASSERT_MSG(false, "Unrecognized SaveDataType: {:02X}", static_cast<u8>(type)); |
| 131 | return fmt::format("{}save/unknown_{:X}/{:016X}", out, static_cast<u8>(type), title_id); | ||
| 131 | } | 132 | } |
| 132 | } | 133 | } |
| 133 | 134 | ||
diff --git a/src/core/hle/kernel/object.cpp b/src/core/hle/kernel/object.cpp index 0ea851a74..806078638 100644 --- a/src/core/hle/kernel/object.cpp +++ b/src/core/hle/kernel/object.cpp | |||
| @@ -32,6 +32,7 @@ bool Object::IsWaitable() const { | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | UNREACHABLE(); | 34 | UNREACHABLE(); |
| 35 | return false; | ||
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | } // namespace Kernel | 38 | } // namespace Kernel |
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 643afdee8..e9166dbd9 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -187,6 +187,7 @@ T Read(const VAddr vaddr) { | |||
| 187 | default: | 187 | default: |
| 188 | UNREACHABLE(); | 188 | UNREACHABLE(); |
| 189 | } | 189 | } |
| 190 | return {}; | ||
| 190 | } | 191 | } |
| 191 | 192 | ||
| 192 | template <typename T> | 193 | template <typename T> |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 25bb7604a..0faff6fdf 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -164,6 +164,7 @@ public: | |||
| 164 | return 3; | 164 | return 3; |
| 165 | default: | 165 | default: |
| 166 | UNREACHABLE(); | 166 | UNREACHABLE(); |
| 167 | return 1; | ||
| 167 | } | 168 | } |
| 168 | } | 169 | } |
| 169 | 170 | ||
| @@ -871,6 +872,7 @@ public: | |||
| 871 | return 4; | 872 | return 4; |
| 872 | } | 873 | } |
| 873 | UNREACHABLE(); | 874 | UNREACHABLE(); |
| 875 | return 1; | ||
| 874 | } | 876 | } |
| 875 | 877 | ||
| 876 | GPUVAddr StartAddress() const { | 878 | GPUVAddr StartAddress() const { |
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index 2efeb6e1a..eb703bb5a 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h | |||
| @@ -1065,6 +1065,7 @@ union Instruction { | |||
| 1065 | LOG_CRITICAL(HW_GPU, "Unhandled texture_info: {}", | 1065 | LOG_CRITICAL(HW_GPU, "Unhandled texture_info: {}", |
| 1066 | static_cast<u32>(texture_info.Value())); | 1066 | static_cast<u32>(texture_info.Value())); |
| 1067 | UNREACHABLE(); | 1067 | UNREACHABLE(); |
| 1068 | return TextureType::Texture1D; | ||
| 1068 | } | 1069 | } |
| 1069 | 1070 | ||
| 1070 | TextureProcessMode GetTextureProcessMode() const { | 1071 | TextureProcessMode GetTextureProcessMode() const { |
| @@ -1145,6 +1146,7 @@ union Instruction { | |||
| 1145 | LOG_CRITICAL(HW_GPU, "Unhandled texture_info: {}", | 1146 | LOG_CRITICAL(HW_GPU, "Unhandled texture_info: {}", |
| 1146 | static_cast<u32>(texture_info.Value())); | 1147 | static_cast<u32>(texture_info.Value())); |
| 1147 | UNREACHABLE(); | 1148 | UNREACHABLE(); |
| 1149 | return TextureType::Texture1D; | ||
| 1148 | } | 1150 | } |
| 1149 | 1151 | ||
| 1150 | TextureProcessMode GetTextureProcessMode() const { | 1152 | TextureProcessMode GetTextureProcessMode() const { |
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 88c45a423..08cf6268f 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -102,6 +102,7 @@ u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { | |||
| 102 | return 1; | 102 | return 1; |
| 103 | default: | 103 | default: |
| 104 | UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format)); | 104 | UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format)); |
| 105 | return 1; | ||
| 105 | } | 106 | } |
| 106 | } | 107 | } |
| 107 | 108 | ||
| @@ -119,6 +120,7 @@ u32 DepthFormatBytesPerPixel(DepthFormat format) { | |||
| 119 | return 2; | 120 | return 2; |
| 120 | default: | 121 | default: |
| 121 | UNIMPLEMENTED_MSG("Unimplemented Depth format {}", static_cast<u32>(format)); | 122 | UNIMPLEMENTED_MSG("Unimplemented Depth format {}", static_cast<u32>(format)); |
| 123 | return 1; | ||
| 122 | } | 124 | } |
| 123 | } | 125 | } |
| 124 | 126 | ||
diff --git a/src/video_core/macro_interpreter.cpp b/src/video_core/macro_interpreter.cpp index 9c55e9f1e..64f75db43 100644 --- a/src/video_core/macro_interpreter.cpp +++ b/src/video_core/macro_interpreter.cpp | |||
| @@ -171,6 +171,7 @@ u32 MacroInterpreter::GetALUResult(ALUOperation operation, u32 src_a, u32 src_b) | |||
| 171 | 171 | ||
| 172 | default: | 172 | default: |
| 173 | UNIMPLEMENTED_MSG("Unimplemented ALU operation {}", static_cast<u32>(operation)); | 173 | UNIMPLEMENTED_MSG("Unimplemented ALU operation {}", static_cast<u32>(operation)); |
| 174 | return 0; | ||
| 174 | } | 175 | } |
| 175 | } | 176 | } |
| 176 | 177 | ||
| @@ -268,6 +269,7 @@ bool MacroInterpreter::EvaluateBranchCondition(BranchCondition cond, u32 value) | |||
| 268 | return value != 0; | 269 | return value != 0; |
| 269 | } | 270 | } |
| 270 | UNREACHABLE(); | 271 | UNREACHABLE(); |
| 272 | return true; | ||
| 271 | } | 273 | } |
| 272 | 274 | ||
| 273 | } // namespace Tegra | 275 | } // namespace Tegra |
diff --git a/src/video_core/morton.cpp b/src/video_core/morton.cpp index a310491a8..47e76d8fe 100644 --- a/src/video_core/morton.cpp +++ b/src/video_core/morton.cpp | |||
| @@ -192,6 +192,7 @@ static MortonCopyFn GetSwizzleFunction(MortonSwizzleMode mode, Surface::PixelFor | |||
| 192 | return linear_to_morton_fns[static_cast<std::size_t>(format)]; | 192 | return linear_to_morton_fns[static_cast<std::size_t>(format)]; |
| 193 | } | 193 | } |
| 194 | UNREACHABLE(); | 194 | UNREACHABLE(); |
| 195 | return morton_to_linear_fns[static_cast<std::size_t>(format)]; | ||
| 195 | } | 196 | } |
| 196 | 197 | ||
| 197 | /// 8x8 Z-Order coordinate from 2D coordinates | 198 | /// 8x8 Z-Order coordinate from 2D coordinates |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h index b4ef6030d..de3671acf 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_cache.h | |||
| @@ -67,6 +67,7 @@ public: | |||
| 67 | 6, "ShaderTrianglesAdjacency"); | 67 | 6, "ShaderTrianglesAdjacency"); |
| 68 | default: | 68 | default: |
| 69 | UNREACHABLE_MSG("Unknown primitive mode."); | 69 | UNREACHABLE_MSG("Unknown primitive mode."); |
| 70 | return LazyGeometryProgram(geometry_programs.points, "points", 1, "ShaderPoints"); | ||
| 70 | } | 71 | } |
| 71 | } | 72 | } |
| 72 | 73 | ||
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index bd61af463..836865e14 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -364,6 +364,7 @@ public: | |||
| 364 | return value; | 364 | return value; |
| 365 | default: | 365 | default: |
| 366 | UNREACHABLE_MSG("Unimplemented conversion size: {}", static_cast<u32>(size)); | 366 | UNREACHABLE_MSG("Unimplemented conversion size: {}", static_cast<u32>(size)); |
| 367 | return value; | ||
| 367 | } | 368 | } |
| 368 | } | 369 | } |
| 369 | 370 | ||
| @@ -626,6 +627,7 @@ public: | |||
| 626 | return "floatBitsToInt(" + value + ')'; | 627 | return "floatBitsToInt(" + value + ')'; |
| 627 | } else { | 628 | } else { |
| 628 | UNREACHABLE(); | 629 | UNREACHABLE(); |
| 630 | return value; | ||
| 629 | } | 631 | } |
| 630 | } | 632 | } |
| 631 | 633 | ||
| @@ -2064,6 +2066,8 @@ private: | |||
| 2064 | std::to_string(instr.alu.GetSignedImm20_20())}; | 2066 | std::to_string(instr.alu.GetSignedImm20_20())}; |
| 2065 | default: | 2067 | default: |
| 2066 | UNREACHABLE(); | 2068 | UNREACHABLE(); |
| 2069 | return {regs.GetRegisterAsInteger(instr.gpr39, 0, false), | ||
| 2070 | std::to_string(instr.alu.GetSignedImm20_20())}; | ||
| 2067 | } | 2071 | } |
| 2068 | }(); | 2072 | }(); |
| 2069 | const std::string offset = '(' + packed_shift + " & 0xff)"; | 2073 | const std::string offset = '(' + packed_shift + " & 0xff)"; |
| @@ -3314,6 +3318,7 @@ private: | |||
| 3314 | return std::to_string(instr.r2p.immediate_mask); | 3318 | return std::to_string(instr.r2p.immediate_mask); |
| 3315 | default: | 3319 | default: |
| 3316 | UNREACHABLE(); | 3320 | UNREACHABLE(); |
| 3321 | return std::to_string(instr.r2p.immediate_mask); | ||
| 3317 | } | 3322 | } |
| 3318 | }(); | 3323 | }(); |
| 3319 | const std::string mask = '(' + regs.GetRegisterAsInteger(instr.gpr8, 0, false) + | 3324 | const std::string mask = '(' + regs.GetRegisterAsInteger(instr.gpr8, 0, false) + |
| @@ -3777,7 +3782,9 @@ private: | |||
| 3777 | } | 3782 | } |
| 3778 | break; | 3783 | break; |
| 3779 | } | 3784 | } |
| 3780 | default: { UNIMPLEMENTED_MSG("Unhandled instruction: {}", opcode->get().GetName()); } | 3785 | default: { |
| 3786 | UNIMPLEMENTED_MSG("Unhandled instruction: {}", opcode->get().GetName()); | ||
| 3787 | } | ||
| 3781 | } | 3788 | } |
| 3782 | 3789 | ||
| 3783 | break; | 3790 | break; |
| @@ -3932,4 +3939,4 @@ std::optional<ProgramResult> DecompileProgram(const ProgramCode& program_code, u | |||
| 3932 | return {}; | 3939 | return {}; |
| 3933 | } | 3940 | } |
| 3934 | 3941 | ||
| 3935 | } // namespace OpenGL::GLShader::Decompiler \ No newline at end of file | 3942 | } // namespace OpenGL::GLShader::Decompiler |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 4fd0d66c5..f02415139 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -427,6 +427,7 @@ static const char* GetSource(GLenum source) { | |||
| 427 | RET(OTHER); | 427 | RET(OTHER); |
| 428 | default: | 428 | default: |
| 429 | UNREACHABLE(); | 429 | UNREACHABLE(); |
| 430 | return "Unknown source"; | ||
| 430 | } | 431 | } |
| 431 | #undef RET | 432 | #undef RET |
| 432 | } | 433 | } |
| @@ -445,6 +446,7 @@ static const char* GetType(GLenum type) { | |||
| 445 | RET(MARKER); | 446 | RET(MARKER); |
| 446 | default: | 447 | default: |
| 447 | UNREACHABLE(); | 448 | UNREACHABLE(); |
| 449 | return "Unknown type"; | ||
| 448 | } | 450 | } |
| 449 | #undef RET | 451 | #undef RET |
| 450 | } | 452 | } |
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index 9582dd2ca..a97b1562b 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp | |||
| @@ -65,6 +65,7 @@ PixelFormat PixelFormatFromDepthFormat(Tegra::DepthFormat format) { | |||
| 65 | default: | 65 | default: |
| 66 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | 66 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); |
| 67 | UNREACHABLE(); | 67 | UNREACHABLE(); |
| 68 | return PixelFormat::S8Z24; | ||
| 68 | } | 69 | } |
| 69 | } | 70 | } |
| 70 | 71 | ||
| @@ -141,6 +142,7 @@ PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) | |||
| 141 | default: | 142 | default: |
| 142 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | 143 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); |
| 143 | UNREACHABLE(); | 144 | UNREACHABLE(); |
| 145 | return PixelFormat::RGBA8_SRGB; | ||
| 144 | } | 146 | } |
| 145 | } | 147 | } |
| 146 | 148 | ||
| @@ -327,6 +329,7 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format, | |||
| 327 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}", static_cast<u32>(format), | 329 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}", static_cast<u32>(format), |
| 328 | static_cast<u32>(component_type)); | 330 | static_cast<u32>(component_type)); |
| 329 | UNREACHABLE(); | 331 | UNREACHABLE(); |
| 332 | return PixelFormat::ABGR8U; | ||
| 330 | } | 333 | } |
| 331 | } | 334 | } |
| 332 | 335 | ||
| @@ -346,6 +349,7 @@ ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type) { | |||
| 346 | default: | 349 | default: |
| 347 | LOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast<u32>(type)); | 350 | LOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast<u32>(type)); |
| 348 | UNREACHABLE(); | 351 | UNREACHABLE(); |
| 352 | return ComponentType::UNorm; | ||
| 349 | } | 353 | } |
| 350 | } | 354 | } |
| 351 | 355 | ||
| @@ -393,6 +397,7 @@ ComponentType ComponentTypeFromRenderTarget(Tegra::RenderTargetFormat format) { | |||
| 393 | default: | 397 | default: |
| 394 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | 398 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); |
| 395 | UNREACHABLE(); | 399 | UNREACHABLE(); |
| 400 | return ComponentType::UNorm; | ||
| 396 | } | 401 | } |
| 397 | } | 402 | } |
| 398 | 403 | ||
| @@ -403,6 +408,7 @@ PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat | |||
| 403 | default: | 408 | default: |
| 404 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | 409 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); |
| 405 | UNREACHABLE(); | 410 | UNREACHABLE(); |
| 411 | return PixelFormat::ABGR8U; | ||
| 406 | } | 412 | } |
| 407 | } | 413 | } |
| 408 | 414 | ||
| @@ -418,6 +424,7 @@ ComponentType ComponentTypeFromDepthFormat(Tegra::DepthFormat format) { | |||
| 418 | default: | 424 | default: |
| 419 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | 425 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); |
| 420 | UNREACHABLE(); | 426 | UNREACHABLE(); |
| 427 | return ComponentType::UNorm; | ||
| 421 | } | 428 | } |
| 422 | } | 429 | } |
| 423 | 430 | ||
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index bbae9285f..5db75de22 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -226,7 +226,7 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 226 | return 8; | 226 | return 8; |
| 227 | default: | 227 | default: |
| 228 | UNIMPLEMENTED_MSG("Format not implemented"); | 228 | UNIMPLEMENTED_MSG("Format not implemented"); |
| 229 | break; | 229 | return 1; |
| 230 | } | 230 | } |
| 231 | } | 231 | } |
| 232 | 232 | ||
diff --git a/src/yuzu/debugger/graphics/graphics_surface.cpp b/src/yuzu/debugger/graphics/graphics_surface.cpp index 707747422..209798521 100644 --- a/src/yuzu/debugger/graphics/graphics_surface.cpp +++ b/src/yuzu/debugger/graphics/graphics_surface.cpp | |||
| @@ -30,6 +30,7 @@ static Tegra::Texture::TextureFormat ConvertToTextureFormat( | |||
| 30 | return Tegra::Texture::TextureFormat::A2B10G10R10; | 30 | return Tegra::Texture::TextureFormat::A2B10G10R10; |
| 31 | default: | 31 | default: |
| 32 | UNIMPLEMENTED_MSG("Unimplemented RT format"); | 32 | UNIMPLEMENTED_MSG("Unimplemented RT format"); |
| 33 | return Tegra::Texture::TextureFormat::A8R8G8B8; | ||
| 33 | } | 34 | } |
| 34 | } | 35 | } |
| 35 | 36 | ||