How to debug FinalizeError?

Steven Schveighoffer schveiguy at gmail.com
Thu Nov 29 14:51:40 UTC 2018


On 11/29/18 2:07 AM, unDEFER wrote:
> No I'm not preallocating any exceptions. It was idea, but I removed all 
> calls which can make throw.
> I'm using very old dmd 2.074.1, so as I have patched it for my text 
> editor with IDE functions. I had a year break in development, so now I 
> need to rewrite all my patches.
> But exactly the output of my program looks like this:
> 
> core.exception.FinalizeError at src/rt/lifetime.d(1407): Finalization error
> ----------------
> === Bypassed ===
> 
> |||||||||||| BerkeleyDB exceptions mixed with output of destructors 
> ||||||||||||||||||
> 
> core.exception.InvalidMemoryOperationError at src/core/exception.d(696): 
> Invalid memory operation
> ----------------
> 
> It means that "Invalid memory operation" occurred earlier than 
> "Finalization error"?
> The line on which shows the pointer src/rt/lifetime.d(1407) is exactly:
>          onFinalizeError(*pc, e);
> Why gdb doesn't see this function?

You need to compile druntime in debug mode. One thing you can do is 
implement the function locally, and then break on it (it's a C linkage, 
so I think the linker will grab your copy instead of the one in druntime)

i.e. in your code, do:

extern(C) void onFinalizeError(TypeInfo info, Throwable e, string file = 
__FILE__, size_t line = __LINE__)
{
    import core.stdc.stdio;
    printf("break here\n");
}

> 
> My program (the text editor) had run test all night under gdb with break 
> on InvalidMemoryOperationError and didn't fall. So it is very-very-very 
> hard to reproduce.
> And I haven't ideas where maybe this throw. At least I don't see any 
> throw in explicit form.

These are unfortunately really tough to debug. You get very little info, 
and the stack trace is generally useless.

-Steve


More information about the Digitalmars-d-learn mailing list