Author Topic: Segfault when saving file  (Read 4494 times)

Atash

  • Guest
Segfault when saving file
« on: June 30, 2009, 09:33:55 am »
<begin edit>
I totally just realized that this is my first post on the boards and that I ought to at least say hello... soooo:
Hello! I'm an avid C++ progger and I liked Code::Blocks back when I was using it on Windows... So I'm using it on Linux! Woooo!
Alright, back to the actual content of this post... *poof*
<end edit>


As far as I know (from experience), what follows occurs in revisions 5679+5680 (not the nightlies... I don't know if I should have been expecting this or not), and from what I've picked up in a single random forum post elsewhere (that I can't seem to find again), possibly has been occurring earlier.

A crash occurs whenever I attempt to save a file. I'm going to make a wild guess here and say it's a problem with reparsing the file once it's saved.
:arrow: Some (I think) relevant output from GDB...
Code
Passing list of files to parse
[New Thread 0x44538950 (LWP 32467)]
[Thread 0x44538950 (LWP 32467) exited]
Starting batch parsing
Parsing stage done (1194 total parsed files, 27367 tokens in 0 minute(s), 5.71 seconds).
Updating class browser...
Class browser updated.
[New Thread 0x44538950 (LWP 32619)]
[Thread 0x44538950 (LWP 32619) exited]
Reparsing saved files...

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fe57ea1d6f0 (LWP 28513)]
0x00007fe578a8a521 in _int_malloc () from /lib/libc.so.6
(gdb) info stack
#0  0x00007fe578a8a521 in _int_malloc () from /lib/libc.so.6
#1  0x00007fe578a8c360 in malloc () from /lib/libc.so.6
#2  0x00007fe5792cb5ed in operator new (sz=40) at ../../../../src/libstdc++-v3/libsupc++/new_op.cc:57
#3  0x00007fe5721683ab in std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_copy (this=0x7fff86254280, __x=0x28,
    __p=0x7fe578d73a60) at /usr/include/c++/4.2/ext/new_allocator.h:91
#4  0x00007fe5721683ea in std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_copy (this=0x7fff86254280, __x=0x4768980,
    __p=0xd630e50) at /usr/include/c++/4.2/bits/stl_tree.h:1291
#5  0x00007fe5721683ea in std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_copy (this=0x7fff86254280, __x=0x4766580,
    __p=0xd630e20) at /usr/include/c++/4.2/bits/stl_tree.h:1291
#6  0x00007fe5721683ea in std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_copy (this=0x7fff86254280, __x=0x4761ba0,
    __p=0xd630df0) at /usr/include/c++/4.2/bits/stl_tree.h:1291
#7  0x00007fe5721683ea in std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_copy (this=0x7fff86254280, __x=0x475a8e0,
    __p=0xd630dc0) at /usr/include/c++/4.2/bits/stl_tree.h:1291
#8  0x00007fe5721683ea in std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_copy (this=0x7fff86254280, __x=0x474b100,
    __p=0xd630d90) at /usr/include/c++/4.2/bits/stl_tree.h:1291
#9  0x00007fe5721683ea in std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_copy (this=0x7fff86254280, __x=0x4730d90,
    __p=0x7fff86254288) at /usr/include/c++/4.2/bits/stl_tree.h:1291
#10 0x00007fe57218b4b7 in std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::operator= (this=0x7fff86254280,
    __x=@0x22ff1d0) at /usr/include/c++/4.2/bits/stl_tree.h:819
#11 0x00007fe5721a63c5 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at /usr/include/c++/4.2/bits/stl_set.h:206
#12 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#13 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#14 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#15 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#16 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#17 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#18 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#19 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#20 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#21 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#22 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#23 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#24 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#25 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#26 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#27 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
#28 0x00007fe5721a63e1 in TokensTree::RemoveToken (this=0x15fe900, oldToken=<value optimized out>) at parser/token.cpp:601
---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) list
247 app.cpp: No such file or directory.
in app.cpp
(gdb)
A note about the stack... It goes ad infinitum on that same line (I gave up holding my finger on the keyboard once it got to around 700+).

