[Gambas-user] Issue 135 in gambas: Cannot use vararg in functions with optional arguments - Segmentation fault

gambas at ...2524... gambas at ...2524...
Thu Oct 27 21:52:23 CEST 2011


Status: New
Owner: ----
Labels: Version Type-Bug Priority-Medium OpSys-Any Dist-Any Arch-Any  
Desktop-Any GUI-Any

New issue 135 by emil.len... at ...626...: Cannot use vararg in functions with  
optional arguments - Segmentation fault
http://code.google.com/p/gambas/issues/detail?id=135

1) Describe the problem.
When you call a function that has optional arguments and vararg, the  
interpreter exits with a Segmentation fault.

2) GIVE THE FOLLOWING INFORMATIONS (if they are appropriate):

Version: TRUNK
Revision: r4222

3) Provide a little project that reproduces the bug or the crash.
Public Sub CrashFunction(Optional a As Integer, ...)
End

Public Sub Main()
     CrashFunction(1, 2)
End

5) Explain clearly how to reproduce the bug or the crash.
Run the code.

6) By doing that carefully, you have done 50% of the bug fix job!

The error seems to be in gbx_exec.c from line 461 and forward.
If there are at least one optional argument in the signature, it assumes  
all of the following arguments are optional, but they might in fact be  
varargs.

First change line 465 to
for (i = func->npmin; i < Min(func->n_param, nparam); i++)
instead of
for (i = func->npmin; i < nparam; i++)

But I don't know what to do with line 501 if some optional arguments were  
missing...





More information about the User mailing list