copcall interpreter segfault possible?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

copcall interpreter segfault possible?

Gerhard Preuss
Hi!

As stated here https://github.com/Olivine-Labs/busted/issues/171, I am
observing a segmentation fault (Lua 5.1.5) when using copcall where
pcall should have been used.

Unfortunately it is a rather complex situation but it is reproducible.
lua-ev is involved which itself makes some pcall through the lua API.
copcall and pcall may call each other in this scenario.

Does this sound dangerous? Are there known scenarios where calling
copcall instead of pcall can crash the interpreter due to a badly
behaving C module?

Regards,
Gerhard

Reply | Threaded
Open this post in threaded view
|

RE: copcall interpreter segfault possible?

Thijs Schreijer
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Gerhard Lipp
> Sent: woensdag 5 juni 2013 15:15
> To: [hidden email]
> Subject: copcall interpreter segfault possible?
>
> Hi!
>
> As stated here https://github.com/Olivine-Labs/busted/issues/171, I am
> observing a segmentation fault (Lua 5.1.5) when using copcall where
> pcall should have been used.
>
> Unfortunately it is a rather complex situation but it is reproducible.
> lua-ev is involved which itself makes some pcall through the lua API.
> copcall and pcall may call each other in this scenario.
>
> Does this sound dangerous? Are there known scenarios where calling
> copcall instead of pcall can crash the interpreter due to a badly
> behaving C module?
>
> Regards,
> Gerhard

Not sure whether it fixes your problem. But I just submitted a PR [1] to fix an issue with coxpcall I ran into. You might want to give it a try.

Thijs

[1] https://github.com/keplerproject/coxpcall/pull/1


Reply | Threaded
Open this post in threaded view
|

Re: copcall interpreter segfault possible?

Fabio Mascarenhas
Thanks for the patch, Thijs, but I believe it is unrelated to the problem at hand. I would bet on a misbehaving C library forgetting to do lua_checkstack and causing memory corruption in the heap. 

Running the failing test under valgrind should be instructive, but I see someone closed the original issue, does that mean the cause was found?

--
Fabio Mascarenhas


On Mon, Jun 10, 2013 at 12:11 PM, Thijs Schreijer <[hidden email]> wrote:
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Gerhard Lipp
> Sent: woensdag 5 juni 2013 15:15
> To: [hidden email]
> Subject: copcall interpreter segfault possible?
>
> Hi!
>
> As stated here https://github.com/Olivine-Labs/busted/issues/171, I am
> observing a segmentation fault (Lua 5.1.5) when using copcall where
> pcall should have been used.
>
> Unfortunately it is a rather complex situation but it is reproducible.
> lua-ev is involved which itself makes some pcall through the lua API.
> copcall and pcall may call each other in this scenario.
>
> Does this sound dangerous? Are there known scenarios where calling
> copcall instead of pcall can crash the interpreter due to a badly
> behaving C module?
>
> Regards,
> Gerhard

Not sure whether it fixes your problem. But I just submitted a PR [1] to fix an issue with coxpcall I ran into. You might want to give it a try.

Thijs

[1] https://github.com/keplerproject/coxpcall/pull/1



Reply | Threaded
Open this post in threaded view
|

RE: copcall interpreter segfault possible?

Thijs Schreijer
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Fabio Mascarenhas
> Sent: maandag 10 juni 2013 18:06
> To: Lua mailing list
> Subject: Re: copcall interpreter segfault possible?
>
> Thanks for the patch, Thijs, but I believe it is unrelated to the problem
> at hand.

Yes I agree, it probably is unrelated. But doesn't hurt to try...

> I would bet on a misbehaving C library forgetting to do
> lua_checkstack and causing memory corruption in the heap.

Yes, I also suspect that Lua-EV is the culprit here.

>
> Running the failing test under valgrind should be instructive, but I see
> someone closed the original issue, does that mean the cause was found?
>

No it hasn't. A workaround was pulled in that no longer uses coxpcall with Lua-EV, which resolves the problem at hand, but not its root cause.
I have never use valgrind nor Lua-EV myself, but maybe Gerhard could give it a try?

Thijs

>
> --
> Fabio Mascarenhas
>
> On Mon, Jun 10, 2013 at 12:11 PM, Thijs Schreijer
> <[hidden email]> wrote:
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]]
> On
> > Behalf Of Gerhard Lipp
> > Sent: woensdag 5 juni 2013 15:15
> > To: [hidden email]
> > Subject: copcall interpreter segfault possible?
> >
> > Hi!
> >
> > As stated here https://github.com/Olivine-Labs/busted/issues/171, I am
> > observing a segmentation fault (Lua 5.1.5) when using copcall where
> > pcall should have been used.
> >
> > Unfortunately it is a rather complex situation but it is reproducible.
> > lua-ev is involved which itself makes some pcall through the lua API.
> > copcall and pcall may call each other in this scenario.
> >
> > Does this sound dangerous? Are there known scenarios where calling
> > copcall instead of pcall can crash the interpreter due to a badly
> > behaving C module?
> >
> > Regards,
> > Gerhard
> Not sure whether it fixes your problem. But I just submitted a PR [1] to
> fix an issue with coxpcall I ran into. You might want to give it a try.
>
> Thijs
>
> [1] https://github.com/keplerproject/coxpcall/pull/1
>

Reply | Threaded
Open this post in threaded view
|

Re: copcall interpreter segfault possible?

Gerhard Preuss
In reply to this post by Fabio Mascarenhas
On Mon, Jun 10, 2013 at 6:05 PM, Fabio Mascarenhas <[hidden email]> wrote:
> Thanks for the patch, Thijs, but I believe it is unrelated to the problem at
> hand. I would bet on a misbehaving C library forgetting to do lua_checkstack
> and causing memory corruption in the heap.

Thanks for pointing in a direction! I'll try to track this down some more.

>
> Running the failing test under valgrind should be instructive, but I see
> someone closed the original issue, does that mean the cause was found?

No, the PR (https://github.com/Olivine-Labs/busted/pull/173) just uses
pcall instaed of copcall for lua-ev (which is involved in the error
described).

>
> --
> Fabio Mascarenhas
>
>
> On Mon, Jun 10, 2013 at 12:11 PM, Thijs Schreijer <[hidden email]>
> wrote:
>>
>> > -----Original Message-----
>> > From: [hidden email] [mailto:[hidden email]]
>> > On
>> > Behalf Of Gerhard Lipp
>> > Sent: woensdag 5 juni 2013 15:15
>> > To: [hidden email]
>> > Subject: copcall interpreter segfault possible?
>> >
>> > Hi!
>> >
>> > As stated here https://github.com/Olivine-Labs/busted/issues/171, I am
>> > observing a segmentation fault (Lua 5.1.5) when using copcall where
>> > pcall should have been used.
>> >
>> > Unfortunately it is a rather complex situation but it is reproducible.
>> > lua-ev is involved which itself makes some pcall through the lua API.
>> > copcall and pcall may call each other in this scenario.
>> >
>> > Does this sound dangerous? Are there known scenarios where calling
>> > copcall instead of pcall can crash the interpreter due to a badly
>> > behaving C module?
>> >
>> > Regards,
>> > Gerhard
>>
>> Not sure whether it fixes your problem. But I just submitted a PR [1] to
>> fix an issue with coxpcall I ran into. You might want to give it a try.
>>
>> Thijs
>>
>> [1] https://github.com/keplerproject/coxpcall/pull/1
>>
>>
>