Skip Menu |
 

This queue is for tickets about the AI-MegaHAL CPAN distribution.

Report information
The Basics
Id: 48751
Status: open
Priority: 0/
Queue: AI-MegaHAL

People
Owner: Nobody in particular
Requestors: harv [...] ruin.nu
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.06
  • 0.06_01
  • 0.07
Fixed in: (no value)



Subject: BYTE4 defined as unsigned long breaks on 64 bit platforms
Download (untitled) / with headers
text/plain 401b
In libmegahal.c, on line 154 in 0.07 (146 in 0.06) there is: #define BYTE4 unsigned long However, unsigned long is 8 bytes on many 64 bit platforms, so loading a brain generated on a 32 bit platform will not work. However, the fix is easy, just changing it to: #define BYTE4 unsigned int That might break on older platforms, where int is 16 bit, not sure how common those are these days though.
From: Dave
Download (untitled) / with headers
text/plain 671b
Attached a patch for this bug. The only place it seemed to cause a problem was in load_dictionary(), as fread() was reading an unsigned long into an int. Just changed the int to an unsigned long. On Sun Aug 16 08:44:32 2009, harv wrote: Show quoted text
> In libmegahal.c, on line 154 in 0.07 (146 in 0.06) there is: > > #define BYTE4 unsigned long > > However, unsigned long is 8 bytes on many 64 bit platforms, so loading > a brain generated on a 32 bit platform will not work. However, the fix > is easy, just changing it to: > > #define BYTE4 unsigned int > > That might break on older platforms, where int is 16 bit, not sure how > common those are these days though.
Download 64bit-patch
application/octet-stream 522b

Message body not shown because it is not plain text.

Download (untitled) / with headers
text/plain 521b
On Sun Oct 18 23:05:14 2009, https://www.google.com/accounts/o8/id? id=AItOawnlNzkbyGCzSmAN8oBQ4OFZYqObWyCwc1I wrote: Show quoted text
> Attached a patch for this bug. The only place it seemed to cause a > problem was in load_dictionary(), as fread() was reading an unsigned > long into an int. > > Just changed the int to an unsigned long.
That's still a problem, since unsigned long is still 8 bytes, and not 4, it'll read too much from the file. With this change I'm getting a segmentation fault instead of an unusable brain.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.