pycdc icon indicating copy to clipboard operation
pycdc copied to clipboard

Segmentation fault (core dumped)

Open Zunea opened this issue 3 years ago • 9 comments

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

Zunea avatar Feb 25 '22 13:02 Zunea

How large is your .pyc file?

rocky avatar Mar 05 '22 11:03 rocky

yes. >=27kb .pyc

Zunea avatar Mar 09 '22 05:03 Zunea

Is there any way to solve it?

Zunea avatar Mar 20 '22 17:03 Zunea

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 ()

alxnegrila avatar May 02 '22 21:05 alxnegrila

Just now got the same crash,

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

0x3C50 avatar May 29 '22 09:05 0x3C50

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!

MoodMonitor avatar Dec 28 '23 19:12 MoodMonitor

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!

nataliawilsona10 avatar Apr 08 '24 03:04 nataliawilsona10