Strange wined3d crash

Matteo Bruni matteo.mystral at gmail.com
Wed Apr 29 12:02:58 CDT 2015


2015-04-29 18:03 GMT+02:00 Francois Gouget <fgouget at free.fr>:
> On Wed, 29 Apr 2015, Henri Verbeet wrote:
>
>> On 29 April 2015 at 12:40, Francois Gouget <fgouget at free.fr> wrote:
>> > I am getting a strange wined3d crash during the d3d8:device test.
>> >
>> Is that a regression? We did touch the shader generation code recently.
>
> It is actually. This is the patch that introduced the crash:
>
> commit 28343db2083de7b4afe4079da090520f44b5544d
> Author: Matteo Bruni <mbruni at codeweavers.com>
> Date:   Mon Apr 27 17:39:12 2015 +0200
>
>     wined3d: Don't use the builtin FFP uniforms for the lights.
>
>     While at it, use D3D-like uniforms for the light parameters and
>     (consequently) implement range and proper D3D spotlights support.
>
>
> I can test patches but I'm not sure I'll have time to debug this much
> further for a while :-( Note that this is with an Intel HD Graphics 4600
> GPU.

Thanks Francois, I can reproduce.

Essentially it crashes in shader_vaddline() as soon as we have to
resize the buffer because vsnprintf() tries to use "args" for a second
time.

I attached a fix. Henri, is something like that okay with you?
-------------- next part --------------
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index caba7db..35f5cf2 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -275,12 +275,14 @@ int shader_vaddline(struct wined3d_string_buffer *buffer, const char *format, va
     int rc;
     char *new_buffer;
     unsigned int new_buffer_size;
+    va_list cur_args;
 
     for (;;)
     {
         rem = buffer->buffer_size - buffer->content_size;
-        rc = vsnprintf(&buffer->buffer[buffer->content_size], rem, format, args);
-
+        va_copy(cur_args, args);
+        rc = vsnprintf(&buffer->buffer[buffer->content_size], rem, format, cur_args);
+        va_end(cur_args);
         if (rc >= 0 /* C89 */ && (unsigned int)rc < rem /* C99 */)
             break;
 


More information about the wine-devel mailing list