lukewagner / polyfill-prototype-1

Experimental WebAssembly polyfill library and tools
Apache License 2.0
241 stars 42 forks source link

AstMemory invokes undefined behavior on alignment #10

Closed kripken closed 9 years ago

kripken commented 9 years ago

I am porting the packer to JS for #9. While doing so I noticed that it does an unaligned write to a double. The issue is that AstMemory simply returns a pointer and bumps the current position in the arena. Many of the sizes it allocates are not multiples of 8, so DoubleNode, which stores a double, can get misaligned.

Am I missing something here?

I'll make it just allocate a number of bytes that is a multiple of 8 for now. A better option might be separate arenas, etc.

lukewagner commented 9 years ago

d'oh, aligning the allocations sounds right.