bugGforth - Bugs: bug #52085, Invalid memory address error in...

 
 

bug #52085: Invalid memory address error in valid code. Equivalent code has no error.

Submitter:  Colton Lewis <cwlmb3>
Submitted:  Fri 22 Sep 2017 05:58:41 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  anton
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 01 Oct 2017 11:08:59 AM UTC, comment #1: 

I could reproduce the problem.  This is a bug in rin.fth (also in rin2.fth and rin3.fth, but there the bug does not lead to a crash).  The problem is that PAD points to a little behind HERE, and code is compiled at HERE, moving HERE and PAD, but not the former PAD stored in IO.  What happens in rin.fth is that the READ-FILE overwrites the ";S" compiled by the ";" in RIN.  You can check by doing a SIMPLE-SEE RIN before and after the call to RIN.

Fix: Use the address returned by PAD directly.  It is only valid until HERE changes (e.g., by compilation, ALLOT, or ",").

Anton Ertl <anton>
Group administrator
Fri 22 Sep 2017 05:58:41 AM UTC, original submission:  

Version: 0.7.3
Compiler: gcc 5.4.0
OS: Gnu/Linux

Steps to reproduce:
1. Download the attached source files.
2. Populate a file named "file" with some text. (echo gforth >file)
3. Execute rin.fth (gforth rin.fth)
4. Note the code fails with "rin.fth:9: Invalid memory address".
5. Repeat step 3 with files rin2.fth and rin3.fth, which both succeed, leaving bytes read on the stack as expected.

Colton Lewis <cwlmb3>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #41865:  rin.fth added by cwlmb3 (160B - application/octet-stream)
file #41866:  rin3.fth added by cwlmb3 (160B - application/octet-stream)
file #41867:  rin2.fth added by cwlmb3 (159B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by anton (Posted a comment)
  • -email is unavailable- added by cwlmb3 (Submitted the item)
  • -email is unavailable- added by cwlmb3
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-10-01 anton StatusNone Invalid
        Assigned toNone anton
        Open/ClosedOpen Closed
    2017-09-22 cwlmb3 Attached File- Added rin.fth, #41865
        Attached File- Added rin3.fth, #41866
        Attached File- Added rin2.fth, #41867
        Carbon-Copy- Added cwlmb3

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code