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

Segmentation fault (core dumped) #239

Open
Zunea opened this issue Feb 25, 2022 · 9 comments · May be fixed by #532
Open

Segmentation fault (core dumped) #239

Zunea opened this issue Feb 25, 2022 · 9 comments · May be fixed by #532

Comments

@Zunea
Copy link

Zunea commented Feb 25, 2022

When the .pyc file is large, pycdc outputs Segmentation fault (core dumped)

@rocky
Copy link

rocky commented Mar 5, 2022

How large is your .pyc file?

@Zunea
Copy link
Author

Zunea commented Mar 9, 2022

yes. >=27kb .pyc

@Zunea
Copy link
Author

Zunea commented Mar 20, 2022

Is there any way to solve it?

@alxnegrila
Copy link

alxnegrila commented May 2, 2022

It seems to be linked with the *.pyc file size or the depth of the code. Maybe allocating memory on loading the file.

(gdb) run sk.pyc
Starting program: /usr/local/bin/pycdc sk.pyc
# Source Generated with Decompyle++
# File: sk.pyc (Python 3.10)


Program received signal SIGSEGV, Segmentation fault.
0x00005555555b59c0 in std::vector<PycRef<ASTNode>, std::allocator<PycRef<ASTNode> > >::size() const ()

@0x3C50
Copy link

0x3C50 commented May 29, 2022

Just now got the same crash,

Program received signal SIGSEGV, Segmentation fault.
0x00005555555b5d78 in std::vector<PycRef<ASTNode>, std::allocator<PycRef<ASTNode> > >::size() const ()

@MoodMonitor
Copy link

Hello, I felt into same issue, but somehow I found the clue. The problem was, that the stack was empty but still program want to get the value from.
My solution for this (hot fix, without further investigation):
File ASTree.cpp:

Line 1187:
PycRef<ASTBlock> tmp = curblock;
blocks.pop();

if (blocks.size() == 0) {
break; } else {
curblock = blocks.top();} // changes

if (should_add_for_block) {
    curblock->append(tmp.cast<ASTNode>());
}
Line 1268:
/* Special case */
if (blocks.size() != 0) {
prev = blocks.top(); // changes
} 
Line 1353:
/* Special case */
if (blocks.size() != 0) {
prev = blocks.top(); // changes
}
Line 1363:
if (prev->blktype() == ASTBlock::BLK_MAIN) {
    /* Something went out of control! */
    prev = nil;
}
if (blocks.size() == 0) {
prev = nil; // changes
}
Line 1398:
if (blocks.size() == 0) {
   curblock->setEnd(pos+offs); // changes
} else {
    curblock = blocks.top(); // changes
}

if (curblock->blktype() == ASTBlock::BLK_EXCEPT) {
  curblock->setEnd(pos+offs);
}

Adding ASTree.cpp:
ASTree.txt
Hope will work with your case!

@nataliawilsona10
Copy link

Hello, I felt into same issue, but somehow I found the clue. The problem was, that the stack was empty but still program want to get the value from. My solution for this (hot fix, without further investigation): File ASTree.cpp:

Line 1187:
PycRef<ASTBlock> tmp = curblock;
blocks.pop();

if (blocks.size() == 0) {
break; } else {
curblock = blocks.top();} // changes

if (should_add_for_block) {
    curblock->append(tmp.cast<ASTNode>());
}
Line 1268:
/* Special case */
if (blocks.size() != 0) {
prev = blocks.top(); // changes
} 
Line 1353:
/* Special case */
if (blocks.size() != 0) {
prev = blocks.top(); // changes
}
Line 1363:
if (prev->blktype() == ASTBlock::BLK_MAIN) {
    /* Something went out of control! */
    prev = nil;
}
if (blocks.size() == 0) {
prev = nil; // changes
}
Line 1398:
if (blocks.size() == 0) {
   curblock->setEnd(pos+offs); // changes
} else {
    curblock = blocks.top(); // changes
}

if (curblock->blktype() == ASTBlock::BLK_EXCEPT) {
  curblock->setEnd(pos+offs);
}

Adding ASTree.cpp: ASTree.txt Hope will work with your case!

Thank you so much brother you saved my works!

@SuperKenVery
Copy link

It seems that the code has been updated and I can't find the places to apply the patches...

Any updates? This problem makes pycdc pretty much unusable for some input...

kmontag added a commit to kmontag/pycdc that referenced this issue Dec 9, 2024
@kmontag kmontag linked a pull request Dec 9, 2024 that will close this issue
@kmontag
Copy link

kmontag commented Dec 9, 2024

I've packaged the fix into a PR: #532. Thanks @MoodMonitor !

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

Successfully merging a pull request may close this issue.

8 participants