Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack over flow error with certain number of "{" in input file #1448

Closed
hongxuchen opened this issue May 27, 2018 · 3 comments
Closed

Stack over flow error with certain number of "{" in input file #1448

hongxuchen opened this issue May 27, 2018 · 3 comments

Comments

@hongxuchen
Copy link

When there are certain number of continuous "{" inside input file, it may cause some stackoverflows.

For example, on my machine (Linux x86_64) when compiled with address sanitizer, espruino emits stack overflow when there are 130671, 130676, 130683, 130747, ... >130774 continuous "{" in the input files.

This was actually observed by our fuzzer in Espruino's older versions several times, but we didn't reproduce with vanilla address sanitizer. We wrote the following simple script to generate the input and finally reproduced it on ca13e4d.

#!/usr/bin/env python

import sys
import subprocess

if len(sys.argv) < 2:
    print("wrong cmd, exit")
    sys.exit(1)
else:
    exe = sys.argv[1]
    print(exe)

def write_file(n, fname):
    with open(fname, "w") as f:
        f.write("{" * n)

def call(fname):
    out_fname = fname + ".res"
    cmd_str = "{} {}".format(exe, fname)
    print(cmd_str)
    cmd = cmd_str.split()
    with open(out_fname, "w") as out_f:
        c = subprocess.call(cmd, stdout=out_f, stderr=out_f)

for i in xrange(130650, 300000):
    fname = "{:08d}".format(i)
    write_file(i, fname)
    call(fname)
@hongxuchen
Copy link
Author

hongxuchen commented May 27, 2018

BTW, it seems that whenever there are some crashes (although only in few scenarios), espruino will ruin the terminal (tried several machines and several terminals, all have this issue), it there any way to mitigate this?

2018-05-27-144442_1919x247_scrot

@MaBecker
Copy link
Contributor

it there any way to mitigate this?

try stty sane

@hongxuchen
Copy link
Author

@MaBecker Thanks 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants