~pepe/good-place

3

[Trolley] Fiber and segmentation fault

Details
Message ID
<20210519142803.47ab7cea@Denis.localdomain>
DKIM signature
pass
Download raw message
Hello,

I'm looking for a simple router library in Janet, and Trolley seems
very good!

But I get a seg fault when I'm using it in a fiber, and using ":" in
the route.
Minimal step to reproduce:
```
(import trolley)
(def f (fiber/new (fn []
           (trolley/router {"/:id" |(pp "")}))))
(ev/go f)
```
It doesn't fail in the repl...

When looking at the code, there is this "dyn" todo. Is it related? I
tried but I'm quite new in Janet.

Have you any idea?

Thank you in advance,
Denis

Re: [Trolley] Fiber and segmentation fault

Details
Message ID
<CAO6HGbWfwCBDiu9wQSrrpfwdzWPadzk+9v5ev9tad4WwJ_qQ+g@mail.gmail.com>
In-Reply-To
<20210519142803.47ab7cea@Denis.localdomain> (view parent)
DKIM signature
missing
Download raw message
Hello, thank you very much for trying Trolley.

I am using it in fibers routinely, but I guess there definitely could
be some bug. I am leaving the computer for the vaccine shot in a short
time, but I will try to look into it later tonite and write back.

Cheers Pepe

st 19. 5. 2021 v 16:28 odesílatel denis <denis@ecaf.be> napsal:
>
> Hello,
>
> I'm looking for a simple router library in Janet, and Trolley seems
> very good!
>
> But I get a seg fault when I'm using it in a fiber, and using ":" in
> the route.
> Minimal step to reproduce:
> ```
> (import trolley)
> (def f (fiber/new (fn []
>            (trolley/router {"/:id" |(pp "")}))))
> (ev/go f)
> ```
> It doesn't fail in the repl...
>
> When looking at the code, there is this "dyn" todo. Is it related? I
> tried but I'm quite new in Janet.
>
> Have you any idea?
>
> Thank you in advance,
> Denis



-- 
Ing. Josef Pospíšil
LastStar.eu - CTO
+420774278707 - iMessage, Telegram
@damnpepe - Twitter

Re: [Trolley] Fiber and segmentation fault

Details
Message ID
<CAO6HGbWfO5T7OU_3VpK_iPiUmQ6DqoDbAKWSN1H=mH85hcGhEw@mail.gmail.com>
In-Reply-To
<20210519142803.47ab7cea@Denis.localdomain> (view parent)
DKIM signature
missing
Download raw message
Just a quick test with slightly changed code works fine. I guess there
is some problem in creating new fiber without correct blocking.

```
(import trolley)
(def f (coro (pp ((trolley/router {"/:id" :root}) "/10"))))
(ev/go f)
```
As I said, I will look into it later, but I suspect, there is
something wrong with Janet itself in this case.

st 19. 5. 2021 v 16:28 odesílatel denis <denis@ecaf.be> napsal:
>
> Hello,
>
> I'm looking for a simple router library in Janet, and Trolley seems
> very good!
>
> But I get a seg fault when I'm using it in a fiber, and using ":" in
> the route.
> Minimal step to reproduce:
> ```
> (import trolley)
> (def f (fiber/new (fn []
>            (trolley/router {"/:id" |(pp "")}))))
> (ev/go f)
> ```
> It doesn't fail in the repl...
>
> When looking at the code, there is this "dyn" todo. Is it related? I
> tried but I'm quite new in Janet.
>
> Have you any idea?
>
> Thank you in advance,
> Denis



-- 
Ing. Josef Pospíšil
LastStar.eu - CTO
+420774278707 - iMessage, Telegram
@damnpepe - Twitter

Re: [Trolley] Fiber and segmentation fault

Details
Message ID
<CAO6HGbWZfzaJUfPzoVouTVHd7isj8Hj9-41TmjNuPWZKcr41oA@mail.gmail.com>
In-Reply-To
<CAO6HGbWfO5T7OU_3VpK_iPiUmQ6DqoDbAKWSN1H=mH85hcGhEw@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
After a little more investigation, I have found that the issue is
caused by the environment given to fiber (none in the example you
gave), so when you inherit or set the prototype for the created fiber,
it again works fine.

```
(import trolley)
(def f
  (fiber/new
    (fn []
      (trolley/router {"/:id" print})) :p)) # or :i

(ev/go f)
```
Anyway, I think you found a bug in the fibers with the `ev` and I have
created an issue on the janet-lang repository
https://github.com/janet-lang/janet/issues/701.

Thank you very much for the report. If you have any questions about
the trolley or any other good-place lib, I am be glad to help.

Cheers

st 19. 5. 2021 v 17:43 odesílatel Josef Pospíšil
<josef.pospisil@laststar.eu> napsal:
>
> Just a quick test with slightly changed code works fine. I guess there
> is some problem in creating new fiber without correct blocking.
>
> ```
> (import trolley)
> (def f (coro (pp ((trolley/router {"/:id" :root}) "/10"))))
> (ev/go f)
> ```
> As I said, I will look into it later, but I suspect, there is
> something wrong with Janet itself in this case.
>
> st 19. 5. 2021 v 16:28 odesílatel denis <denis@ecaf.be> napsal:
> >
> > Hello,
> >
> > I'm looking for a simple router library in Janet, and Trolley seems
> > very good!
> >
> > But I get a seg fault when I'm using it in a fiber, and using ":" in
> > the route.
> > Minimal step to reproduce:
> > ```
> > (import trolley)
> > (def f (fiber/new (fn []
> >            (trolley/router {"/:id" |(pp "")}))))
> > (ev/go f)
> > ```
> > It doesn't fail in the repl...
> >
> > When looking at the code, there is this "dyn" todo. Is it related? I
> > tried but I'm quite new in Janet.
> >
> > Have you any idea?
> >
> > Thank you in advance,
> > Denis
>
>
>
> --
> Ing. Josef Pospíšil
> LastStar.eu - CTO
> +420774278707 - iMessage, Telegram
> @damnpepe - Twitter



-- 
Ing. Josef Pospíšil
LastStar.eu - CTO
+420774278707 - iMessage, Telegram
@damnpepe - Twitter
Reply to thread Export thread (mbox)