Giter VIP home page Giter VIP logo

Comments (12)

steinerkelvin avatar steinerkelvin commented on July 17, 2024

Those examples are incomplete, you have to follow the link on the top of each table.

Will add something to make this clear.

from hvm.

01mf02 avatar 01mf02 commented on July 17, 2024

I see. Still, I believe that even the incomplete example should not segfault ... ;)

from hvm.

steinerkelvin avatar steinerkelvin commented on July 17, 2024

even the incomplete example should not segfault

Oh, you are right! This should be investigated.

I guess that is allocating nodes ad infinitum. A better allocator is needed, indeed, as per #38 .

from hvm.

VictorTaelin avatar VictorTaelin commented on July 17, 2024

Yes, finding where this (and any other) segfault comes from is very important so we can put the right checks and error handlers in place. Thanks for the issue.

from hvm.

nothingnesses avatar nothingnesses commented on July 17, 2024

@01mf02 I'm not able to reproduce the segfault. I'm also using commit 1da2875. Just to be clear, are you compiling the whole contents of this file, or just the incomplete snippet from the README? I don't think the incomplete snippet would work, as it's missing some definitions, e.g. App, right? Here's what I did:

bash-5.1$ git rev-parse HEAD
1da287553156dae87b23e1170575af7d73c4531c
bash-5.1$ nix build
bash-5.1$ cd bench/LambdaArithmetic/
bash-5.1$ ../../result/bin/hvm c main.hvm
Compiled to 'main.c'.
bash-5.1$ clang -O2 main.c -o main -lpthread
bash-5.1$ ./main 25
Rewrites: 65483 (0.38 MR/s).
Mem.Size: 78118 words.

822584320
bash-5.1$

from hvm.

01mf02 avatar 01mf02 commented on July 17, 2024

@nothingnesses: Ok, so here is what I did: I installed HVM with cargo install --git https://github.com/Kindelia/HVM and then made a main.hvm that contains precisely the code I posted in my original post; that is, the incomplete snippet from the README. Then I used hvm c main && clang -O2 main.c -o main -lpthread to compile. Following this, ./main 25 gives the mentioned segfault.

By the way, the interpreter (?) also crashes on the same file, but with a stack overflow:

$ hvm r main 5
Reducing.

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)

from hvm.

FranchuFranchu avatar FranchuFranchu commented on July 17, 2024

Main = λ(Main) throws a stack overflow for me in the "interpreter". I think these two stack overflows might be related

from hvm.

VictorTaelin avatar VictorTaelin commented on July 17, 2024

Main = λ(Main) throws a stack overflow because it is an infinite expression! HVM finishes stringification before printing, can't print infinite terms (yet). It would be cool if it printed lazily, like GHC, though.

from hvm.

FranchuFranchu avatar FranchuFranchu commented on July 17, 2024

This has the rather confusing consequence that forgetting to apply a lambda that calls a recursive constructor with an end-case throws a stack overflow

(Q 0) = HelloWorld
(Q a) = (Q (- a 1))
Lambda = λa(Q (- a 1))
Main = ((Lambda) 1) // => (HelloWorld)
Main = ((Lambda)) // => [stack overflow]

from hvm.

VictorTaelin avatar VictorTaelin commented on July 17, 2024

Yes, I'm aware. I'm already working on a higher-level, statically typed language that compiles to HVM, which will solve these issues too!

from hvm.

lawcho avatar lawcho commented on July 17, 2024

Main = λ(Main) throws a stack overflow because it is an infinite expression! HVM finishes stringification before printing, can't print infinite terms (yet). It would be cool if it printed lazily, like GHC, though.

So readback is the function that is crashing?

I'm getting similar issues (#151), but the problem seems to be in the ffi_normal function (the second debug never fires):

https://github.com/Kindelia/HVM/blob/71065d3bcd3d33c4b7a38ec69cb98598ae36d5f0/src/runtime.c#L1440-L1442

from hvm.

VictorTaelin avatar VictorTaelin commented on July 17, 2024

Should be working on master. If the problem is still present, please reopen the issue.

from hvm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.