how to disable inlining of ldc2 when 'dub build --build=release'?

lixiaozi via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 22 03:34:23 PDT 2017


On Saturday, 20 May 2017 at 08:08:38 UTC, Johan Engelen wrote:
> On Saturday, 20 May 2017 at 08:02:26 UTC, lixiaozi wrote:
>> [...]
>> I noticed it's the inline optimization in ldc2 that caused the 
>> crash.
>
> If you are certain that your code is 100% correct, please file 
> a bug report. Inlining is done by LLVM and it is rare to find 
> an LLVM bug like that (what architecture are you on, x86?).
>
>> so, what should i do to disable inlining of ldc2 in release 
>> build?
>
> You can try disabling inlining of a specific function 
> (pragma(inline, false)), or disabling optimization inside a 
> function (@optStrategy("none")).
>
> -Johan

Thanks.

> On Saturday, 20 May 2017 at 08:02:26 UTC, lixiaozi wrote:
>> [...]
>> I noticed it's the inline optimization in ldc2 that caused the 
>> crash.
>
> If you are certain that your code is 100% correct, please file 
> a bug report. Inlining is done by LLVM and it is rare to find 
> an LLVM bug like that (what architecture are you on, x86?).
I'm not so sure about the 100% correct. It's just the 
"disable-inlining" flag that make thought it's a inline problem.

>> so, what should i do to disable inlining of ldc2 in release 
>> build?
>
> You can try disabling inlining of a specific function 
> (pragma(inline, false)), or disabling optimization inside a 
> function (@optStrategy("none")).
>
> -Johan
I've just tried these.
(pragma(inline, false)) didn't work and (@optStrategy("none")) 
produced a error of "Error: undefined identifier 'optStrategy'.

Here's some info.
== <uname -a>
Linux centosServer 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 
15:04:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
==
== <ldc2 --version>
LDC - the LLVM D compiler (1.2.0):
   based on DMD v2.072.2 and LLVM 4.0.0
   built with LDC - the LLVM D compiler (1.2.0)
   Default target: x86_64-unknown-linux-gnu
   Host CPU: haswell
   http://dlang.org - http://wiki.dlang.org/LDC

   Registered Targets:
     x86    - 32-bit X86: Pentium-Pro and above
     x86-64 - 64-bit X86: EM64T and AMD64
==
== <dub --version>
DUB version 1.2.1, built on Feb 17 2017
==
== <file uploadTest>
uploadTest: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), 
dynamically linked (uses shared libs), for GNU/Linux 2.6.32, 
BuildID[sha1]=ef04c21ce824390619013256378b3dda8e6caf67, not 
stripped
==
== <gdb uploadTest core.6722>
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show 
copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from 
/home/senter/uploadserverTest/uploadTest...done.
[New LWP 6726]
[New LWP 6728]
[New LWP 6730]
[New LWP 6724]
[New LWP 6722]
[New LWP 6727]
[New LWP 6725]
[New LWP 6729]
[New LWP 6723]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `uploadTest'.
Program terminated with signal 6, Aborted.
#0  0x00007f5e1b1681d7 in __GI_raise (sig=sig at entry=6)
     at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) bt
#0  0x00007f5e1b1681d7 in __GI_raise (sig=sig at entry=6)
     at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007f5e1b1698c8 in __GI_abort () at abort.c:90
#2  0x00007f5e1b503e45 in _Unwind_Resume (exc=0x7f5e1670f3e8)
     at ../../../libgcc/unwind.inc:234
#3  0x00000000004ae9fa in vibe.core.core.CoreTask.run() 
(this=<optimized out>)
     at core.d:1216
#4  0x0000000000536b49 in fiber_entryPoint ()
#5  0x0000000000000000 in ?? ()
(gdb)
== uploadTest is the executable build by dub in release-debug 
mode.
== <and the code that corrupted the app>
try
{
         writeln("post begin--------------------");
         writeln("picanalyseurl", picanalyseurl);
         auto httpanalyse = HTTP(picanalyseurl.idup);
         httpanalyse.handle.set(CurlOption.timeout,10);
         scope char[] content = 
post(picanalyseurl.idup,picanalysemsg.idup,httpanalyse);
         writeln(cast(string)content);
         writeln("post end ------------------");
}
catch(Throwable ee)
{
         writeln(ee.msg);
}
== for now the variable 'picanalyseurl' is invalid, so there'll 
always a exception.
== <the corrupted screenshot>
picanalyseurl:http://127.0.0.1:8721/picanalyse
picanalysemsg:meid=8C1F780876BB489A&picname=8C1F780876BB489A_201702210000000001.jpg&uploaddt=2017-05-19 11:12:32&analyseMode=0&analysePicname=&picanalyseregion=
post begin--------------------
picanalyseurlhttp://127.0.0.1:8721/picanalyse
Aborted(core dump)
==

Thanks.



More information about the Digitalmars-d-learn mailing list