slash-lang/slash — pull request #37 by vstm (2013-12-05 14:07:34+00:00)
Title: Fix segfault when calling Error.throw on x86-32

Slash produces a segfault when executing "Error.new.throw" on 32-bit
systems.

Steps to reproduce:

1. You need a 32-bit system (I tested it successfully on "bare metal" and a 32 bit guest vm on top of a 64 bit host)

2. Apply the `throw` method of an `Error`-instance:

$ ./sapi/cli/slash-cli
Interactive Slash
>> Error.new.throw
Segmentation fault

The problem is that `sl_throw` has no return value (`void`) but gets called
as if it would return a `SLVAL`. The address of the return value is then
added by the caller before the other parameters. If that happens, the
`vm`-parameter contains the address to uninitialized `SLVAL` of the
caller - which is of course invalid.

This fix solves the problem by just wrapping the `sl_throw` call in a
function with a matching function signature. That way the return value
is "pop"-ed before the parameters.

This problem does not appear on 64-bit systems because the return value
has a dedicated register and does not "get in the way" of the other
parameters.