December 1st, 2011

Our code needs to run on multiple platforms with different rules, so we follow none of them!

A customer was encountering sporadic crashes in their 64-bit application, and upon investigation, the problem was traced to a misaligned RSP register. We saw some time ago that the Windows x64 calling convention requires the RSP register to be 16-byte aligned. The customer traced the source of the misalignment to a third-party library they were using. They contacted the vendor, who acknowledged that they were not following the Windows x64 calling conventions, but explained that their code needs to run on multiple x64 operating systems, and since each operating system has different calling conventions, they adhere to none of them!

I was kind of boggled by this remark. Yes, it’s frustrating that different operating systems have different calling conventions, but that doesn’t mean that you are welcome to ignore them. Every region of the world has different laws regarding the operation of motorized vehicles, but that doesn’t mean “My truck driver has to drive through all these different jurisdictions with different rules, so he follows none of them!”

Topics
Other

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.