Ticket #226 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Type vtable needs types assignments for strict aliasing

Reported by: scoder Owned by: scoder
Priority: major Milestone: 0.11
Component: Code Generation Keywords:
Cc:

Description

When setting up the vtable of a type, the methods are first copied from the vtable of the superclass and then each overridden method is cast to (void(**)(void)) on assignment in the vtable as follows.

  __pyx_vtable_4lxml_5etree__XSLTContext.__pyx_base = *__pyx_vtabptr_4lxml_5etree__BaseContext;

  *(void(**)(void))&__pyx_vtable_4lxml_5etree__XSLTContext.__pyx_base._copy = (void(*)(void))__pyx_f_4lxml_5etree_12_XSLTContext__copy;

Strict aliasing rules will allow the C compiler to execute the assignments in any order, which may let the first assignment overwrite the second, thus corrupting the vtable.

This can be prevented by getting rid of the cast on the LHS, which requires figuring out the correct signature of the function to cast the RHS (which is required because of the different self parameter).

Change History

Changed 4 years ago by scoder

  • owner changed from somebody to scoder
  • status changed from new to assigned
  • milestone changed from wishlist to 0.11

Changed 4 years ago by scoder

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.