Hard to reproduce segmentation fault in generated binary

41 views
Skip to first unread message

Stepan Koltsov

unread,
Aug 22, 2012, 3:07:43 PM8/22/12
to clay-l...@googlegroups.com
Hi.

Program: https://gist.github.com/3428355

compiled with clay from master:

>>> clay -O2 ./aaa.clay

executed as:

>>> ./aaa

results in segmentation fault.

MacOS X 10.8, 64 bit.

If I replace record `Backtrace` with its content array (comment lines 10-11, uncomment 12-13), code begins to work fine. If I turn off optimization, code also begins to work fine. This is a minimal example I could get to crash the program. But example is still large, so probably you won't reproduce it.

Note, `showBacktraceMine` is not really called, but content of this function affects code generation. This seems like LLVM bug, right? Or maybe I missed something obvious?

--
Stepa

Stepan Koltsov

unread,
Aug 25, 2012, 11:35:49 AM8/25/12
to clay-l...@googlegroups.com
Program crashes exactly the same on Ubuntu 12.04 x86_64.

--
Stepa

Joe Groff

unread,
Aug 25, 2012, 11:55:55 AM8/25/12
to clay-l...@googlegroups.com
It may be an LLVM bug, or there may be undefined behavior in the
generated LLVM IR, or the IR might be invalid because of a compiler
bug. If you haven't already, you could try building clay against an
assertions-enabled LLVM build to see if your program trips any LLVM
assertions.

-Joe

Stepan Koltsov

unread,
Aug 25, 2012, 11:58:40 AM8/25/12
to clay-l...@googlegroups.com


I just did, and no LLVM assertions fired. Digging further.

--
Stepa

Stepan Koltsov

unread,
Aug 25, 2012, 3:08:45 PM8/25/12
to clay-l...@googlegroups.com


I've found a problem: local memory of inlined function is not reused for another functions after return of inlined:

https://gist.github.com/3469333

Clang has the same problem:

https://gist.github.com/3469192
 
GCC doesn't.

Is it Clay and Clang bug or LLVM bug?

--
Stepan Koltsov

Joe Groff

unread,
Aug 25, 2012, 3:18:38 PM8/25/12
to clay-l...@googlegroups.com
On Sat, Aug 25, 2012 at 12:08 PM, Stepan Koltsov
<stepan....@gmail.com> wrote:
>
> I've found a problem: local memory of inlined function is not reused for
> another functions after return of inlined:
>
> https://gist.github.com/3469333
>
> Clang has the same problem:
>
> https://gist.github.com/3469192
>
> GCC doesn't.
>
> Is it Clay and Clang bug or LLVM bug?

Likely an LLVM bug. In either case, you should file a bug with the
LLVM project. Unfortunately, the llvm.org site appears to be down (for
me at least).

-Joe

Stepan Koltsov

unread,
Aug 25, 2012, 3:53:02 PM8/25/12
to clay-l...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages