On Sat, Jan 9, 2016 at 2:04 AM, Mariano Martinez Peck <marianopeck@gmail.com> wrote:
Hi guys,
I wonder if someone could give me a hand to find out why a FFI calling I am doing is crashing. In OSX it works correct but I am testing in CentOS and it fails. I wonder if it also crashes in other Linuxes too.
I only had enough time to run it a few time so you know it also crashes in Debian Jessie 32-bit. There were no debug logs. I got these sorts of messages... *** Error in `/home/ben/tst/pharo-vm/pharo': free(): invalid next size (fast): 0x08841a70 *** pharo: malloc.c:3695: _int_malloc: Assertion `(unsigned long) (size)
= (unsigned long) (nb)' failed. *** Error in `/home/ben/tst/pharo-vm/pharo': malloc(): memory corruption: 0x0984c1e0 ***
Searching github for "posix_spawn_file_actions_init " (https://git.io/vuSPL) I see a lot a function definitions of the form... int posix_spawn_file_actions_init(posix_spawn_file_actions_t *fa) { fa->__actions = 0; return 0; } ...so it seems you need to first allocate the space for the struct and then pass the address of that. { int __allocated; int __used; struct __spawn_action *__actions; int __pad[16]; } posix_spawn_file_actions_t; // http://linux.die.net/include/spawn.h cheers -ben
I am using latest Pharo 5.0 with Spur. To reproduce:
1) Get latest Pharo 5.0 and Spur via: wget -O- get.pharo.org/alpha+vm | bash
2) Inside Pharo, load my prototype tool:
Gofer it package: 'OSSubprocess'; url: 'http://smalltalkhub.com/mc/marianopeck/OSSubprocess/main'; load.
3) This is the code I am executing and it's crashing:
| posixSpawnFileActionsT | posixSpawnFileActionsT := ExternalAddress allocate: 4. OSSUnixSubprocess new primitivePosixSpawnFileActionsInit: posixSpawnFileActionsT. posixSpawnFileActionsT free. 4) The primitive is as simple as:
primitivePosixSpawnFileActionsInit: aPosixSpawnFileActionsT ^ self ffiCall: #( int posix_spawn_file_actions_init(void* aPosixSpawnFileActionsT) ) module: LibC
I have no idea what I am doing wrong. And again, this works on OSX. The function I am calling is: int posix_spawn_file_actions_init(posix_spawn_file_actions_t *file_actions); as you can read in [1]
Below is the stacktrace I get the Linux terminal.
Any hint is greatly appreciated.
Thanks,
[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn_file_a...