forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem realloc for scc 64 bit

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit
View previous topic :: View next topic  
Author Message
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Thu Apr 04, 2019 4:17 pm    Post subject: Problem realloc for scc 64 bit Reply with quote

Hello,

when porting a ftn95 application from 32 bit to 64 bit we make use of C/CPP calls malloc and realloc. The following code may be used to compile/link a 32 bit and a 64 bit executable using Salford`s scc compiler. The 32 bit executable works ok, however, for the 64 bit executable the realloc call returns the null pointer, when it should not.

Code:

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

int main() {
  int chunk_size=16;
  char* pChunk,*pChunk1;
 
  pChunk=(char*)malloc(chunk_size);
  printf("pChunk=0x%x\n",pChunk);
 
  pChunk1=(char*)realloc(pChunk,chunk_size);
  printf("pChunk1=0x%x\n",pChunk1);
  strcpy(pChunk1,"123456781234567812345678");
  printf("*pChunk1=%s\n",pChunk1);
 
  return 0;
}

Output of 32 bit exe:
Code:

pChunk=0x3805970
pChunk1=0x3805958
*pChunk1=123456781234567812345678

Output of 64 bit exe:
Code:

pChunk=0x1d5bd0
pChunk1=0x0

A a consequence of realloc returning the NULL pointer the 64 bit executable crashes with an access violation.

Version information of scc:
[Silverfrost SCC/WIN32 Ver 4.20 Copyright (c) Silverfrost Ltd 2018]


Regards,
Dietmar
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Thu Apr 04, 2019 5:22 pm    Post subject: Reply with quote

This has already been fixed and a new set of DLLs is available here for testing...

https://www.dropbox.com/s/tnx0fokexiug77i/newDLLs33.zip?dl=0

The function is in salflibc64.dll.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Apr 05, 2019 7:27 am    Post subject: Reply with quote

Dietmar

In the rush of things I did not check this before replying.

It does not work for me so I will investigate further.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Apr 05, 2019 9:43 am    Post subject: Reply with quote

This has now been fixed in this set of DLLs...

https://www.dropbox.com/s/2fiv6pwnsdq3e50/newDLLs34.zip?dl=0
Back to top
View user's profile Send private message AIM Address
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 279

PostPosted: Fri Apr 05, 2019 10:57 am    Post subject: Reply with quote

Paul,

thanks for the quick response and solution. The test sample runs as expected now (the pointer returned by the 64 bit exe is now different from NULL Smile

By the way I forgot to increase the chunk_size in my test sample before the realloc call Wink

Regards,
Dietmar
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group