Hello, Jesus! Thursday, September 8, 2011, 9:42:38 PM, you wrote:
JG> Hello, is normal to crash the engine whe an exception is JG> raised inside a udf dll or must be catch by the engine? JG> I had a udf with the function power. If i call power with a JG> negative value in the base parameter an exception is raised and JG> the engine is stopped. Why not catch the exception To prevent the JG> problem and raise it like any exception? <my opinion> Server just does not know what to do after exception came from your function. For example, your udf is written in Delphi. You allocated some memory, then divided by zero, and exception went to the server. Server's memory manager is different than Delphi-s, so, allocated memory cannot be returned back. Well, if server handled that exception, you still have memory leak, and this leak causes server (!) to function unproperly. So, the good practice for udfs is to handle all exceptions inside it and not to allow to leave udf function code by any error. People often tries to put into udf a lot of complicated stuff - sending emails, working with files, connecting to other databases and so on. And they mostly do not write any exception handling of this code. Catching these exceptions in server will not help these udfs at all. JG> I think this is a bug in the engine. I think it's a bug in your udf :-) p.s. long time ago, IIRC, Ann Harrison replied to similar question something like: "well, we can put a lot of checks over udf calls, but this will slowdown them. You need to choose - have fast but a bit dangerous (from writer's side) udfs, or slow but safe udf calls". -- Dmitry Kuzmenko, www.ibase.ru, (495) 953-13-34
