[llvm-dev] LLVM Kaleidoscope : Compiling to Object Code - Segmentation Fault
preejackie via llvm-dev
llvm-dev at lists.llvm.org
Fri Jan 25 11:37:55 PST 2019
Hi David
On 25/01/19 4:12 AM, David Blaikie wrote:
> Still haven't had much luck reproducing this
> On Thu, Jan 24, 2019 at 1:19 PM preejackie
> <praveenvelliengiri at gmail.com <mailto:praveenvelliengiri at gmail.com>>
> wrote:
>
> Hi David!
>
> Thanks for reaching out, the codegen part of the tutorial is fine,
> but when I try to generate the object code file, it throws
> segfault. Also please note that I'm using release build of llvm,
> actually I don't know whether that is the root cause or not.
>
> I also run through valgrind, it seems like a invalid read from stack.
>
> |||Error Summary:
> |
>
> |1 errors in context 1 of 1:
> ==4153== Invalid read of size 1
> ==4153== at 0x4AFEE0:
> llvm::optional_detail::OptionalStorage<llvm::Reloc::Model,
> true>::OptionalStorage(llvm::optional_detail::OptionalStorage<llvm::Reloc::Model,
> true> const&) (in /home/preejackie/kld/toy)
> ==4153== by 0x4B098D:
> llvm::RegisterTargetMachine<llvm::X86TargetMachine>::Allocator(llvm::Target
> const&, llvm::Triple const&, llvm::StringRef, llvm::StringRef,
> llvm::TargetOptions const&, llvm::Optional<llvm::Reloc::Model>,
> llvm::Optional<llvm::CodeModel::Model>, llvm::CodeGenOpt::Level,
> bool) (in /home/preejackie/kld/toy)
> ==4153== by 0x46CE5B: createTargetMachine (TargetRegistry.h:397)
> ==4153== by 0x46CE5B: main (kjit.cpp:1337)
> ==4153== Address 0x4 is not stack'd, malloc'd or (recently) free'd
> |
>
> Source compile command : clang++ -g -O3 kjit.cpp `llvm-config
> --cxxflags --ldflags --system-libs --libs all` -o toy
>
> Please, let me know that if you need some additional information :)
>
> Thanks a lot
>
>
> Oh, hmm, this might be that ABI problem
> https://bugs.llvm.org/show_bug.cgi?id=39427 - if the release you're
> using was built with GCC and you're building your code with Clang,
> that could be it.
>
> Maybe try building with GCC?
>
Yes, I tried to compile with GCC it works fine.
Thanks a lot
> On 25/01/19 1:47 AM, David Blaikie wrote:
>> Hi there!
>>
>> Sorry to hear you're having trouble with the examples & thanks
>> for reaching out.
>>
>> I'm having some difficulty reproducing the failure mode you
>> described. From the code sample, it sounds like you're in Chapter
>> 8 and I just took a look at Chapter 8 in my debug build and got
>> this result:
>>
>> $ ./bin/Kaleidoscope-Ch8
>> ready> def average(x y) (x + y) * 0.5;
>> Read function definition:
>> define double @average(double %x, double %y) {
>> entry:
>> %y2 = alloca double
>> %x1 = alloca double
>> store double %x, double* %x1
>> store double %y, double* %y2
>> %x3 = load double, double* %x1
>> %y4 = load double, double* %y2
>> %addtmp = fadd double %x3, %y4
>> %multmp = fmul double %addtmp, 5.000000e-01
>> ret double %multmp
>> }
>>
>>
>> Any ideas what you might be doing differently that I could do to
>> try to reproduce the failure you're seeing?
>>
>> On Thu, Jan 24, 2019 at 9:36 AM preejackie via llvm-dev
>> <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>>
>> Hi all :)
>>
>> I'm new to llvm!
>>
>> I'm going through the kaleidoscope : compiling llvm IR to
>> object code tutorial, code in the listings breaks and causes
>> a segmentation fault. After some investigation through gdb,
>> probably this constructor call, causing the segfault.
>>
>> |Program received signal SIGSEGV, Segmentation fault.||
>> ||0x00000000004afee0 in
>> llvm::optional_detail::OptionalStorage<llvm::Reloc::Model,
>> true>::OptionalStorage(llvm::optional_detail::OptionalStorage<llvm::Reloc::Model,
>> true> const&) ()|
>>
>> |Source code: |
>>
>> TargetOptions opt;
>> autoRM =Optional<Reloc::Model>();
>> autoTheTargetMachine =
>> Target->createTargetMachine(TargetTriple, CPU, Features, opt,
>> RM);
>>
>> Whether this behavior is already notified and is there any
>> workaround available for it ? I would be great to know the
>> root cause for this behavior.
>>
>> Of course, the kaleidoscope is friendly and good introduction
>> to llvm for beginners, thank you very much for developing :)
>>
>> Thanks for your kind help
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190126/be2fbe94/attachment-0001.html>
More information about the llvm-dev
mailing list