inicio mail me! sindicaci;ón

Bus error in FreeBSD/MacOSX

I’m dealing with a nasty platform problem now. The following sample of code works well under linux and its POSIX implementation of mmap but under BSD/MacOSX it throws an ugly Bus Error:

[code lang="python"] import cmmap

f = open(”foo”, “w+”) f.write(”c”) f.flush() m = cmmap.mmap(f.fileno(), 1) f.close() [/code]

gdb says:

Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: 10 at address: 0×00045000 Bus error

And this is the ktrace output in MacOSX:

26481 Python   CALL  mmap(0,0x1,0x3,0x1,0x4,0)
26481 Python   RET   mmap 282624/0x45000
26481 Python   PSIG  SIGBUS SIG_DFL

I think I’m definitely missing something…

UPDATE: the mistery goes on…

This equivalent in C works well (obviously… the problem must be in my python code):

[code lang="c"]

include

include

include

int main(void) { FILE* f; char * ret; int fd;

f = fopen(”foo”, “w+”); fd = fileno(f);

fprintf(f, “c”); fflush(f); ret = (char *) mmap(NULL, 1, 3, 1, fd, 0); printf(”%s\n”, ret);

return 0; } [/code]

If you want to try it by yourself: http://codespeak.net/svn/user/rhymes/modules/mmap/cmmap.py

Mmmm…

Related posts

  • Bus error is still here
  • Do the bus a bus
  • E, episode ten (Promises)
  • PyAppleSMS
  • memory map your entire mind
  • Leave a Comment