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

Queries.BlobSize returns the contents of a blob instead of its size #1119

Closed
mrstanb opened this issue Jul 26, 2023 · 1 comment · Fixed by #1125
Closed

Queries.BlobSize returns the contents of a blob instead of its size #1119

mrstanb opened this issue Jul 26, 2023 · 1 comment · Fixed by #1125
Assignees
Labels
Milestone

Comments

@mrstanb
Copy link
Member

mrstanb commented Jul 26, 2023

Description

I noticed that when calling Queries.BlobSize on a pointer, containing dynamically-allocated memory, BlobSize returns the contents of the blob that the pointer points to instead of the blob's size.

Take the following C program as an example:

#include <stdlib.h>

int main(int argc, char const *argv[]) {
    char *ptr = malloc(5 * sizeof(char));

    *ptr = 'a';

    free(ptr); //BlobSize

    return 0;
}

Observed Behavior

Calling BlobSize for ptr in the program above for the line with the comment //BlobSize returns the contents of ptr's blob, namely 97 (i.e., the char a in decimal ASCII encoding).

Expected Behavior

Calling BlobSize for ptr in the program above for the line with the comment //BlobSize should return 5, since ptr points to a heap memory block with size 5 * sizeof(char) which should evaluate to 5

Further remarks

I noticed that in the match in base.ml's query function here, the second match case is always taken, i.e., BlobSize always gives back top and never matches the Blob (_,s,_) case.

@sim642
Copy link
Member

sim642 commented Jul 26, 2023

Nothing right now uses BlobSize, so it's not surprising that it broke at one point when modifying the blob domain.

@mrstanb mrstanb linked a pull request Aug 3, 2023 that will close this issue
@sim642 sim642 added this to the v2.2.0 milestone Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants