Peter Eriksson wrote:
Another thing I just noticed (but you probably already is aware of that):
A last thing... I did some debugger tracing of the calls to i_stream_unref and printed the arguments (see the attached file)
It seems the *stream in these two calls to i_stream_unref references the same 'stream'.
The second call to i_stream_unref is the one wrapped with the 'data.destroying_stream' check that triggers the assert.
I inserted a breakpoint at the index_mail_stream_destroy_callback function and that one actually gets called correctly with 'mail->data.destroying_stream' set to '1'. If I then check the '_mail' structure contents back in the i_stream_unref function it is correctly set to '0'.
But the i_assert() call on line 1091 still triggers for some unknown reason...
My guess:
Optimizer incorrectly assuming that it doesn't need to refetch the variable value from the structure since it doesn't understand that the i_stream_unref(&mail->data.stream) call actually modifies the whole mail->data structure...
Funny that both Gcc and Sun Studio seems to make the same assumptions in that case :-)
mail->data.destroying_stream = TRUE; i_stream_unref(&mail->data.stream); i_assert(!mail->data.destroying_stream);
- Peter