Hmmm..... you cannot do alloc with size of string. Size of string is depended on length of string!
Jussi On Sun, Jan 9, 2011 at 15:59, Demosthenes Koptsis <demosthen...@gmail.com>wrote: > this example on pointers raises signal #6. > Gambas3 svn3432 Ubuntu 10.04, AMD64 > > --------------------------- > ' Gambas module file > 'char *getwd(char *buf); > Extern getwd(buf As Pointer) As Pointer In "libc:6" > > Public Sub Main() > > Dim pBuf As Pointer > Dim pFunc As Pointer > Dim sWorkingDirectory As String > > 'getwd > pBuf = Alloc(SizeOf(gb.String)) > pFunc = Alloc(SizeOf(gb.String)) > > pFunc = getwd(pBuf) > > sWorkingDirectory = Str@(pFunc) > Free(pFunc) > Free(pBuf) > Print sWorkingDirectory > > End > --------------------------- > > output: > --------------------------- > *** glibc detected *** Pointers86: free(): invalid next size (fast): > 0x0000000001af39a0 *** > ======= Backtrace: ========= > /lib/libc.so.6(+0x775b6)[0x7f4d6a2495b6] > /lib/libc.so.6(cfree+0x73)[0x7f4d6a24fe83] > Pointers86[0x405308] > Pointers86[0x422f50] > /lib/libc.so.6(__libc_start_main+0xfd)[0x7f4d6a1f0c4d] > Pointers86[0x4043f9] > ======= Memory map: ======== > 00400000-00445000 r-xp 00000000 08:14 > 2377106 /usr/local/bin/gbx3 > 00644000-00645000 r--p 00044000 08:14 > 2377106 /usr/local/bin/gbx3 > 00645000-0064f000 rw-p 00045000 08:14 > 2377106 /usr/local/bin/gbx3 > 0064f000-00651000 rw-p 00000000 00:00 0 > 01ade000-01aff000 rw-p 00000000 00:00 0 > [heap] > 7f4d64000000-7f4d64021000 rw-p 00000000 00:00 0 > 7f4d64021000-7f4d68000000 ---p 00000000 00:00 0 > 7f4d69fbb000-7f4d69fd1000 r-xp 00000000 08:14 > 1179728 /lib/libgcc_s.so.1 > 7f4d69fd1000-7f4d6a1d0000 ---p 00016000 08:14 > 1179728 /lib/libgcc_s.so.1 > 7f4d6a1d0000-7f4d6a1d1000 r--p 00015000 08:14 > 1179728 /lib/libgcc_s.so.1 > 7f4d6a1d1000-7f4d6a1d2000 rw-p 00016000 08:14 > 1179728 /lib/libgcc_s.so.1 > 7f4d6a1d2000-7f4d6a34c000 r-xp 00000000 08:14 > 1180003 /lib/libc-2.11.1.so > 7f4d6a34c000-7f4d6a54b000 ---p 0017a000 08:14 > 1180003 /lib/libc-2.11.1.so > 7f4d6a54b000-7f4d6a54f000 r--p 00179000 08:14 > 1180003 /lib/libc-2.11.1.so > 7f4d6a54f000-7f4d6a550000 rw-p 0017d000 08:14 > 1180003 /lib/libc-2.11.1.so > 7f4d6a550000-7f4d6a555000 rw-p 00000000 00:00 0 > 7f4d6a555000-7f4d6a55c000 r-xp 00000000 08:14 > 2231491 /usr/lib/libffi.so.5.0.10 > 7f4d6a55c000-7f4d6a75b000 ---p 00007000 08:14 > 2231491 /usr/lib/libffi.so.5.0.10 > 7f4d6a75b000-7f4d6a75c000 r--p 00006000 08:14 > 2231491 /usr/lib/libffi.so.5.0.10 > 7f4d6a75c000-7f4d6a75d000 rw-p 00007000 08:14 > 2231491 /usr/lib/libffi.so.5.0.10 > 7f4d6a75d000-7f4d6a775000 r-xp 00000000 08:14 > 1180001 /lib/libpthread-2.11.1.so > 7f4d6a775000-7f4d6a974000 ---p 00018000 08:14 > 1180001 /lib/libpthread-2.11.1.so > 7f4d6a974000-7f4d6a975000 r--p 00017000 08:14 > 1180001 /lib/libpthread-2.11.1.so > 7f4d6a975000-7f4d6a976000 rw-p 00018000 08:14 > 1180001 /lib/libpthread-2.11.1.so > 7f4d6a976000-7f4d6a97a000 rw-p 00000000 00:00 0 > 7f4d6a97a000-7f4d6a97c000 r-xp 00000000 08:14 > 1180008 /lib/libdl-2.11.1.so > 7f4d6a97c000-7f4d6ab7c000 ---p 00002000 08:14 > 1180008 /lib/libdl-2.11.1.so > 7f4d6ab7c000-7f4d6ab7d000 r--p 00002000 08:14 > 1180008 /lib/libdl-2.11.1.so > 7f4d6ab7d000-7f4d6ab7e000 rw-p 00003000 08:14 > 1180008 /lib/libdl-2.11.1.so > 7f4d6ab7e000-7f4d6ac00000 r-xp 00000000 08:14 > 1179958 /lib/libm-2.11.1.so > 7f4d6ac00000-7f4d6adff000 ---p 00082000 08:14 > 1179958 /lib/libm-2.11.1.so > 7f4d6adff000-7f4d6ae00000 r--p 00081000 08:14 > 1179958 /lib/libm-2.11.1.so > 7f4d6ae00000-7f4d6ae01000 rw-p 00082000 08:14 > 1179958 /lib/libm-2.11.1.so > 7f4d6ae01000-7f4d6ae21000 r-xp 00000000 08:14 > 1179985 /lib/ld-2.11.1.so > 7f4d6ae95000-7f4d6ae96000 rw-p 00000000 00:00 0 > 7f4d6ae96000-7f4d6aed5000 r--p 00000000 08:14 > 2237984 /usr/lib/locale/en_US.utf8/LC_CTYPE > 7f4d6aed5000-7f4d6aff3000 r--p 00000000 08:14 > 2239899 /usr/lib/locale/en_US.utf8/LC_COLLATE > 7f4d6aff3000-7f4d6aff7000 rw-p 00000000 00:00 0 > 7f4d6b00b000-7f4d6b00c000 r--p 00000000 08:14 > 2237989 /usr/lib/locale/en_US.utf8/LC_NUMERIC > 7f4d6b00c000-7f4d6b00d000 r--p 00000000 08:14 > 2232077 /usr/lib/locale/en_US.utf8/LC_TIME > 7f4d6b00d000-7f4d6b00e000 r--p 00000000 08:14 > 2234328 /usr/lib/locale/en_US.utf8/LC_MONETARY > 7f4d6b00e000-7f4d6b00f000 r--p 00000000 08:14 > 2235935 > /usr/lib/locale/en_US.utf8/LC_MESSAGES/SYS_LC_MESSAGES > 7f4d6b00f000-7f4d6b010000 r--p 00000000 08:14 > 2237938 /usr/lib/locale/en_US.utf8/LC_PAPER > 7f4d6b010000-7f4d6b011000 r--p 00000000 08:14 > 2237858 /usr/lib/locale/en_US.utf8/LC_NAME > 7f4d6b011000-7f4d6b012000 r--p 00000000 08:14 > 2235936 /usr/lib/locale/en_US.utf8/LC_ADDRESS > 7f4d6b012000-7f4d6b013000 r--p 00000000 08:14 > 2235937 /usr/lib/locale/en_US.utf8/LC_TELEPHONE > 7f4d6b013000-7f4d6b014000 r--p 00000000 08:14 > 2239858 /usr/lib/locale/en_US.utf8/LC_MEASUREMENT > 7f4d6b014000-7f4d6b01b000 r--s 00000000 08:14 > 2233563 /usr/lib/gconv/gconv-modules.cache > 7f4d6b01b000-7f4d6b01c000 r--p 00000000 08:14 > 2235940 /usr/lib/locale/en_US.utf8/LC_IDENTIFICATION > 7f4d6b01c000-7f4d6b020000 rw-p 00000000 00:00 0 > 7f4d6b020000-7f4d6b021000 r--p 0001f000 08:14 > 1179985 /lib/ld-2.11.1.so > 7f4d6b021000-7f4d6b022000 rw-p 00020000 08:14 > 1179985 /lib/ld-2.11.1.so > 7f4d6b022000-7f4d6b023000 rw-p 00000000 00:00 0 > 7fff5c542000-7fff5c557000 rw-p 00000000 00:00 0 > [stack] > 7fff5c5ff000-7fff5c600000 r-xp 00000000 00:00 0 > [vdso] > ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 > [vsyscall] > /mnt/store/LINUX/DOCUMENTS/DEVELOPMENT/Gambas/Προγραμματισμός σε > Gambas/Το βιβλίο της Gambas3/Projects/Pointers86 > --------------------------- > > the last line is in Greek some part, it is the name of current > directory. > > > > ------------------------------------------------------------------------------ > Gaining the trust of online customers is vital for the success of any > company > that requires sensitive data to be transmitted over the Web. Learn how to > best implement a security strategy that keeps consumers' information secure > and instills the confidence they need to proceed with transactions. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Gaining the trust of online customers is vital for the success of any company that requires sensitive data to be transmitted over the Web. Learn how to best implement a security strategy that keeps consumers' information secure and instills the confidence they need to proceed with transactions. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user