🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

error compiling on gcc/x64 with address sanitizer

Started by
5 comments, last by WitchLord 6 years, 9 months ago

Is this the right place to report errors in AngelScript?

I have found a compile error that affects both v2.31.2 and the latest svn.  I am using gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 running on Lubuntu 16.04.3 LTS.  The error is in as_callfunc_x64_gcc.cpp.  Without address sanitizer, the file compiles correctly, but with address sanitizer, I get the following error message:


angelscript/source/as_callfunc_x64_gcc.cpp: In function ‘asQWORD X64_CallFunction(const asQWORD*, int, funcptr_t, asQWORD&, bool)’:
angelscript/source/as_callfunc_x64_gcc.cpp:162:82: error: ‘asm’ operand has impossible constraints
  "%rdi", "%rsi", "%rax", "%rdx", "%rcx", "%r8", "%r9", "%r10", "%r11", "%r15");
                                                                               ^

The root cause appears to be register exhaustion due to address sanitizer reserving some registers for its own use.  Changing the "r" constraints on the input parameters to "g" constraints appears to fix the problem:


Index: angelscript/source/as_callfunc_x64_gcc.cpp
===================================================================
--- angelscript/source/as_callfunc_x64_gcc.cpp	(revision 2407)
+++ angelscript/source/as_callfunc_x64_gcc.cpp	(working copy)
@@ -157,7 +157,7 @@
 		"  movq %%rdx, %4 \n"
 		"endcall: \n"
 
-		: : "r" ((asQWORD)cnt), "r" (args), "r" (func), "m" (retQW1), "m" (retQW2), "m" (returnFloat)
+		: : "g" ((asQWORD)cnt), "g" (args), "g" (func), "m" (retQW1), "m" (retQW2), "m" (returnFloat)
 		: "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", 
 		  "%rdi", "%rsi", "%rax", "%rdx", "%rcx", "%r8", "%r9", "%r10", "%r11", "%r15");

 

Advertisement

Yes, this is the correct place for reporting problems on AngelScript :)

Thanks for letting me know about the problem and the potential solution. I'll be sure to check it out and if it is correct make the changes as you suggested it.

I'll report back when the problem is fixed.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I didn't encounter any problem compiling the library using address sanitizer with GNUC and Ubuntu 64bit.

What other compiler options are you using? Perhaps it is a specific combination of compiler options that causes the problem you reported.

I used the following:


g++ -m64 -std=c++11 -fsanitize=address -Wall -fPIC -fno-strict-aliasing -o obj/as_callfunc_x64_gcc.o -c ../../source/as_callfunc_x64_gcc.cpp

 

 

 

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I used the bare minimum to compile the file, i.e. "g++ -fsanitize=address -c angelscript/source/as_callfunc_x64_gcc.cpp". However, I am getting the same error when I use your command line. Maybe you're testing on a different version of gcc? Like I wrote in my original post, I'm running gcc 5.4.0 on Lubuntu 16.4 LTS (Xenial Xerus).

I'm running g++ 4.8.4 on Ubuntu 14.04.

I'll upgrade g++ and see if that allow me to reproduce the problem.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

That was it. After updating g++ to 5.4.1 the problem was reproduced.

I've checked in your fix under revision 2410.

Thanks,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement