Giter VIP home page Giter VIP logo

Comments (5)

bakpakin avatar bakpakin commented on June 5, 2024 2

@czkz Check now for examples 1 and 3. Example 2 I think should still have some strange behavior, but that is because the construction is strange. I have not yet decided on why the correct behavior here should be - my current thought is that "edefer end" and "main end" should not print, but everything else should.

from janet.

bakpakin avatar bakpakin commented on June 5, 2024

The issue here seems to be with the os_shell function, and the fact that is implemented to run on a another thread, and then schedule the original fiber when it completes.

The second instance is a bit more complex, as the initial deadline cancellation triggers the second piece of code to run, which should also immediately expire the deadline.

from janet.

bakpakin avatar bakpakin commented on June 5, 2024

Hard to tell from just the valgrind output, but I think the invalid read is from calling strlen on a symbol created by (gensym). Most function internal to Janet don't require a trailing 0 byte for strings, but all created strings should have such a byte just in case.

from janet.

czkz avatar czkz commented on June 5, 2024

The issue here seems to be with the os_shell function

Note: replacing os/shell with os/spawn resulted in the same behavior (but both are now fixed).

Check now for examples 1 and 3.

Example 1 is fixed for both os/shell and os/spawn.
Example 3 now produces less errors :)

the invalid read is from calling strlen on a symbol created by (gensym)

Indeed!
This example triggers the valgrind error (even on the new version):

(ev/cancel
  (ev/spawn (ev/sleep 1e9))
  (gensym))

It also spits random garbage in the error, e.g.

error: _00000r0Mw\
                  A
  in _spawn [tst2.janet] on line 2, column 13

from janet.

czkz avatar czkz commented on June 5, 2024

I have not yet decided on why the correct behavior here should be - my current thought is that "edefer end" and "main end" should not print, but everything else should.

It could work as if edefer body was offloaded to a new fiber.
Not necessarily one-to-one, but something similar to this:

(ev/spawn
  (ev/deadline 0.1)
  (edefer
    (ev/spawn # the only line different from example 2
      (print "edefer start")
      (os/shell "sleep 10 && echo sh_edefer")
      (print "edefer end"))
    (print "main start")
    (os/shell "sleep 5 && echo sh_main")
    (print "main end")))

output:

main start
error: deadline expired
edefer start
sh_main
sh_edefer
edefer end

from janet.

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.