[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] ash: fix a crash on arm when building with clang.
From:       Yunlian Jiang <yunlian () google ! com>
Date:       2017-12-29 0:22:47
Message-ID: CAMsPy2vJNbN0qv0rad51x-67gqgTmWH_hfrCmwoHzc+4SXKxYA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Sorry about the confusion. My build system changed the compiler back to gcc
when I try to apply the patch and the patch does not help.

However, the patch below helps

@@ -173,7 +173,11 @@ struct lineedit_statics {
 };

 /* See lineedit_ptr_hack.c */
-extern struct lineedit_statics *const lineedit_ptr_to_statics;
+#ifndef GCC_COMBINE
+extern struct lineedit_statics *lineedit_ptr_to_statics;
+#else
+extern struct lineedit_statics *const lineedit_ptr_to_statics
__attribute__ ((section (".data")));
+#endif

 #define S (*lineedit_ptr_to_statics)
 #define state            (S.state           )

On Wed, Dec 20, 2017 at 7:44 PM, Kang-Che Sung <explorer09@gmail.com> wrote:

> On Thu, Dec 21, 2017 at 5:32 AM, Yunlian Jiang <yunlian@google.com> wrote:
> >
> > When I run
> > busybox ash on an arm device with busybox built with clang 6.
> > I got a segmentation fault
> > in the macro
> > #define INIT_S() do { \
> > (*(struct lineedit_statics**)&lineedit_ptr_to_statics) =
> xzalloc(sizeof(S)); \
> > barrier(); \
> > cmdedit_termw = 80; \
> > IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \
> > IF_FEATURE_EDITING_VI(delptr = delbuf;) \
> > } while (0)
> >
> > With the patch below, the segmentation disappears.
> >
> > --- busybox-1.27.2/libbb/lineedit.c
> > +++ busybox-1.27.2/libbb/lineedit.c
> > @@ -197,8 +197,8 @@ extern struct lineedit_statics *const li
> >   (*(struct lineedit_statics**)&lineedit_ptr_to_statics) =
> xzalloc(sizeof(S)); \
> >   barrier(); \
> >   cmdedit_termw = 80; \
> > - IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \
> > - IF_FEATURE_EDITING_VI(delptr = delbuf;) \
> > + IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;); \
> > + IF_FEATURE_EDITING_VI(delptr = delbuf;); \
> >  } while (0)
> >
> >  static void deinit_S(void)
>
> What's the problem of the missing semicolons in the build? BusyBox has been
> using these constructs almost everywhere. And they should succeed.
>
> Could you show us the generated code differences?
> It looks like a bug in the compiler, and nothing to do with Busybox.
>

[Attachment #5 (text/html)]

<div dir="ltr">Sorry about the confusion. My build system changed the compiler back \
to gcc when I try to apply the patch and the patch does not \
help.<div><br></div><div>However, the patch below \
helps</div><div><br></div><div><div>@@ -173,7 +173,11 @@ struct lineedit_statics \
{</div><div>  };</div><div>  </div><div>  /* See lineedit_ptr_hack.c \
*/</div><div>-extern struct lineedit_statics *const \
lineedit_ptr_to_statics;</div><div>+#ifndef GCC_COMBINE</div><div>+extern struct \
lineedit_statics *lineedit_ptr_to_statics;</div><div>+#else</div><div>+extern struct \
lineedit_statics *const lineedit_ptr_to_statics __attribute__ ((section \
(&quot;.data&quot;)));</div><div>+#endif</div><div>  </div><div>  #define S \
(*lineedit_ptr_to_statics)</div><div>  #define state                  (S.state        \
)</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec \
20, 2017 at 7:44 PM, Kang-Che Sung <span dir="ltr">&lt;<a \
href="mailto:explorer09@gmail.com" \
target="_blank">explorer09@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Dec 21, 2017 at \
5:32 AM, Yunlian Jiang &lt;<a \
href="mailto:yunlian@google.com">yunlian@google.com</a>&gt; wrote:<br> &gt;<br>
&gt; When I run<br>
&gt; busybox ash on an arm device with busybox built with clang 6.<br>
&gt; I got a segmentation fault<br>
&gt; in the macro<br>
&gt; #define INIT_S() do { \<br>
&gt; (*(struct lineedit_statics**)&amp;lineedit_<wbr>ptr_to_statics) = \
xzalloc(sizeof(S)); \<br> &gt; barrier(); \<br>
&gt; cmdedit_termw = 80; \<br>
&gt; IF_USERNAME_OR_HOMEDIR(home_<wbr>pwd_buf = (char*)null_str;) \<br>
&gt; IF_FEATURE_EDITING_VI(delptr = delbuf;) \<br>
&gt; } while (0)<br>
&gt;<br>
&gt; With the patch below, the segmentation disappears.<br>
&gt;<br>
&gt; --- busybox-1.27.2/libbb/lineedit.<wbr>c<br>
&gt; +++ busybox-1.27.2/libbb/lineedit.<wbr>c<br>
&gt; @@ -197,8 +197,8 @@ extern struct lineedit_statics *const li<br>
&gt;     (*(struct lineedit_statics**)&amp;lineedit_<wbr>ptr_to_statics) = \
xzalloc(sizeof(S)); \<br> &gt;     barrier(); \<br>
&gt;     cmdedit_termw = 80; \<br>
&gt; - IF_USERNAME_OR_HOMEDIR(home_<wbr>pwd_buf = (char*)null_str;) \<br>
&gt; - IF_FEATURE_EDITING_VI(delptr = delbuf;) \<br>
&gt; + IF_USERNAME_OR_HOMEDIR(home_<wbr>pwd_buf = (char*)null_str;); \<br>
&gt; + IF_FEATURE_EDITING_VI(delptr = delbuf;); \<br>
&gt;   } while (0)<br>
&gt;<br>
&gt;   static void deinit_S(void)<br>
<br>
</div></div>What&#39;s the problem of the missing semicolons in the build? BusyBox \
has been<br> using these constructs almost everywhere. And they should succeed.<br>
<br>
Could you show us the generated code differences?<br>
It looks like a bug in the compiler, and nothing to do with Busybox.<br>
</blockquote></div><br></div>



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic