News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

malloc and 64 bit ?

Started by bitcoin, December 09, 2022, 10:56:13 PM

Previous topic - Next topic

bitcoin

Hello
If i use malloc in 64 bit program, this allocates memory in address,start in FFFFF...
and program don't work.
why?

John Z

Hi bitcoin,

Well I searched and searched but couldn't find the error code for "doesn't work"  :)
Seriously though you are not giving enough information to allow any help to be useful.

It seems you received no error message when using the malloc, but are saying something else
did not work and you seem to be suspecting/pointing to the memory address.  Other than
that what didn't work is unspecified.  You mention 64 bit specifically, have you tried 32 bit and
does it work as you wanted?

Can you zip and post a small project that demonstrates what doesn't work?

John Z


bitcoin


John Z

Thanks bitcoin,

Well other than two missing h files I don't see, or get, any error.  I ran both the std exe and the debug exe, no error.
Attached is the debug 'Local' tab, and a memory view of the x pointer.  BTW I set changed memset to 1 so it
is easy to see the memset results in memory.  The x location was also shown in debug by mouse hover over x
also attached screen shot and it matches the local display. The memory at the location was filled with 1s.

I'm at a loss to see a problem.

John Z


TimoVJL

In windows 7 x64 i got address 0000000000610068h
May the source be with you

MrBcx

This works for me, 32-bit and 64-bit, Windows 10 Pro:


#include <stdio.h>     
#include <stdlib.h>     
#include <string.h>   

int main(void)
{
char *x = (char*)malloc(128);
memset(x,0,128);
return 0;
}

Bcx Basic to C/C++ Translator
https://www.bcxbasiccoders.com

bitcoin

It is very strange. Because I have a problem. Okay, sorry, this is probably a local error.
I use Windows 10, no antivirus.

---
If you run my exe file from attach, it works?

John Z

Hi,

Yes as far as I can tell the original 1.exe from your zip runs just fine, no error report.
Attached is 1_me.exe from my compile. You can try it.
Attached is also a comparison of file size, mine is exactly  1K (1024) bytes larger.



John Z

bitcoin

Your exe works fine
my - crashes with error
ok, thanks, maybe I need to re-install PellesC Ide

John Z

Definitely something strange because your exe does not show any error on my system. maybe something corrupted on your system but might not necessarily be Pelles C.  Still worth a try to re-install to get 'fresh' .lib files.

I'm on Windows 11 home edition 21H2 build 22000.1219 btw.  I have windows 7 and windows 10  as well and I'm going to try your exe there too.


John Z

P.S. "No antivirus", but you are running Microsoft Defender and firewall I hope....

bitcoin

Yes, I use windef.
I will try Ida Free and BinDiff to find error. Because this is very strange.

bitcoin

I reinstalled and everything worked!
maybe delete this stupid topic?

John Z

Great news!  Never know though this might help someone else might -

John Z