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

Print null instead of string #91

Closed
jupvfranco opened this issue Feb 16, 2015 · 5 comments
Closed

Print null instead of string #91

jupvfranco opened this issue Feb 16, 2015 · 5 comments

Comments

@jupvfranco
Copy link

In the program below, the main class creates many passive objects, of type Image,
which are initialized always with the same name "blah".
Each object of type Image is sent to a new active object of type Processing, which prints
the name of the image.

When I execute this program, the output is something like:

blah
blah
blah
...
blah
(null)
blah
blah

blah
...

nulls and empty lines are being printed and it shouldn't happen.
Thanks.

class Main

    def main(): void {

        let 
            n  = 10000
        in {
            repeat i <- n {
                let p = new Processing in 
                p!run(new Image(i))
            }
        }
    }

class Processing 

    def run(img: Image): void {
        print img.name
    }

----- passive data -------

passive class Image
    name: string
    n: int

    def init(n: int): void {
        this.name = "blah";
        this.n = n
    }
@TheGrandmother
Copy link
Contributor

Hmm.. interestingly this only seems to cause problems when printing the strings and not the integers.

If I change run to:

    def run(img: Image): void {
        print("{}:{}\n",img.name,img.n);
    }

I get output which looks like:

blah:960
:959
blah:962
blah:961
blah:964
blah:963
blah:966
...
...
...
blah:990
blah:989
blah:992
(null):991
blah:994
blah:993

@supercooldave
Copy link

Probably a GC problem.
I bet if you create the Image inside the run method the problem will go away.
(Not that this solves the problem.)

@EliasC
Copy link
Contributor

EliasC commented Feb 17, 2015

I agree with @supercooldave that the GC is the most likely cause. (null) is what printf prints if asked to print NULL as a %s. The blank lines could be that the actual string has been zeroed out, making it look like an empty string.

@TheGrandmother
Copy link
Contributor

This bug may be related to #48

It the blank lines appears at regular intervals and the problem only occurs when n exceeds a certain value.

I had a similar problem with the same characteristics and that was due to the GC so I would not be surprised if this bug is related to the GC.

@EliasC
Copy link
Contributor

EliasC commented May 21, 2015

As far as I can tell, this seems to be fixed now. My guess is the updated GC from 2ba9fb1 solved the problem. I'm closing this.

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

4 participants