[Gambas-user] Issue 178 in gambas: Constants of type "Single" does not work in some cases. Segmentation fault.

gambas at ...2524... gambas at ...2524...
Fri Dec 30 21:00:59 CET 2011


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

New issue 178 by emil.len... at ...626...: Constants of type "Single" does not  
work in some cases. Segmentation fault.
http://code.google.com/p/gambas/issues/detail?id=178

1) Describe the problem.
Constants of type "Single" does not work in some cases.

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

Version: TRUNK
Revision: r4368

3) Provide a little project that reproduces the bug or the crash.
MMain:
Public Const a As Single = 123.45

Public Sub Main
   Print MMain.a
End

4) If your project needs a database, try to provide it, or part of it.

5) Explain clearly how to reproduce the bug or the crash.
Create the Module MMain with the contents above. The interpreter crashes  
with a segmentation fault.

One part of why it is going wrong is the code in gbx_class_load.c:
         if (TYPE_is_integer(desc->constant.type))
           desc->constant.value._integer = cc->_integer.value;
         else if (desc->constant.type == T_FLOAT)
           desc->constant.value._float = cc->_float.value;
         else if (desc->constant.type == T_LONG)
           desc->constant.value._long = cc->_long.value;
         else
         {
           desc->constant.type = T_CSTRING;
           desc->constant.value._string = cc->_string.addr;
					desc->constant.translate = (cc->type == T_CSTRING);
         }

The desc->constant.type is T_SINGLE, so the else part runs..

The actual crash is at
VALUE_read(&SP[-1], (void *)&desc->constant.value, desc->constant.type);
in gbx_exec_push.c, as it tries to read a string at a bad address instead...





More information about the User mailing list