Re: [go-nuts] Unexpected behaviour with LD_PRELOAD and fopen and cgo

2018-01-15 Thread tonywalker . uk
Ah ok. So I managed to get something to compile (ended up having to cast the 'const char' arguments to fopen64 to char before passing them to my go_fopen64 function but I still get: fatal: morestack on g0 zsh: trace trap LD_PRELOAD=./preload python test.py foo I'm clearly out of my depth here

Re: [go-nuts] Unexpected behaviour with LD_PRELOAD and fopen and cgo

2018-01-15 Thread Ian Lance Taylor
On Mon, Jan 15, 2018 at 12:36 PM, wrote: > Thanks Ian. I assume I'd include it like this: > // #include myfopen.h > And also a myfopen.c with the actual function > > But how do I ensure the fopen64 in myfopen.h is exported to override the > default? The fopen64 function written in myfopen.c will

Re: [go-nuts] Unexpected behaviour with LD_PRELOAD and fopen and cgo

2018-01-15 Thread tonywalker . uk
Thanks Ian. I assume I'd include it like this: // #include myfopen.h And also a myfopen.c with the actual function But how do I ensure the fopen64 in myfopen.h is exported to override the default? On Monday, January 15, 2018 at 3:05:32 PM UTC-5, Ian Lance Taylor wrote: > > The simplist workarou

Re: [go-nuts] Unexpected behaviour with LD_PRELOAD and fopen and cgo

2018-01-15 Thread Ian Lance Taylor
On Mon, Jan 15, 2018 at 11:54 AM, wrote: > > Thanks Ian. This did the trick and now I'm faced with the problem of > function signatures that include 'const'. On my system, fopen is declared > thus: > extern FILE *fopen (char *p0, char *modes) __wur > But fopen64 is: > extern FILE *fopen64 (const

Re: [go-nuts] Unexpected behaviour with LD_PRELOAD and fopen and cgo

2018-01-15 Thread tonywalker . uk
Thanks Ian. This did the trick and now I'm faced with the problem of function signatures that include 'const'. On my system, fopen is declared thus: extern FILE *fopen (char *p0, char *modes) __wur But fopen64 is: extern FILE *fopen64 (const char *__restrict __filename, const char *__restrict __

Re: [go-nuts] Unexpected behaviour with LD_PRELOAD and fopen and cgo

2018-01-15 Thread Ian Lance Taylor
On Mon, Jan 15, 2018 at 9:09 AM, wrote: > > I'm doing more experiments with created shared-object files with functions > that override syscalls and I've hit something I'd like to see if you guys > can help with. > > See a cut-down version of what I'm doing here > > There are 2 problems.. > > 1. I

[go-nuts] Unexpected behaviour with LD_PRELOAD and fopen and cgo

2018-01-15 Thread tonywalker . uk
Hi there, I'm doing more experiments with created shared-object files with functions that override syscalls and I've hit something I'd like to see if you guys can help with. See a cut-down version of what I'm doing here There are 2 problems.. 1. If I r