Re: [firebird-support] UDF or/and maybe Charset problem
24.08.2017 15:07, Rudi Feijó rudi.fe...@multidadosti.com.br [firebird-support] wrote: > is there any problems if I just declare all UDF's with FREE IT? Yes, server will have problems trying to free memory that wasn't allocated. -- WBR, SD.
RE: [firebird-support] UDF or/and maybe Charset problem
>You must use ib_util_malloc() to allocate memory in UDF and don't forget >FREE_IT in declaration to avoid memory leak. Dimitry, on a similar question, is there any problems if I just declare all UDF's with FREE IT? We use dozens of UDF's, but only half of them are declared as FREE IT, and I have no way of knowing which ones should be freeing memory or not
Re: [firebird-support] UDF or/and maybe Charset problem
24.08.2017 12:00, Nagy Szilveszter nagy_szilvesz...@yahoo.com [firebird-support] wrote: > out = (char*)calloc(strlen(str), sizeof(char)); > result = (char*)calloc(j, sizeof(char)); Besides, here and there you forgot about space for terminating null char. -- WBR, SD. ++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++ Yahoo Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/firebird-support/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/firebird-support/join (Yahoo! ID required) <*> To change settings via email: firebird-support-dig...@yahoogroups.com firebird-support-fullfeatu...@yahoogroups.com <*> To unsubscribe from this group, send an email to: firebird-support-unsubscr...@yahoogroups.com <*> Your use of Yahoo Groups is subject to: https://info.yahoo.com/legal/us/yahoo/utos/terms/
Re: [firebird-support] UDF or/and maybe Charset problem
No, it has value of TRX12270 On Thursday, August 24, 2017, 12:56:09 PM GMT+3, Antônio Gomes acgomes2...@yahoo.com.br [firebird-support] <firebird-support@yahoogroups.com> wrote: there no a null string? De: "Nagy Szilveszter nagy_szilvesz...@yahoo.com [firebird-support]" <firebird-support@yahoogroups.com> Para: Firebird-support <firebird-support@yahoogroups.com> Enviadas: Quinta-feira, 24 de Agosto de 2017 6:41 Assunto: [firebird-support] UDF or/and maybe Charset problem Hi, i have an UDF function that runs perfectly on Linux 64 bit systems. I wanted to port it to Windows 32 bit, but i'm having problems there. The UDF was written in C (not C++), compiled on Linux with gcc, everything works fine. I compiled the same C file on Windows with MinGW Developer Studio (using MinGW compiler) Here is the function with problems (the functions returns the same string but deletes every non alphanumerical character): char *strpeel(char *str){ unsigned int i = 0, j = 0; char *out; str = strupr(str); out = (char*)calloc(strlen(str), sizeof(char)); for (i=0; i<strlen(str); i++){ if ((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= '0' && str[i] <= '9')) { out[j++] = str[i]; } } char * result; result = (char*)calloc(j, sizeof(char)); strcpy(result, out); return result; } This is the declaration of UDF in Firebird: DECLARE EXTERNAL FUNCTION STRPEEL CSTRING(255) RETURNS CSTRING(255) ENTRY_POINT 'strpeel' MODULE_NAME 'utils-udf'; When i test this function it runs correctly: select strpeel('ABC - 123') from rdb$database > returns: 'ABC123' But when i run it on my PRODUCTS table, there are some rows where this function crashes: select product_code, strpeel(product_code) from products The field PRODUCT_CODE is Varchar(30) charset UTF8 collate UTF8 At row 51 the string must have some invisible characters that makes the UDF to crash. The firebird.log says: The user defined function: STRPEEL referencing entrypoint: strpeel in module: utils-udf caused the fatal exception: Access violation. The code attempted to access a virtual address without privilege to do so. This exception will cause the Firebird server to terminate abnormally. Shutting down the server with 2 active connection(s) to 2 database(s), 0 active service(s) Firebird shutdown is still in progress after the specified timeout Operating system call ReleaseSemaphore failed. Error code 6 Operating system call ReleaseSemaphore failed. Error code 6 That code in that line is TRX12270 If i run select strpeel('TRX12270') from rdb$database - it works fine If i copy that string from table and replace the above string then it crashes again. So there must be something wrong in that field. Also if i edit the table and rewrite the code then it works fine. I also checked the characters with ASCII_VAL but i can see nothing strange. As the UDF, there are 2 memory allocations for strings and no freeing it, neither FREE_IT was used. I dont know if this is a problem since other strings work well with this UDF. Please help me detect and correct this issue! Thank you! #yiv5987566480 #yiv5987566480 -- #yiv5987566480ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv5987566480 #yiv5987566480ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv5987566480 #yiv5987566480ygrp-mkp #yiv5987566480hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv5987566480 #yiv5987566480ygrp-mkp #yiv5987566480ads {margin-bottom:10px;}#yiv5987566480 #yiv5987566480ygrp-mkp .yiv5987566480ad {padding:0 0;}#yiv5987566480 #yiv5987566480ygrp-mkp .yiv5987566480ad p {margin:0;}#yiv5987566480 #yiv5987566480ygrp-mkp .yiv5987566480ad a {color:#ff;text-decoration:none;}#yiv5987566480 #yiv5987566480ygrp-sponsor #yiv5987566480ygrp-lc {font-family:Arial;}#yiv5987566480 #yiv5987566480ygrp-sponsor #yiv5987566480ygrp-lc #yiv5987566480hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv5987566480 #yiv5987566480ygrp-sponsor #yiv5987566480ygrp-lc .yiv5987566480ad {margin-bottom:10px;padding:0 0;}#yiv5987566480 #yiv5987566480actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv5987566480 #yiv5987566480activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv5987566480 #yiv5987566480activity span {font-weight:700;}#yiv5987566480 #yiv5987566480activity span:first-child {text-transform:uppercase;}#yiv5987566480 #yiv5987566480activity span a {color:#5085b6;text-decoration:none;}#yiv5987566480 #yiv5987566480activity span span {color:#ff7900;}#yiv5987566480 #yiv5987566480activity span .yiv5987566480underline {t
Re: [firebird-support] UDF or/and maybe Charset problem
there no a null string? De: "Nagy Szilveszter nagy_szilvesz...@yahoo.com [firebird-support]" <firebird-support@yahoogroups.com> Para: Firebird-support <firebird-support@yahoogroups.com> Enviadas: Quinta-feira, 24 de Agosto de 2017 6:41 Assunto: [firebird-support] UDF or/and maybe Charset problem Hi, i have an UDF function that runs perfectly on Linux 64 bit systems. I wanted to port it to Windows 32 bit, but i'm having problems there. The UDF was written in C (not C++), compiled on Linux with gcc, everything works fine. I compiled the same C file on Windows with MinGW Developer Studio (using MinGW compiler) Here is the function with problems (the functions returns the same string but deletes every non alphanumerical character): char *strpeel(char *str){ unsigned int i = 0, j = 0; char *out; str = strupr(str); out = (char*)calloc(strlen(str), sizeof(char)); for (i=0; i<strlen(str); i++){ if ((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= '0' && str[i] <= '9')) { out[j++] = str[i]; } } char * result; result = (char*)calloc(j, sizeof(char)); strcpy(result, out); return result; } This is the declaration of UDF in Firebird: DECLARE EXTERNAL FUNCTION STRPEEL CSTRING(255) RETURNS CSTRING(255) ENTRY_POINT 'strpeel' MODULE_NAME 'utils-udf'; When i test this function it runs correctly: select strpeel('ABC - 123') from rdb$database > returns: 'ABC123' But when i run it on my PRODUCTS table, there are some rows where this function crashes: select product_code, strpeel(product_code) from products The field PRODUCT_CODE is Varchar(30) charset UTF8 collate UTF8 At row 51 the string must have some invisible characters that makes the UDF to crash. The firebird.log says: The user defined function: STRPEEL referencing entrypoint: strpeel in module: utils-udf caused the fatal exception: Access violation. The code attempted to access a virtual address without privilege to do so. This exception will cause the Firebird server to terminate abnormally. Shutting down the server with 2 active connection(s) to 2 database(s), 0 active service(s) Firebird shutdown is still in progress after the specified timeout Operating system call ReleaseSemaphore failed. Error code 6 Operating system call ReleaseSemaphore failed. Error code 6 That code in that line is TRX12270 If i run select strpeel('TRX12270') from rdb$database - it works fine If i copy that string from table and replace the above string then it crashes again. So there must be something wrong in that field. Also if i edit the table and rewrite the code then it works fine. I also checked the characters with ASCII_VAL but i can see nothing strange. As the UDF, there are 2 memory allocations for strings and no freeing it, neither FREE_IT was used. I dont know if this is a problem since other strings work well with this UDF. Please help me detect and correct this issue! Thank you! #yiv3803517428 #yiv3803517428 -- #yiv3803517428ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv3803517428 #yiv3803517428ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv3803517428 #yiv3803517428ygrp-mkp #yiv3803517428hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv3803517428 #yiv3803517428ygrp-mkp #yiv3803517428ads {margin-bottom:10px;}#yiv3803517428 #yiv3803517428ygrp-mkp .yiv3803517428ad {padding:0 0;}#yiv3803517428 #yiv3803517428ygrp-mkp .yiv3803517428ad p {margin:0;}#yiv3803517428 #yiv3803517428ygrp-mkp .yiv3803517428ad a {color:#ff;text-decoration:none;}#yiv3803517428 #yiv3803517428ygrp-sponsor #yiv3803517428ygrp-lc {font-family:Arial;}#yiv3803517428 #yiv3803517428ygrp-sponsor #yiv3803517428ygrp-lc #yiv3803517428hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv3803517428 #yiv3803517428ygrp-sponsor #yiv3803517428ygrp-lc .yiv3803517428ad {margin-bottom:10px;padding:0 0;}#yiv3803517428 #yiv3803517428actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv3803517428 #yiv3803517428activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv3803517428 #yiv3803517428activity span {font-weight:700;}#yiv3803517428 #yiv3803517428activity span:first-child {text-transform:uppercase;}#yiv3803517428 #yiv3803517428activity span a {color:#5085b6;text-decoration:none;}#yiv3803517428 #yiv3803517428activity span span {color:#ff7900;}#yiv3803517428 #yiv3803517428activity span .yiv3803517428underline {text-decoration:underline;}#yiv3803517428 .yiv3803517428attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv3803517428 .yiv3803517428attach div a {text-
Re: [firebird-support] UDF or/and maybe Charset problem
24.08.2017 11:37, Nagy Szilveszter nagy_szilvesz...@yahoo.com [firebird-support] wrote: > result = (char*)calloc(j, sizeof(char)); You must use ib_util_malloc() to allocate memory in UDF and don't forget FREE_IT in declaration to avoid memory leak. -- WBR, SD. ++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++ Yahoo Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/firebird-support/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/firebird-support/join (Yahoo! ID required) <*> To change settings via email: firebird-support-dig...@yahoogroups.com firebird-support-fullfeatu...@yahoogroups.com <*> To unsubscribe from this group, send an email to: firebird-support-unsubscr...@yahoogroups.com <*> Your use of Yahoo Groups is subject to: https://info.yahoo.com/legal/us/yahoo/utos/terms/
[firebird-support] UDF or/and maybe Charset problem
Hi, i have an UDF function that runs perfectly on Linux 64 bit systems. I wanted to port it to Windows 32 bit, but i'm having problems there. The UDF was written in C (not C++), compiled on Linux with gcc, everything works fine. I compiled the same C file on Windows with MinGW Developer Studio (using MinGW compiler) Here is the function with problems (the functions returns the same string but deletes every non alphanumerical character): char *strpeel(char *str){ unsigned int i = 0, j = 0; char *out; str = strupr(str); out = (char*)calloc(strlen(str), sizeof(char)); for (i=0; i= 'A' && str[i] <= 'Z') || (str[i] >= '0' && str[i] <= '9')) { out[j++] = str[i]; } } char * result; result = (char*)calloc(j, sizeof(char)); strcpy(result, out); return result; } This is the declaration of UDF in Firebird: DECLARE EXTERNAL FUNCTION STRPEEL CSTRING(255) RETURNS CSTRING(255) ENTRY_POINT 'strpeel' MODULE_NAME 'utils-udf'; When i test this function it runs correctly: select strpeel('ABC - 123') from rdb$database > returns: 'ABC123' But when i run it on my PRODUCTS table, there are some rows where this function crashes: select product_code, strpeel(product_code) from products The field PRODUCT_CODE is Varchar(30) charset UTF8 collate UTF8 At row 51 the string must have some invisible characters that makes the UDF to crash. The firebird.log says: The user defined function: STRPEEL referencing entrypoint: strpeel in module: utils-udf caused the fatal exception: Access violation. The code attempted to access a virtual address without privilege to do so. This exception will cause the Firebird server to terminate abnormally. Shutting down the server with 2 active connection(s) to 2 database(s), 0 active service(s) Firebird shutdown is still in progress after the specified timeout Operating system call ReleaseSemaphore failed. Error code 6 Operating system call ReleaseSemaphore failed. Error code 6 That code in that line is TRX12270 If i run select strpeel('TRX12270') from rdb$database - it works fine If i copy that string from table and replace the above string then it crashes again. So there must be something wrong in that field. Also if i edit the table and rewrite the code then it works fine. I also checked the characters with ASCII_VAL but i can see nothing strange. As the UDF, there are 2 memory allocations for strings and no freeing it, neither FREE_IT was used. I dont know if this is a problem since other strings work well with this UDF. Please help me detect and correct this issue! Thank you!