Menu

#43 Multiple scheme_load_named_file() will cause memory corruption and crash

None
open
nobody
None
1
2020-05-28
2013-04-02
Sanel Zukan
No

When function scheme_load_named_file() was called multiple times with the same argument, it will crash whole interpreter with this message:

*** glibc detected *** ./scheme: malloc(): memory corruption: 0x000000000072f200 ***
*** glibc detected *** ./scheme: malloc(): memory corruption: 0x000000000072f200 ***
*** glibc detected *** ./scheme: malloc(): memory corruption: 0x000000000072f200 ***
*** glibc detected *** ./scheme: malloc(): memory corruption: 0x000000000072f200 ***
*** glibc detected *** ./scheme: malloc(): memory corruption: 0x000000000072f200 ***
*** glibc detected *** ./scheme: malloc(): memory corruption: 0x000000000072f200 ***
*** glibc detected *** ./scheme: malloc(): memory corruption: 0x000000000072f200 ***
*** glibc detected *** ./scheme: malloc(): memory corruption: 0x000000000072f200 ***
*** glibc detected *** ./scheme: malloc(): memory corruption: 0x000000000072f200 ***

How to reproduce it: open scheme.c and put somewhere (after init.scm was loaded something like):

scheme_load_named_file(&sc, fin, "init.scm");
scheme_load_named_file(&sc, fin, "init.scm");
scheme_load_named_file(&sc, fin, "init.scm");

you will get the crash.

I noticed also that '(load)' will correctly utilize load_stack via file_push(), which isn't the case with scheme_load_named_file(): the later will use only first stack element, causing gc() to wrongly try to free object port which isn't allocated.

Any ideas?

Discussion

  • Kevin Cozens

    Kevin Cozens - 2015-07-14

    Ticket moved from /p/tinyscheme/patches/9/

     
  • Kevin Cozens

    Kevin Cozens - 2020-05-28

    I just ran a test of calling scheme_load_named_file() four times in a row and it worked without crashing. Can you still reproduce the problem? If not, this bug can be closed as obsolete.

     

Log in to post a comment.