KERNEL32!HeapLock() ?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

KERNEL32!HeapLock() ?

Post by XianForce »

Code: Select all

      #0 00401BAB     ??() (??:??)
      #1 00934748     ??() (??:??)
      #2 0022FCA0     ??() (??:??)
      #3 0022FCB0     ??() (??:??)
      #4 7755C56F     KERNEL32!HeapLock() (C:\Windows\system32\kernel32.dll:??)
      #5 00930000     ??() (??:??)
      #6 00000000     ??() (??:??)
Okay, I REALLY hate to be so vague on this, but I don't want to be someone that posts a crap load of code asking someone to go through it.

My project compiles fine, but I get a segfault, and here's the call stack from the segfault... gives no line numbers so I haven't the slightest idea of where to even begin to look.

To those that will tell me to use google, sorry, tried and failed. Only thing I could find was references to antivirus's and malware.

I have a lot of files, and since this segfault is being vague, I can't even imagine where to start to look.

So does anyone know what this at least means? Like what went wrong exactly? I'm hoping someone will, so I can narrow down my search.


Thanks in advance for any help =D
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: KERNEL32!HeapLock() ?

Post by Falco Girgis »

You can do better than this. printf/cout at strategic points until it crashes. Use the visual studio debugger to set breakpoints. What you're giving us is 99.99% worthless. All that I can tell you is that it's most likely something to do with dynamic memory allocation. Check your new and delete calls.
User avatar
short
ES Beta Backer
ES Beta Backer
Posts: 548
Joined: Thu Apr 30, 2009 2:22 am
Current Project: c++, c
Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
Programming Language of Choice: c, c++
Location: Oregon, US

Re: KERNEL32!HeapLock() ?

Post by short »

GyroVorbis wrote:You can do better than this. printf/cout at strategic points until it crashes. Use the visual studio debugger to set breakpoints. What you're giving us is 99.99% worthless. All that I can tell you is that it's most likely something to do with dynamic memory allocation. Check your new and delete calls.
I really have no idea how much you know but you could try stepping through your program line by line.

First set a break point at the beginning of your program and run it in debug mode. Step over function calls until you figure out which one causes the segfault. When you've isolated the function call that causes the crash, set a new breakpoint there and then step into the function.

Once you begin stepping through your program like this it is usually much easier to isolate where the error is coming from.


Oh and welcome to debugging random errors. It sucks. But you'll eventually get good at it :)
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: KERNEL32!HeapLock() ?

Post by avansc »

as far as i know HeapLock() is a winapi function, that lock the heap preventing heapwalk to fux things up.
and im almost certain its centric to multithreaded shit. ie. a thread "locks" the heap, so no other thread can allocate of release heap memory until that thread has unlocked the heap.
its a sort of mutex i spose. not sure how you are using it. so without code or any other info its hard to even begin to give advice.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: KERNEL32!HeapLock() ?

Post by XianForce »

Sorry =/. I used the breakpoints, and that's the information I got. Right now I'm not at home, but when I get home, I'll put some stuff on the console screen, and post what I get.
User avatar
short
ES Beta Backer
ES Beta Backer
Posts: 548
Joined: Thu Apr 30, 2009 2:22 am
Current Project: c++, c
Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
Programming Language of Choice: c, c++
Location: Oregon, US

Re: KERNEL32!HeapLock() ?

Post by short »

did you try setting a breakpoint at the very beginning and then stepping through the program line by line?
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: KERNEL32!HeapLock() ?

Post by XianForce »

short wrote:did you try setting a breakpoint at the very beginning and then stepping through the program line by line?
Yeah, and that's exactly what I got. I worked a little bit on it today... ran my debug binary, found where it was crashing, and fixed it... or so I thought. But now it runs through the loop perfectly fine, and I get this:

Code: Select all

#0 774F7DFF	ntdll!DbgUiConvertStateChangeStructure() (C:\Windows\system32\ntdll.dll:??)
#1 7753D0D0	ntdll!EtwEventEnabled() (C:\Windows\system32\ntdll.dll:??)
#2 744EB213	??() (??:??)
#3 00000000	??() (??:??)
And again, I'd just like to know if any of you know what this even means, if I could provide more information without posting crap loads of code, I would.
User avatar
short
ES Beta Backer
ES Beta Backer
Posts: 548
Joined: Thu Apr 30, 2009 2:22 am
Current Project: c++, c
Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
Programming Language of Choice: c, c++
Location: Oregon, US

Re: KERNEL32!HeapLock() ?

Post by short »

what environment are you running in?

OS and compiler / debugger
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: KERNEL32!HeapLock() ?

Post by XianForce »

short wrote:what environment are you running in?

OS and compiler / debugger
CodeBlocks IDE, Windows Vista, MinGW Compiler
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: KERNEL32!HeapLock() ?

Post by MarauderIIC »

What statements are run before it goes into the almost irrelevant assembly and things? That's where your clues are.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: KERNEL32!HeapLock() ?

Post by XianForce »

MarauderIIC wrote:What statements are run before it goes into the almost irrelevant assembly and things? That's where your clues are.
Yeah, I ended up rewriting a portion of my code, and now it's fixed, so still not sure to what it was exactly. It didn't go into that 'irrelevant assembly and things' in a set place, sometimes it screwed up with taking input, sometimes it screwed up with logic, and other times it screwed up with updating the screen.

But I'm not gonna worry about it anymore, it's gone =p


EDIT: I'm gonna throw a big 'Nevermind' on that one. Seems the SegFault is in my Release binary, yet not my Debug binary 0.o.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: KERNEL32!HeapLock() ?

Post by dandymcgee »

XianForce wrote:
MarauderIIC wrote:What statements are run before it goes into the almost irrelevant assembly and things? That's where your clues are.
Yeah, I ended up rewriting a portion of my code, and now it's fixed, so still not sure to what it was exactly. It didn't go into that 'irrelevant assembly and things' in a set place, sometimes it screwed up with taking input, sometimes it screwed up with logic, and other times it screwed up with updating the screen.

But I'm not gonna worry about it anymore, it's gone =p


EDIT: I'm gonna throw a big 'Nevermind' on that one. Seems the SegFault is in my Release binary, yet not my Debug binary 0.o.
Check your pointers and variable definitions. Debug mode automatically zeroes those sorts of thing where as release mode does not. Segfault is often the result of accessing a pointer to garbage memory, finding which one is the part that's no fun.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Post Reply