FrozenSnake's Profile User Rating: -----

Reputation: 123 Stalwart
Active Members
Active Posts:
1,021 (0.36 per day)
30-July 08
Profile Views:
Last Active:
User is offline Apr 18 2016 03:52 PM

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Who Cares
Dream Kudos:
Icon   FrozenSnake has not set their status

Posts I've Made

  1. In Topic: Measuring CPU usage "problem"

    Posted 18 Apr 2016

    View PostSkydiver, on 18 April 2016 - 06:46 PM, said:

    Did you set the PC to run at 100% CPU (e.g. Performance) instead of as-needed (e.g. Balanced)?

    Is your home computer an 8-core, while your school computer a 4-core? If so, then your program is strictly single threaded and you are saturating one core for that single thread, but not utilizing all the cores available to you.

    How do I see if it is set on performance or balanced or some other setting? I have never touched anything like that.
    Oh, I think I found it. I changed it to "High performance" from balanced. But it still end up at 12.5%

    At home I have a Intel Core i7-4790K CPU.
    At school it is a Intel Xeon E5-2665 0 CPU. They are currently updating the computers so I am not sure if this is the new ones or the old ones (I am connecting using VMware to check).
  2. In Topic: Checking how much memory a function is using?

    Posted 8 Feb 2016

    I'll need to collect the memory useage under run-time. I am going to generate different sized caves in arrays that have
    the size 10 x 10 to 1000 x 1000 with ~50-100 samples per size. So it would be really nice to have a way to keep this
    automatic, so I can start the program and keep it running for the night and wake up with a text file with a bunch of numbers.
  3. In Topic: Problem with old code that doesn't work anymore!

    Posted 3 Nov 2015

    View PostXupicor, on 03 November 2015 - 06:48 PM, said:

    The code compiles with similar warnings to Jim's here, but it does crash and produces no output using Windows 8 and g++ 5.1.0 compiled as C++14.

    As ndc85430 mentioned, the most immediately obvious problem is possible dereferencing of a null pointer at line 32 after you possibly let it pass through the below condition at line 26:
    if (right != NULL || left != NULL)

    There's also line 42 where you possibly dereference a null pointer.

    None of those are directly responsible though. What happens is - left and right pointers are not initialized when calling one of the Tree constructors. So, basically, new Tree(9, 'a') makes a new tree (...uh, "tree node" actually, I don't see why a Tree and a Node aren't separated in your code, but that's inconsequential here : P) that has left and right with garbage values. The condition at line 26 lets it through and then you dereference an invalid pointer, bam, it all crashes and burns.

    Thanks for going in-depth in why this is happening!
    But wouldn't it crash right away? I check the content of bitString and it ends up with 000 and then crash.
    Why does it decide to crash when pushing the forth value? I might be asking a stupid question, it is late.

    Anyway I tried this now
    Tree::Tree(int w, char c_) : weight(w), c(c_) { left = NULL; right = NULL; }
    And now it works again!
    I'll rewrite this code later, and add a Node class!
  4. In Topic: Problem with old code that doesn't work anymore!

    Posted 3 Nov 2015

    View Postjimblumberg, on 03 November 2015 - 05:59 PM, said:

    Could it be that two years ago you were using a 32 bit compiler and today you're using a 64 bit compiler?

    As I stated earlier the code ran for me without crashing, this was using a 32 bit compiler. However when using a 64 bit compiler the program crashed on the lines you indicated.


    I checked on C::Bs homepage they use 32bit in the installation I have. I tried compiling both in x86 and x64 in Visual Studio (if I am right in assuming that x64 is 64bit and x86 is "some other" bit). Same problem. :(

    View PostSalem_c, on 03 November 2015 - 06:01 PM, said:

    > Access violation reading location 0xCDCDCDD1."
    0xCD is what the debug version of the runtime library fills memory with when that memory is deleted.

    0xD1 is basically 0xCD + 4.

    In other words, it's likely to be the 2nd member of a structure/class that has been deleted, and this is an example of a 'use after free' error.

    $ g++ -g -Wall bar.cpp -lefence
    bar.cpp: In constructor ‘Tree::Tree(int, Tree*, Tree*)’:
    bar.cpp:17:7: warning: ‘Tree::weight’ will be initialized after [-Wreorder]
    bar.cpp:15:9: warning:   ‘Tree* Tree::left’ [-Wreorder]
    bar.cpp:22:1: warning:   when initialized here [-Wreorder]
    $ gdb -q ./a.out 
    Reading symbols from /home/sc/Documents/a.out...done.
    (gdb) run
    Starting program: /home/sc/Documents/a.out 
    000 : a
    Program received signal SIGSEGV, Segmentation fault.
    0x0000000000400e39 in Tree::printTree (this=0x0, bitString=...) at bar.cpp:26
    26        if (right != NULL || left != NULL)
    (gdb) bt
    #0  0x0000000000400e39 in Tree::printTree (this=0x0, bitString=...) at bar.cpp:26
    #1  0x0000000000400ec7 in Tree::printTree (this=0x605070, bitString=...) at bar.cpp:32
    #2  0x0000000000400e7a in Tree::printTree (this=0x6050e0, bitString=...) at bar.cpp:29
    #3  0x0000000000400e7a in Tree::printTree (this=0x605100, bitString=...) at bar.cpp:29
    #4  0x000000000040118d in main () at bar.cpp:67
    (gdb) print bitString 
    $1 = (std::string &) @0x7fffffffdf70: {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, 
        _M_p = 0x605138 "001"}}

    Use your debugger to start looking around for the problem.
    For me, it ended up calling the function with a NULL pointer.

    I'll take a look soon! Need to run to the post office real quick! Thanks for the tip!
  5. In Topic: Problem with old code that doesn't work anymore!

    Posted 3 Nov 2015

    View Postjimblumberg, on 03 November 2015 - 05:01 PM, said:

    Other than having a few warnings when I compile your code, it runs without crashing and produces the following output:
    I tried compiling with Code::Blocks 13.12 (TDM-GCC 4.8.1) and Visual Studio Community 2015. It crashes with both of these ://>

    View Postndc85430, on 03 November 2015 - 04:56 PM, said:

    Are you sure that the condition in the if statement in printTree() is correct? What happens, for example, if right is not null, but left is?

    Also, have you gotten into the habit of using version control yet? If not, you really should.
    The code hasn't been changed in 2 years. It worked 2 years ago, at least well enough to pass the assignment. I use github and bitbucket; this code is taken from my bitbucket.

My Information

Member Title:
En man från Sverige!
31 years old
October 31, 1984
Sweden, Gävle
Full Name:
Kim Wahlman
Years Programming:
Programming Languages:
Php, C++


Page 1 of 1
  1. Photo

    Martyn.Rae Icon

    14 Feb 2010 - 04:37
    Davs, hvordan gør det i Sverige?
Page 1 of 1