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:#0000ff;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-decoration:none;}#yiv3803517428 .yiv3803517428attach img {border:none;padding-right:5px;}#yiv3803517428 .yiv3803517428attach label {display:block;margin-bottom:5px;}#yiv3803517428 .yiv3803517428attach label a {text-decoration:none;}#yiv3803517428 blockquote {margin:0 0 0 4px;}#yiv3803517428 .yiv3803517428bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv3803517428 .yiv3803517428bold a {text-decoration:none;}#yiv3803517428 dd.yiv3803517428last p a {font-family:Verdana;font-weight:700;}#yiv3803517428 dd.yiv3803517428last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv3803517428 dd.yiv3803517428last p span.yiv3803517428yshortcuts {margin-right:0;}#yiv3803517428 div.yiv3803517428attach-table div div a {text-decoration:none;}#yiv3803517428 div.yiv3803517428attach-table {width:400px;}#yiv3803517428 div.yiv3803517428file-title a, #yiv3803517428 div.yiv3803517428file-title a:active, #yiv3803517428 div.yiv3803517428file-title a:hover, #yiv3803517428 div.yiv3803517428file-title a:visited {text-decoration:none;}#yiv3803517428 div.yiv3803517428photo-title a, #yiv3803517428 div.yiv3803517428photo-title a:active, #yiv3803517428 div.yiv3803517428photo-title a:hover, #yiv3803517428 div.yiv3803517428photo-title a:visited {text-decoration:none;}#yiv3803517428 div#yiv3803517428ygrp-mlmsg #yiv3803517428ygrp-msg p a span.yiv3803517428yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv3803517428 .yiv3803517428green {color:#628c2a;}#yiv3803517428 .yiv3803517428MsoNormal {margin:0 0 0 0;}#yiv3803517428 o {font-size:0;}#yiv3803517428 #yiv3803517428photos div {float:left;width:72px;}#yiv3803517428 #yiv3803517428photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv3803517428 #yiv3803517428photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv3803517428 #yiv3803517428reco-category {font-size:77%;}#yiv3803517428 #yiv3803517428reco-desc {font-size:77%;}#yiv3803517428 .yiv3803517428replbq {margin:4px;}#yiv3803517428 #yiv3803517428ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv3803517428 #yiv3803517428ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv3803517428 #yiv3803517428ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv3803517428 #yiv3803517428ygrp-mlmsg select, #yiv3803517428 input, #yiv3803517428 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv3803517428 #yiv3803517428ygrp-mlmsg pre, #yiv3803517428 code {font:115% monospace;}#yiv3803517428 #yiv3803517428ygrp-mlmsg * {line-height:1.22em;}#yiv3803517428 #yiv3803517428ygrp-mlmsg #yiv3803517428logo {padding-bottom:10px;}#yiv3803517428 #yiv3803517428ygrp-msg p a {font-family:Verdana;}#yiv3803517428 #yiv3803517428ygrp-msg p#yiv3803517428attach-count span {color:#1E66AE;font-weight:700;}#yiv3803517428 #yiv3803517428ygrp-reco #yiv3803517428reco-head {color:#ff7900;font-weight:700;}#yiv3803517428 #yiv3803517428ygrp-reco {margin-bottom:20px;padding:0px;}#yiv3803517428 #yiv3803517428ygrp-sponsor #yiv3803517428ov li a {font-size:130%;text-decoration:none;}#yiv3803517428 #yiv3803517428ygrp-sponsor #yiv3803517428ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv3803517428 #yiv3803517428ygrp-sponsor #yiv3803517428ov ul {margin:0;padding:0 0 0 8px;}#yiv3803517428 #yiv3803517428ygrp-text {font-family:Georgia;}#yiv3803517428 #yiv3803517428ygrp-text p {margin:0 0 1em 0;}#yiv3803517428 #yiv3803517428ygrp-text tt {font-size:120%;}#yiv3803517428 #yiv3803517428ygrp-vital ul li:last-child {border-right:none !important;}#yiv3803517428