Uhhhhh... what else what else...

A pattern kind of came up when I attempted to compile my files and then save... No matter how inconsequential my actions are to the file (like typing a character and deleting it, so long as I create some sort of history), once I save after a compilation of my program, Code::Blocks segfaults. As it turns out... from what I'm reading from GDB:

Code
/home/soltanmm/Development/Projects/Math/Polynomials.impl.h:746: warning: comparison between signed and unsigned integer expressions
Linking console executable: bin/Debug/Math
/usr/lib/gcc/x86_64-linux-gnu/4.2.4/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 23 seconds)
1 errors, 16 warnings
[New Thread 0x444c5950 (LWP 12647)]
[Thread 0x444c5950 (LWP 12647) exited]
[New Thread 0x444c5950 (LWP 12648)]
[Thread 0x444c5950 (LWP 12648) exited]
[New Thread 0x444c5950 (LWP 12744)]
[Thread 0x444c5950 (LWP 12744) exited]
Reparsing saved files...

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fbdcc4af6f0 (LWP 10919)]
0x00007fbdc651c521 in _int_malloc () from /lib/libc.so.6
(gdb)

I'm thinking it's a problem with the reparsing.

However, if I'm not in a project, I can save a lonely file all I want. And it'll reparse. The pattern here is broken...

Code
Warning: Using user specified encoding as fallback!
Encoding fallback is: Unicode 8 bit (UTF-8) (ID: 41)
Final encoding detected: Unicode 8 bit (UTF-8) (ID: 41)
[New Thread 0x44e99950 (LWP 18018)]
[Thread 0x44e99950 (LWP 18018) exited]
[New Thread 0x44e99950 (LWP 18096)]
[Thread 0x44e99950 (LWP 18096) exited]
Reparsing saved files...
Starting batch parsing
Parsing stage done (1 total parsed files, 173 tokens in 0 minute(s), 0.3 seconds).
Updating class browser...
Class browser updated.
[Thread 0x44698950 (LWP 17922) exited]

Program received signal SIGINT, Interrupt.
[Switching to Thread 0x7f7ea0e186f0 (LWP 17555)]
0x00007f7e9aedfc86 in poll () from /lib/libc.so.6
(gdb)

My system information:
Linux, Ubuntu 8.04, AMD64 <-- I'm guessing it's the 'Linux' and the '64' in there that's killing me more than the rest of the happy people here, but I dunno -.-'
Code::Blocks Revision 5680

Considering how often this crash occurs, I can keep repeating my actions over and over again and be more and more specific if it'd help someone else helping me.

(( on the other hand, if the problem wasn't Code::Blocks but my act of using the wrong version of some library, I'm going to be smacking myself silly for the next week >_< ))
« Last Edit: June 30, 2009, 09:35:26 am by Atash »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Segfault when saving file
« Reply #1 on: June 30, 2009, 09:50:52 am »
If I understand right, you use self-compiled C::B.

Have a look at this post (and possibly the thread it belongs to) : http://forums.codeblocks.org/index.php/topic,10286.msg71442.html#msg71442.

Please try the patch I posted there and see if it helps.

Atash

  • Guest
Re: Segfault when saving file
« Reply #2 on: July 01, 2009, 05:22:09 am »
Patch applied and the thing's working like a charm (well, as charmingly as it can be for a machine... cuz' machines just ain't charming [unless they're cars :-D <wooo - really went on a tangent there>]). *edit: now that I think about it, I can't really call codeblocks a machine... maybe a 'system', but there are plenty of charming 'system's...*

Anyway... that was one hellz of a weird bug...

Much thanks!
« Last Edit: July 01, 2009, 05:23:52 am by Atash »