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:#0000ff;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 {text-decoration:underline;}#yiv5987566480 .yiv5987566480attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv5987566480 .yiv5987566480attach div a {text-decoration:none;}#yiv5987566480 .yiv5987566480attach img {border:none;padding-right:5px;}#yiv5987566480 .yiv5987566480attach label {display:block;margin-bottom:5px;}#yiv5987566480 .yiv5987566480attach label a {text-decoration:none;}#yiv5987566480 blockquote {margin:0 0 0 4px;}#yiv5987566480 .yiv5987566480bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv5987566480 .yiv5987566480bold a {text-decoration:none;}#yiv5987566480 dd.yiv5987566480last p a {font-family:Verdana;font-weight:700;}#yiv5987566480 dd.yiv5987566480last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv5987566480 dd.yiv5987566480last p span.yiv5987566480yshortcuts {margin-right:0;}#yiv5987566480 div.yiv5987566480attach-table div div a {text-decoration:none;}#yiv5987566480 div.yiv5987566480attach-table {width:400px;}#yiv5987566480 div.yiv5987566480file-title a, #yiv5987566480 div.yiv5987566480file-title a:active, #yiv5987566480 div.yiv5987566480file-title a:hover, #yiv5987566480 div.yiv5987566480file-title a:visited {text-decoration:none;}#yiv5987566480 div.yiv5987566480photo-title a, #yiv5987566480 div.yiv5987566480photo-title a:active, #yiv5987566480 div.yiv5987566480photo-title a:hover, #yiv5987566480 div.yiv5987566480photo-title a:visited {text-decoration:none;}#yiv5987566480 div#yiv5987566480ygrp-mlmsg #yiv5987566480ygrp-msg p a span.yiv5987566480yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv5987566480 .yiv5987566480green {color:#628c2a;}#yiv5987566480 .yiv5987566480MsoNormal {margin:0 0 0 0;}#yiv5987566480 o {font-size:0;}#yiv5987566480 #yiv5987566480photos div {float:left;width:72px;}#yiv5987566480 #yiv5987566480photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv5987566480 #yiv5987566480photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv5987566480 #yiv5987566480reco-category {font-size:77%;}#yiv5987566480 #yiv5987566480reco-desc {font-size:77%;}#yiv5987566480 .yiv5987566480replbq {margin:4px;}#yiv5987566480 #yiv5987566480ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv5987566480 #yiv5987566480ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv5987566480 #yiv5987566480ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv5987566480 #yiv5987566480ygrp-mlmsg select, #yiv5987566480 input, #yiv5987566480 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv5987566480 #yiv5987566480ygrp-mlmsg pre, #yiv5987566480 code {font:115% monospace;}#yiv5987566480 #yiv5987566480ygrp-mlmsg * {line-height:1.22em;}#yiv5987566480 #yiv5987566480ygrp-mlmsg #yiv5987566480logo {padding-bottom:10px;}#yiv5987566480 #yiv5987566480ygrp-msg p a {font-family:Verdana;}#yiv5987566480 #yiv5987566480ygrp-msg p#yiv5987566480attach-count span {color:#1E66AE;font-weight:700;}#yiv5987566480 #yiv5987566480ygrp-reco #yiv5987566480reco-head {color:#ff7900;font-weight:700;}#yiv5987566480 #yiv5987566480ygrp-reco {margin-bottom:20px;padding:0px;}#yiv5987566480 #yiv5987566480ygrp-sponsor #yiv5987566480ov li a {font-size:130%;text-decoration:none;}#yiv5987566480 #yiv5987566480ygrp-sponsor #yiv5987566480ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv5987566480 #yiv5987566480ygrp-sponsor #yiv5987566480ov ul {margin:0;padding:0 0 0 8px;}#yiv5987566480 #yiv5987566480ygrp-text {font-family:Georgia;}#yiv5987566480 #yiv5987566480ygrp-text p {margin:0 0 1em 0;}#yiv5987566480 #yiv5987566480ygrp-text tt {font-size:120%;}#yiv5987566480 #yiv5987566480ygrp-vital ul li:last-child {border-right:none !important;}#yiv5987566480