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

Uninitialised structure field #25

Open
klopp opened this issue Jun 19, 2016 · 2 comments
Open

Uninitialised structure field #25

klopp opened this issue Jun 19, 2016 · 2 comments

Comments

@klopp
Copy link

klopp commented Jun 19, 2016

$ cat main.c
void main() {}

$ valgrind --leak-check=yes --track-origins=yes ./picoc main.c
==30986== Memcheck, a memory error detector
==30986== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==30986== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==30986== Command: ./picoc main.c
==30986== 
==30986== Conditional jump or move depends on uninitialised value(s)
==30986==    at 0x4194A7: VariableScopeBegin (variable.c:177)
==30986==    by 0x414D3B: ParseBlock (parse.c:519)
==30986==    by 0x41516D: ParseStatement (parse.c:659)
==30986==    by 0x413638: ParseStatementMaybeRun (parse.c:30)
==30986==    by 0x413BCE: ParseFunctionDefinition (parse.c:146)
==30986==    by 0x414484: ParseDeclaration (parse.c:336)
==30986==    by 0x41564A: ParseStatement (parse.c:772)
==30986==    by 0x415E85: PicocParse (parse.c:966)
==30986==    by 0x404207: PicocPlatformScanFile (platform_unix.c:131)
==30986==    by 0x4161BD: main (picoc.c:54)
==30986==  Uninitialised value was created by a stack allocation
==30986==    at 0x415D58: PicocParse (parse.c:937)
==30986== 
==30986== Conditional jump or move depends on uninitialised value(s)
==30986==    at 0x4194A7: VariableScopeBegin (variable.c:177)
==30986==    by 0x414D3B: ParseBlock (parse.c:519)
==30986==    by 0x41516D: ParseStatement (parse.c:659)
==30986==    by 0x40FB6A: ExpressionParseFunctionCall (expression.c:1545)
==30986==    by 0x40EDBD: ExpressionParse (expression.c:1251)
==30986==    by 0x415123: ParseStatement (parse.c:653)
==30986==    by 0x415E85: PicocParse (parse.c:966)
==30986==    by 0x416523: PicocCallMain (platform.c:77)
==30986==    by 0x416242: main (picoc.c:57)
==30986==  Uninitialised value was created by a stack allocation
==30986==    at 0x415D58: PicocParse (parse.c:937)
==30986== 
==30986== 
==30986== HEAP SUMMARY:
==30986==     in use at exit: 0 bytes in 0 blocks
==30986==   total heap usage: 125 allocs, 125 frees, 136,140 bytes allocated
==30986== 
==30986== All heap blocks were freed -- no leaks are possible
==30986== 
==30986== For counts of detected and suppressed errors, rerun with: -v
==30986== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

Solution (lex.c):

void LexInitParser(struct ParseState *Parser, Picoc *pc, const char *SourceText, void *TokenSource, char *FileName, int RunIt, int EnableDebugger)
{
    Parser->ScopeID = 0; /* HERE */
    Parser->pc = pc;
@yanghao
Copy link

yanghao commented Jun 27, 2017

Is this project still maintained? Fix works for me.

@dodona2
Copy link

dodona2 commented Jun 28, 2017

Is this project still maintained?
there is a more recent fork: https://github.com/jpoirier/picoc

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

3 participants