<p dir="auto">by <strong>bolin.huang</strong>:</p>
<pre class="notranslate">I notice (maybe a bug) in $GOROOT/src/pkg/net/smtp/smtp.go. When smtp authentication
failed, an error of type textproto.Error will not return to the caller. Just see the
following code:

169 func (c *Client) Auth(a Auth) error {
170     if err := c.hello(); err != nil {
171         return err
172     }
173     encoding := base64.StdEncoding
174     mech, resp, err := a.Start(&amp;ServerInfo{c.serverName, c.tls, c.auth})
175     if err != nil {
176         c.Quit()
177         return err
178     }
179     resp64 := make([]byte, encoding.EncodedLen(len(resp)))
180     encoding.Encode(resp64, resp)
181     code, msg64, err := c.cmd(0, "AUTH %s %s", mech, resp64)
182     for err == nil {
183         var msg []byte
184         switch code {
185         case 334:
186             msg, err = encoding.DecodeString(msg64)
187         case 235:
188             // the last message isn't base64 because it isn't a challenge
189             msg = []byte(msg64)
--------------------------- Here ------------------------
190         default:
191             err = &amp;textproto.Error{Code: code, Msg: msg64}
192         }
193         resp, err = a.Next(msg, code == 334)
---------------------------------------------------------
194         if err != nil {
195             // abort the AUTH
196             c.cmd(501, "*")
197             c.Quit()
198             break
199         }
200         if resp == nil {
201             break
202         }
203         resp64 = make([]byte, encoding.EncodedLen(len(resp)))
204         encoding.Encode(resp64, resp)
205         code, msg64, err = c.cmd(0, string(resp64))
206     }
207     return err
208 }

On line 191, when authentication unsuccessful(in this case the reply code is 535),
textproto.Error will generate but the following code will replace the err, and the error
message will not transfer to a.Next(). So I spent a lot time to debug but found no error
message return, but the error just happen.

I notice this problem because I use smtp to send email with wrong password, but I just
get another error(unable to relay). So I suppose it will return back
"Authentication unsuccessful" instead of "unable to relay". 

Which version are you using?  (run 'go version')
go version go1.1.2 darwin/amd64</pre>
<p dir="auto">Go is broken on HardenedBSD currently. It appears to be from the hand-written assembly code in <code class="notranslate">src/runtime/sys_freebsd_amd64.s</code>. The bug can be triggered simply by attempting to compile go on HardenedBSD 11-CURRENT/amd64.</p>
<p dir="auto">uname -a:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="laptop-dev-01[shawn]:/home/shawn/tmp/go (1) $ uname -a
FreeBSD laptop-dev-01 11.0-CURRENT-HBSD FreeBSD 11.0-CURRENT-HBSD #44 264a80e(hardened/current/master): Wed Aug 12 16:42:41 EDT 2015     shawn@laptop-dev-01:/usr/obj/usr/src/sys/LATT-SEC  amd64"><pre class="notranslate"><code class="notranslate">laptop-dev-01[shawn]:/home/shawn/tmp/go (1) $ uname -a
FreeBSD laptop-dev-01 11.0-CURRENT-HBSD FreeBSD 11.0-CURRENT-HBSD #44 264a80e(hardened/current/master): Wed Aug 12 16:42:41 EDT 2015     shawn@laptop-dev-01:/usr/obj/usr/src/sys/LATT-SEC  amd64
</code></pre></div>
<p dir="auto">gdb backtrace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="laptop-dev-01[shawn]:/usr/ports/lang/go $ sudo gdb ./work/go/pkg/tool/freebsd_amd64/go_bootstrap
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type &quot;show copying&quot; to see the conditions.
There is absolutely no warranty for GDB.  Type &quot;show warranty&quot; for details.
This GDB was configured as &quot;amd64-marcel-freebsd&quot;...
(gdb) run
Starting program: /usr/ports/lang/go/work/go/pkg/tool/freebsd_amd64/go_bootstrap 

Program received signal SIGBUS, Bus error.
0x00000000004a4da0 in runtime.settls () at /usr/local/go/src/runtime/sys_freebsd_amd64.s:286
286     /usr/local/go/src/runtime/sys_freebsd_amd64.s: No such file or directory.
        in /usr/local/go/src/runtime/sys_freebsd_amd64.s
Current language:  auto; currently minimal
(gdb) bt
#0  0x00000000004a4da0 in runtime.settls () at /usr/local/go/src/runtime/sys_freebsd_amd64.s:286
#1  0x00000000008020b0 in runtime.tls0 ()
#2  0x000000000048ce3c in runtime.rt0_go () at /usr/local/go/src/runtime/asm_amd64.s:65
#3  0x0000000000000000 in ?? ()"><pre class="notranslate"><code class="notranslate">laptop-dev-01[shawn]:/usr/ports/lang/go $ sudo gdb ./work/go/pkg/tool/freebsd_amd64/go_bootstrap
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) run
Starting program: /usr/ports/lang/go/work/go/pkg/tool/freebsd_amd64/go_bootstrap 

Program received signal SIGBUS, Bus error.
0x00000000004a4da0 in runtime.settls () at /usr/local/go/src/runtime/sys_freebsd_amd64.s:286
286     /usr/local/go/src/runtime/sys_freebsd_amd64.s: No such file or directory.
        in /usr/local/go/src/runtime/sys_freebsd_amd64.s
Current language:  auto; currently minimal
(gdb) bt
#0  0x00000000004a4da0 in runtime.settls () at /usr/local/go/src/runtime/sys_freebsd_amd64.s:286
#1  0x00000000008020b0 in runtime.tls0 ()
#2  0x000000000048ce3c in runtime.rt0_go () at /usr/local/go/src/runtime/asm_amd64.s:65
#3  0x0000000000000000 in ?? ()
</code></pre></div>