preejackie via llvm-dev
2019-Jan-24 17:36 UTC
[llvm-dev] LLVM Kaleidoscope : Compiling to Object Code - Segmentation Fault
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190124/e249da78/attachment.html>
David Blaikie via llvm-dev
2019-Jan-24 20:17 UTC
[llvm-dev] LLVM Kaleidoscope : Compiling to Object Code - Segmentation Fault
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> 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; > auto RM = Optional<Reloc::Model>(); > auto TheTargetMachine > 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 > 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/20190124/de66dfd3/attachment.html>
preejackie via llvm-dev
2019-Jan-24 21:19 UTC
[llvm-dev] LLVM Kaleidoscope : Compiling to Object Code - Segmentation Fault
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 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/20190125/9a9cff23/attachment.html>
Seemingly Similar Threads
- LLVM Kaleidoscope : Compiling to Object Code - Segmentation Fault
- [llvm] r322838 - [ADT] Split optional to only include copy mechanics and dtor for non-trivial types.
- [llvm] r322838 - [ADT] Split optional to only include copy mechanics and dtor for non-trivial types.
- [llvm] r322838 - [ADT] Split optional to only include copy mechanics and dtor for non-trivial types.
- [LLVMdev] Optimization of calls to functions without side effects (from Kaleidoscope example)