<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>12631</bug_id>
          
          <creation_ts>2018-03-28 08:04:37 +0000</creation_ts>
          <short_desc>Go 1.10 generates invalid code</short_desc>
          <delta_ts>2018-10-29 15:17:40 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>devtools / tool chain</component>
          <version>2.5</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>2.6 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Otavio Salvador">otavio</reporter>
          <assigned_to name="Khem Raj">raj.khem</assigned_to>
          <cc>matt</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>otavio</cc>
    
    <cc>raj.khem</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>ross.burton</cc>
    
    <cc>stephano</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>Regression (Used to work)</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>80004</commentid>
    <comment_count>0</comment_count>
    <who name="Otavio Salvador">otavio</who>
    <bug_when>2018-03-28 08:04:37 +0000</bug_when>
    <thetext>The following code:

&lt;pre&gt;
package main                                                                                                                                           
                                                                                                                                                       
import (                                                                                                                                               
    &quot;net/http&quot;                                                                                                                                         
                                                                                                                                                       
    &quot;github.com/sirupsen/logrus&quot;                                                                                                                       
)                                                                                                                                                      
                                                                                                                                                       
func main() {                                                                                                                                          
    logrus.Info(&quot;starting&quot;)                                                                                                                            
                                                                                                                                                       
    client := &amp;http.Client{}                                                                                                                           
    r, _ := http.NewRequest(&quot;GET&quot;, &quot;https://google.com&quot;, nil)                                                                                          
                                                                                                                                                       
    client.Do(r)                                                                                                                                       
                                                                                                                                                       
    logrus.Info(&quot;started&quot;)                                                                                                                             
}
&lt;/pre&gt;

Works when using 1.9.4 and fails with 1.10. However, when using Go from our host to cross build it for same target, it works fine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80005</commentid>
    <comment_count>1</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2018-03-28 08:27:01 +0000</bug_when>
    <thetext>This bug is filed under &quot;BuildAppliance&quot;. Does it mean the problem is observed in BuildAppliance?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80006</commentid>
    <comment_count>2</comment_count>
    <who name="Otavio Salvador">otavio</who>
    <bug_when>2018-03-28 08:57:46 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; This bug is filed under &quot;BuildAppliance&quot;. Does it mean the problem is
&gt; observed in BuildAppliance?

I chose runtime.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80007</commentid>
    <comment_count>3</comment_count>
    <who name="Matt Madison">matt</who>
    <bug_when>2018-03-28 09:49:50 +0000</bug_when>
    <thetext>I tested the sample code, and it worked fine for me, but I may have been building it differently than Otavio.

MACHINE: qemuarm
- created recipe for the sample code
- added recipe for logrus, set DEPENDS in recipe for sample code to point to it

If you&apos;re using glide or godep or some other Go dependency manager, though, you might be running into an issue with the change in how go1.10 handles build flags. Used to be that if you used the `-linkshared&apos; build flag, the go tool would automatically propagate that build modifier to all packages built.  With go1.10, it now only applies that modifier to packages explicitly listed on the command line.

So go.bbclass might need to be changed to add &quot;-gcflags=all:linkshared -asmflags=all:linkshared&quot; to GOBUILDFLAGS when building against the shared runtime, so that any dependencies being handled internally by godep/glide/go get/etc. get compiled with the correct matching settings.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80008</commentid>
    <comment_count>4</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2018-03-28 09:53:25 +0000</bug_when>
    <thetext>I think this seems a good thing to do. I have few apps which are using other go build systems. 

Matt can you post this change ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80009</commentid>
    <comment_count>5</comment_count>
    <who name="Matt Madison">matt</who>
    <bug_when>2018-03-28 09:59:14 +0000</bug_when>
    <thetext>Yes, I&apos;ll work up a patch for that change.  Hopefully Otavio can verify that it actually helps with this particular issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80010</commentid>
    <comment_count>6</comment_count>
    <who name="Otavio Salvador">otavio</who>
    <bug_when>2018-03-28 10:56:34 +0000</bug_when>
    <thetext>The suggested change does not build.

Log data follows:
| DEBUG: Executing shell function do_compile
| invalid value &quot;all:linkshared&quot; for flag -gcflags: missing =&lt;value&gt; in &lt;pattern&gt;=&lt;value&gt;
| usage: list [-e] [-f format] [-json] [build flags] [packages]
| Run &apos;go help list&apos; for details.
| invalid value &quot;all:linkshared&quot; for flag -gcflags: missing =&lt;value&gt; in &lt;pattern&gt;=&lt;value&gt;
| usage: install [-i] [build flags] [packages]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80011</commentid>
    <comment_count>7</comment_count>
    <who name="Otavio Salvador">otavio</who>
    <bug_when>2018-03-28 13:51:53 +0000</bug_when>
    <thetext>Using the recipe in:

https://gist.github.com/gustavosbarreto/38216d2c50f9af589b91989dbc9916f3

You can reproduce this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80021</commentid>
    <comment_count>8</comment_count>
      <attachid>4243</attachid>
    <who name="Matt Madison">matt</who>
    <bug_when>2018-03-29 04:58:07 +0000</bug_when>
    <thetext>Created attachment 4243
Patch for testing - not final version

Sorry, I fat-fingered the needed compiler/assembler flags.

I still can&apos;t reproduce the problem with a qemuarm target, but that could be due to compiler output being identical for armv5 in the static vs. dynamic linkage case.  I might be able to with another target, will give that a try.

In the meantime, could you try with the attached patch to see if it helps?  I think I&apos;ll need to rework the patch a bit before submitting since the bbclass needs to work with both 1.9.4 and 1.10, but only 1.10 supports the new flag format, but this should at least tell me whether I&apos;m on the right track.

Thanks,
-Matt</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80022</commentid>
    <comment_count>9</comment_count>
    <who name="Otavio Salvador">otavio</who>
    <bug_when>2018-03-29 07:20:31 +0000</bug_when>
    <thetext>It does not seem to help.

The issue seems to happen in ARM using hardfp. Also, we found that if we use &quot;http&quot; instead of &quot;http&quot;, it &quot;works&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80047</commentid>
    <comment_count>10</comment_count>
    <who name="Matt Madison">matt</who>
    <bug_when>2018-03-30 15:13:21 +0000</bug_when>
    <thetext>I can reproduce this now on an ARMv7 target, provided the image also includes the ca-certificates package.  Also, you have to wait until /dev/random has enough entropy.

I can also reproduce this natively by building go 1.10 from source, building a shared runtime with &apos;go install -linkshared -buildmode=shared std&apos;,  and doing a &apos;go get -linkshared github.com/gustavosbarreto/go-crazy&apos;.  So it&apos;s not ARM-specific.

It&apos;s a panic due to a segfault, always appearing to happen around a sync.Pool request in logrus&apos;s Entry.log function.  However, it only seems to happen if the https request is also getting processed in other goroutines.  Panic tracebacks always point to the logrus package as the running thread, sometimes with and sometimes without other goroutines being active.

It does seem to happen only when the program is linked against shared runtime, not when linked statically.

Definitely an upstream issue, just not 100% sure that it&apos;s really in the Go runtime, or if logrus is misusing the sync package.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80065</commentid>
    <comment_count>11</comment_count>
    <who name="Otavio Salvador">otavio</who>
    <bug_when>2018-04-02 06:41:14 +0000</bug_when>
    <thetext>I am glad you succeed in reproducing it. Did you find any upstream issue related to it?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80066</commentid>
    <comment_count>12</comment_count>
    <who name="Matt Madison">matt</who>
    <bug_when>2018-04-02 07:44:47 +0000</bug_when>
    <thetext>I haven&apos;t found an upstream bug report that matches this exactly, and it&apos;s hard to know whether the root cause is in the go shared runtime support or in the logrus package.

Some possibly related issues:
https://github.com/golang/go/issues/23199
https://github.com/sirupsen/logrus/issues/740
https://bugzilla.redhat.com/show_bug.cgi?format=multiple&amp;id=1561619</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80067</commentid>
    <comment_count>13</comment_count>
    <who name="Otavio Salvador">otavio</who>
    <bug_when>2018-04-02 09:03:07 +0000</bug_when>
    <thetext>I reported this upstream: https://github.com/golang/go/issues/24640</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80334</commentid>
    <comment_count>14</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2018-04-19 08:29:56 +0000</bug_when>
    <thetext>Move to 2.6 M1 since this is now not the default for the 2.5 release.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80802</commentid>
    <comment_count>15</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2018-06-18 17:32:07 +0000</bug_when>
    <thetext>Otavio

Can you see if 

https://github.com/sirupsen/logrus/pull/752/commits/8369e2f077642788e2ef31f342a0a4621b2b4607

when applied to logrus fixes the issue or not?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80803</commentid>
    <comment_count>16</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2018-06-18 17:33:56 +0000</bug_when>
    <thetext>We might have to wait until 1.11 release  ( tentative Due by July 31, 2018)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80980</commentid>
    <comment_count>17</comment_count>
    <who name="Stephen K Jolley">sjolley.yp.pm</who>
    <bug_when>2018-06-29 15:04:07 +0000</bug_when>
    <thetext>I have put this into Accepted, since it is not waiting on information, but waiting for an upgrade to be available.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81780</commentid>
    <comment_count>18</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2018-10-08 16:31:48 +0000</bug_when>
    <thetext>I think we have to move this to 2.7 which 1.11 has been released, we might not be able to integrate that into 2.6 as of now, given the release is so close.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81919</commentid>
    <comment_count>19</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2018-10-19 03:05:32 +0000</bug_when>
    <thetext>Posted patch to ml.

https://patchwork.openembedded.org/series/14602/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81965</commentid>
    <comment_count>20</comment_count>
    <who name="Khem Raj">raj.khem</who>
    <bug_when>2018-10-29 15:17:40 +0000</bug_when>
    <thetext>this is fixed</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>4243</attachid>
            <date>2018-03-29 04:58:07 +0000</date>
            <delta_ts>2018-03-29 04:58:07 +0000</delta_ts>
            <desc>Patch for testing - not final version</desc>
            <filename>0001-go-set-compiler-and-assembler-flags-when-using-share.patch</filename>
            <type>text/plain</type>
            <size>1991</size>
            <attacher name="Matt Madison">matt</attacher>
            
              <data encoding="base64">RnJvbSAyYjFiMzIxNTIzZWMxMTUwZTU3NmM3MDBjY2Y3MDk0MTM0ZjBkMmU3IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXR0IE1hZGlzb24gPG1hdHRAbWFkaXNvbi5zeXN0ZW1zPgpE
YXRlOiBUaHUsIDI5IE1hciAyMDE4IDA0OjQ4OjI1IC0wNzAwClN1YmplY3Q6IFtQQVRDSF0gZ286
IHNldCBjb21waWxlciBhbmQgYXNzZW1ibGVyIGZsYWdzIHdoZW4gdXNpbmcgc2hhcmVkCiBydW50
aW1lCgpJbiBnbzEuMTAsIHRoZSBidWlsZCB0b29sIG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