Skip to contentSkip to conversation

clover: Fix pipe_grid_info.indirect not being initialized

PATCH In review Hans de Goede 5 participants 7 messages Mar 14, 2016 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clover: Fix pipe_grid_info.indirect not being initialized

After pipe_grid_info.indirect was introduced, clover was not modified to set it causing it to pass uninitialized memory for it to launch_grid.

This commit fixes this by zero-ing the entire pipe_grid_info struct when declaring it, to avoid similar problems popping-up in the future.

---
 src/gallium/state_trackers/clover/core/kernel.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/gallium/state_trackers/clover/core/kernel.cpp +1 -1
index 8396be9..dad66aa 100644
@@ -55,7 +55,7 @@ kernel::launch(command_queue &q,
    const auto reduced_grid_size =
       map(divides(), grid_size, block_size);
    void *st = exec.bind(&q, grid_offset);
-   struct pipe_grid_info info;
+   struct pipe_grid_info info = { 0, };
 
    // The handles are created during exec_context::bind(), so we need make
    // sure to call exec_context::bind() before retrieving them.
Signature · 6 lines
2.7.2

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
#1 lore raw
Quoted 16 lines · Hans de Goede

After pipe_grid_info.indirect was introduced, clover was not modified to set it causing it to pass uninitialized memory for it to launch_grid.

This commit fixes this by zero-ing the entire pipe_grid_info struct when declaring it, to avoid similar problems popping-up in the future.

---
  src/gallium/state_trackers/clover/core/kernel.cpp | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/gallium/state_trackers/clover/core/kernel.cpp +0 -0
index 8396be9..dad66aa 100644

src/gallium/state_trackers/clover/core/kernel.cpp kernel::launch(command_queue &q, · line 58

Quoted 5 lines
src/gallium/state_trackers/clover/core/kernel.cpp +1 -1
@@ -55,7 +55,7 @@ kernel::launch(command_queue &q,
     const auto reduced_grid_size =
        map(divides(), grid_size, block_size);
     void *st = exec.bind(&q, grid_offset);
-   struct pipe_grid_info info;
+   struct pipe_grid_info info = { 0, };

Right, good catch, it's my fault.

= { 0 }; is enough btw.

This should be backported to mesa 11.2 I guess, could you please send a v2 with this minor fix and add the cc thing?

Thanks.

Quoted 4 lines
src/gallium/state_trackers/clover/core/kernel.cpp +0 -0
     // The handles are created during exec_context::bind(), so we need make
     // sure to call exec_context::bind() before retrieving them.
 
Signature · 5 lines
-Samuel
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Hi,

Quoted 27 lines · Samuel Pitoiset
Quoted 16 lines · Hans de Goede

After pipe_grid_info.indirect was introduced, clover was not modified to set it causing it to pass uninitialized memory for it to launch_grid.

This commit fixes this by zero-ing the entire pipe_grid_info struct when declaring it, to avoid similar problems popping-up in the future.

---
  src/gallium/state_trackers/clover/core/kernel.cpp | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/gallium/state_trackers/clover/core/kernel.cpp +0 -0
index 8396be9..dad66aa 100644

src/gallium/state_trackers/clover/core/kernel.cpp kernel::launch(command_queue &q, · line 58

Quoted 5 lines
src/gallium/state_trackers/clover/core/kernel.cpp +1 -1
@@ -55,7 +55,7 @@ kernel::launch(command_queue &q,
     const auto reduced_grid_size =
        map(divides(), grid_size, block_size);
     void *st = exec.bind(&q, grid_offset);
-   struct pipe_grid_info info;
+   struct pipe_grid_info info = { 0, };

Right, good catch, it's my fault.

Quoted 1 line

= { 0 }; is enough btw.

I prefer to add the "," to make clear that we are initializing the entire struct, I read it as ", ...".

Quoted 1 line

This should be backported to mesa 11.2 I guess, could you please send a v2 with this minor fix and add the cc thing?

Sure, as soon as we're done bikeshedding on the "," :)

Regards,

Hans
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 31 lines · Hans de Goede

Hi,

Quoted 28 lines · Samuel Pitoiset
Quoted 17 lines · Hans de Goede

After pipe_grid_info.indirect was introduced, clover was not modified to set it causing it to pass uninitialized memory for it to launch_grid.

This commit fixes this by zero-ing the entire pipe_grid_info struct when declaring it, to avoid similar problems popping-up in the future.

---
  src/gallium/state_trackers/clover/core/kernel.cpp | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/gallium/state_trackers/clover/core/kernel.cpp +0 -0
index 8396be9..dad66aa 100644

src/gallium/state_trackers/clover/core/kernel.cpp kernel::launch(command_queue &q, · line 58

Quoted 5 lines
src/gallium/state_trackers/clover/core/kernel.cpp +1 -1
@@ -55,7 +55,7 @@ kernel::launch(command_queue &q,
     const auto reduced_grid_size =
        map(divides(), grid_size, block_size);
     void *st = exec.bind(&q, grid_offset);
-   struct pipe_grid_info info;
+   struct pipe_grid_info info = { 0, };

Right, good catch, it's my fault.

Quoted 5 lines
Quoted 1 line

= { 0 }; is enough btw.

I prefer to add the "," to make clear that we are initializing the entire struct,
I read it as ", ...".

Well, usually we use { 0 } in mesa, try to grep and you will see. :-) There is only 3 occurrences of { 0, }, but I think they are quite old.

Quoted 9 lines
Quoted 3 lines

This should be backported to mesa 11.2 I guess, could you please send a v2 with this minor fix and add the cc thing?

Sure, as soon as we're done bikeshedding on the "," :)

Regards,

Hans

Signature · 5 lines
-Samuel
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 36 lines · Samuel Pitoiset
Quoted 33 lines · Hans de Goede

Hi,

Quoted 30 lines · Samuel Pitoiset
Quoted 19 lines · Hans de Goede

After pipe_grid_info.indirect was introduced, clover was not modified to set it causing it to pass uninitialized memory for it to launch_grid.

This commit fixes this by zero-ing the entire pipe_grid_info struct when
declaring it, to avoid similar problems popping-up in the future.

---
  src/gallium/state_trackers/clover/core/kernel.cpp | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/gallium/state_trackers/clover/core/kernel.cpp +0 -0
index 8396be9..dad66aa 100644

src/gallium/state_trackers/clover/core/kernel.cpp kernel::launch(command_queue &q, · line 58

Quoted 5 lines
src/gallium/state_trackers/clover/core/kernel.cpp +1 -1
@@ -55,7 +55,7 @@ kernel::launch(command_queue &q,
     const auto reduced_grid_size =
        map(divides(), grid_size, block_size);
     void *st = exec.bind(&q, grid_offset);
-   struct pipe_grid_info info;
+   struct pipe_grid_info info = { 0, };

Right, good catch, it's my fault.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

= { 0 }; is enough btw.

I prefer to add the "," to make clear that we are initializing the entire struct,
I read it as ", ...".

Well, usually we use { 0 } in mesa, try to grep and you will see. :-) There is only 3 occurrences of { 0, }, but I think they are quite old.

Of course, I'm not really against this ",", but I just want consistency with the other parts.

Quoted 11 lines
Quoted 10 lines
Quoted 4 lines

This should be backported to mesa 11.2 I guess, could you please send a v2 with this minor fix and add the cc thing?

Sure, as soon as we're done bikeshedding on the "," :)

Regards,

Hans

Signature · 5 lines
-Samuel
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#9 lore raw
Quoted 43 lines · Samuel Pitoiset
Quoted 42 lines · Samuel Pitoiset
Quoted 38 lines · Hans de Goede

Hi,

Quoted 30 lines · Samuel Pitoiset
Quoted 19 lines · Hans de Goede

After pipe_grid_info.indirect was introduced, clover was not modified to set it causing it to pass uninitialized memory for it to launch_grid.

This commit fixes this by zero-ing the entire pipe_grid_info struct when
declaring it, to avoid similar problems popping-up in the future.

---
  src/gallium/state_trackers/clover/core/kernel.cpp | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/gallium/state_trackers/clover/core/kernel.cpp +0 -0
index 8396be9..dad66aa 100644

src/gallium/state_trackers/clover/core/kernel.cpp kernel::launch(command_queue &q, · line 58

Quoted 5 lines
src/gallium/state_trackers/clover/core/kernel.cpp +1 -1
@@ -55,7 +55,7 @@ kernel::launch(command_queue &q,
     const auto reduced_grid_size =
        map(divides(), grid_size, block_size);
     void *st = exec.bind(&q, grid_offset);
-   struct pipe_grid_info info;
+   struct pipe_grid_info info = { 0, };

Right, good catch, it's my fault.

Quoted 1 line

= { 0 }; is enough btw.

I prefer to add the "," to make clear that we are initializing the entire struct,
I read it as ", ...".

Quoted 6 lines
Quoted 2 lines

Well, usually we use { 0 } in mesa, try to grep and you will see. :-) There is only 3 occurrences of { 0, }, but I think they are quite old.

Of course, I'm not really against this ",", but I just want consistency with the other parts.

In C++ '{}' is standard, more concise, and works for a wider range of types regardless of their layout ('{ 0 }' is valid or not depending on what the first member of the struct is, while '{}' works regardless, in C++11 it can even be used to initialize non-POD types with custom constructors), so it should be generally preferred instead.

Don't bother to resend just because of my nitpicking, I'll fix it up before I push the last revision of your change, which is:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

This should be backported to mesa 11.2 I guess, could you please send a v2 with this minor fix and add the cc thing?

Quoted 13 lines
Quoted 6 lines
Quoted 5 lines

Sure, as soon as we're done bikeshedding on the "," :)

Regards,

Hans

Signature · 5 lines
-Samuel
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#10 lore raw
Quoted 52 lines · Francisco Jerez
Quoted 43 lines · Samuel Pitoiset
Quoted 42 lines · Samuel Pitoiset
Quoted 38 lines · Hans de Goede

Hi,

Quoted 30 lines · Samuel Pitoiset
Quoted 19 lines · Hans de Goede

After pipe_grid_info.indirect was introduced, clover was not modified to set it causing it to pass uninitialized memory for it to launch_grid.

This commit fixes this by zero-ing the entire pipe_grid_info struct when
declaring it, to avoid similar problems popping-up in the future.

---
   src/gallium/state_trackers/clover/core/kernel.cpp | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
src/gallium/state_trackers/clover/core/kernel.cpp +0 -0
index 8396be9..dad66aa 100644

src/gallium/state_trackers/clover/core/kernel.cpp kernel::launch(command_queue &q, · line 58

Quoted 5 lines
src/gallium/state_trackers/clover/core/kernel.cpp +1 -1
@@ -55,7 +55,7 @@ kernel::launch(command_queue &q,
      const auto reduced_grid_size =
         map(divides(), grid_size, block_size);
      void *st = exec.bind(&q, grid_offset);
-   struct pipe_grid_info info;
+   struct pipe_grid_info info = { 0, };

Right, good catch, it's my fault.

Quoted 1 line

= { 0 }; is enough btw.

I prefer to add the "," to make clear that we are initializing the entire struct,
I read it as ", ...".

Quoted 6 lines
Quoted 2 lines

Well, usually we use { 0 } in mesa, try to grep and you will see. :-) There is only 3 occurrences of { 0, }, but I think they are quite old.

Of course, I'm not really against this ",", but I just want consistency with the other parts.

Quoted 8 lines

In C++ '{}' is standard, more concise, and works for a wider range of types regardless of their layout ('{ 0 }' is valid or not depending on what the first member of the struct is, while '{}' works regardless, in C++11 it can even be used to initialize non-POD types with custom constructors), so it should be generally preferred instead.

Don't bother to resend just because of my nitpicking, I'll fix it up before I push the last revision of your change, which is:

I didn't know that, thanks for this very good explanation. :-)

Quoted 21 lines
Quoted 18 lines
Quoted 11 lines
Quoted 10 lines
Quoted 4 lines

This should be backported to mesa 11.2 I guess, could you please send a v2 with this minor fix and add the cc thing?

Sure, as soon as we're done bikeshedding on the "," :)

Regards,

Hans

--
-Samuel
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev