You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Vijay (Created) (JIRA)" <ji...@apache.org> on 2012/04/03 01:31:21 UTC
[jira] [Created] (CASSANDRA-4111) Serializing cache can cause
Segfault in 1.1
Serializing cache can cause Segfault in 1.1
-------------------------------------------
Key: CASSANDRA-4111
URL: https://issues.apache.org/jira/browse/CASSANDRA-4111
Project: Cassandra
Issue Type: Bug
Components: Core
Affects Versions: 1.1.0
Reporter: Vijay
Assignee: Vijay
Fix For: 1.1.0
Rare but this can happen per sure, looks like this issue is after CASSANDRA-3862 hence affectes only 1.1
FreeableMemory old = map.get(key);
if (old == null)
return false;
// see if the old value matches the one we want to replace
FreeableMemory mem = serialize(value);
if (mem == null)
return false; // out of memory. never mind.
V oldValue = deserialize(old);
boolean success = oldValue.equals(oldToReplace) && map.replace(key, old, mem);
if (success)
old.unreference();
else
mem.unreference();
return success;
in the above code block we deserialize(old) without taking reference to the old memory, this can case seg faults when the old is reclaimed (free is called)
Fix is to get the reference just for deserialization
V oldValue;
// reference old guy before de-serializing
old.reference();
try
{
oldValue = deserialize(old);
}
finally
{
old.unreference();
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CASSANDRA-4111) Serializing cache can cause
Segfault in 1.1
Posted by "Vijay (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CASSANDRA-4111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13244849#comment-13244849 ]
Vijay commented on CASSANDRA-4111:
----------------------------------
Noticed it when compaction was serializing it and update was freeing it.
> Serializing cache can cause Segfault in 1.1
> -------------------------------------------
>
> Key: CASSANDRA-4111
> URL: https://issues.apache.org/jira/browse/CASSANDRA-4111
> Project: Cassandra
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.1.0
> Reporter: Vijay
> Assignee: Vijay
> Fix For: 1.1.0
>
> Attachments: 0001-CASSANDRA-4111.patch
>
>
> Rare but this can happen per sure, looks like this issue is after CASSANDRA-3862 hence affectes only 1.1
> FreeableMemory old = map.get(key);
> if (old == null)
> return false;
> // see if the old value matches the one we want to replace
> FreeableMemory mem = serialize(value);
> if (mem == null)
> return false; // out of memory. never mind.
> V oldValue = deserialize(old);
> boolean success = oldValue.equals(oldToReplace) && map.replace(key, old, mem);
> if (success)
> old.unreference();
> else
> mem.unreference();
> return success;
> in the above code block we deserialize(old) without taking reference to the old memory, this can case seg faults when the old is reclaimed (free is called)
> Fix is to get the reference just for deserialization
> V oldValue;
> // reference old guy before de-serializing
> old.reference();
> try
> {
> oldValue = deserialize(old);
> }
> finally
> {
> old.unreference();
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (CASSANDRA-4111) Serializing cache can cause
Segfault in 1.1
Posted by "Vijay (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CASSANDRA-4111?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vijay updated CASSANDRA-4111:
-----------------------------
Attachment: 0001-CASSANDRA-4111.patch
> Serializing cache can cause Segfault in 1.1
> -------------------------------------------
>
> Key: CASSANDRA-4111
> URL: https://issues.apache.org/jira/browse/CASSANDRA-4111
> Project: Cassandra
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.1.0
> Reporter: Vijay
> Assignee: Vijay
> Fix For: 1.1.0
>
> Attachments: 0001-CASSANDRA-4111.patch
>
>
> Rare but this can happen per sure, looks like this issue is after CASSANDRA-3862 hence affectes only 1.1
> FreeableMemory old = map.get(key);
> if (old == null)
> return false;
> // see if the old value matches the one we want to replace
> FreeableMemory mem = serialize(value);
> if (mem == null)
> return false; // out of memory. never mind.
> V oldValue = deserialize(old);
> boolean success = oldValue.equals(oldToReplace) && map.replace(key, old, mem);
> if (success)
> old.unreference();
> else
> mem.unreference();
> return success;
> in the above code block we deserialize(old) without taking reference to the old memory, this can case seg faults when the old is reclaimed (free is called)
> Fix is to get the reference just for deserialization
> V oldValue;
> // reference old guy before de-serializing
> old.reference();
> try
> {
> oldValue = deserialize(old);
> }
> finally
> {
> old.unreference();
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (CASSANDRA-4111) Serializing cache can cause
Segfault in 1.1
Posted by "Vijay (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CASSANDRA-4111?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vijay updated CASSANDRA-4111:
-----------------------------
Attachment: 0001-CASSANDRA-4111-v2.patch
ahaaa missed that.... V2 fixes it. Thanks!
> Serializing cache can cause Segfault in 1.1
> -------------------------------------------
>
> Key: CASSANDRA-4111
> URL: https://issues.apache.org/jira/browse/CASSANDRA-4111
> Project: Cassandra
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.1.0
> Reporter: Vijay
> Assignee: Vijay
> Fix For: 1.1.0
>
> Attachments: 0001-CASSANDRA-4111-v2.patch, 0001-CASSANDRA-4111.patch
>
>
> Rare but this can happen per sure, looks like this issue is after CASSANDRA-3862 hence affectes only 1.1
> FreeableMemory old = map.get(key);
> if (old == null)
> return false;
> // see if the old value matches the one we want to replace
> FreeableMemory mem = serialize(value);
> if (mem == null)
> return false; // out of memory. never mind.
> V oldValue = deserialize(old);
> boolean success = oldValue.equals(oldToReplace) && map.replace(key, old, mem);
> if (success)
> old.unreference();
> else
> mem.unreference();
> return success;
> in the above code block we deserialize(old) without taking reference to the old memory, this can case seg faults when the old is reclaimed (free is called)
> Fix is to get the reference just for deserialization
> V oldValue;
> // reference old guy before de-serializing
> old.reference();
> try
> {
> oldValue = deserialize(old);
> }
> finally
> {
> old.unreference();
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CASSANDRA-4111) Serializing cache can cause
Segfault in 1.1
Posted by "Jonathan Ellis (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CASSANDRA-4111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13245525#comment-13245525 ]
Jonathan Ellis commented on CASSANDRA-4111:
-------------------------------------------
+1
> Serializing cache can cause Segfault in 1.1
> -------------------------------------------
>
> Key: CASSANDRA-4111
> URL: https://issues.apache.org/jira/browse/CASSANDRA-4111
> Project: Cassandra
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.1.0
> Reporter: Vijay
> Assignee: Vijay
> Fix For: 1.1.0
>
> Attachments: 0001-CASSANDRA-4111-v2.patch, 0001-CASSANDRA-4111.patch
>
>
> Rare but this can happen per sure, looks like this issue is after CASSANDRA-3862 hence affectes only 1.1
> FreeableMemory old = map.get(key);
> if (old == null)
> return false;
> // see if the old value matches the one we want to replace
> FreeableMemory mem = serialize(value);
> if (mem == null)
> return false; // out of memory. never mind.
> V oldValue = deserialize(old);
> boolean success = oldValue.equals(oldToReplace) && map.replace(key, old, mem);
> if (success)
> old.unreference();
> else
> mem.unreference();
> return success;
> in the above code block we deserialize(old) without taking reference to the old memory, this can case seg faults when the old is reclaimed (free is called)
> Fix is to get the reference just for deserialization
> V oldValue;
> // reference old guy before de-serializing
> old.reference();
> try
> {
> oldValue = deserialize(old);
> }
> finally
> {
> old.unreference();
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CASSANDRA-4111) Serializing cache can cause
Segfault in 1.1
Posted by "Jonathan Ellis (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CASSANDRA-4111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13244920#comment-13244920 ]
Jonathan Ellis commented on CASSANDRA-4111:
-------------------------------------------
good catch. also need to handle old.reference() returning false tho.
> Serializing cache can cause Segfault in 1.1
> -------------------------------------------
>
> Key: CASSANDRA-4111
> URL: https://issues.apache.org/jira/browse/CASSANDRA-4111
> Project: Cassandra
> Issue Type: Bug
> Components: Core
> Affects Versions: 1.1.0
> Reporter: Vijay
> Assignee: Vijay
> Fix For: 1.1.0
>
> Attachments: 0001-CASSANDRA-4111.patch
>
>
> Rare but this can happen per sure, looks like this issue is after CASSANDRA-3862 hence affectes only 1.1
> FreeableMemory old = map.get(key);
> if (old == null)
> return false;
> // see if the old value matches the one we want to replace
> FreeableMemory mem = serialize(value);
> if (mem == null)
> return false; // out of memory. never mind.
> V oldValue = deserialize(old);
> boolean success = oldValue.equals(oldToReplace) && map.replace(key, old, mem);
> if (success)
> old.unreference();
> else
> mem.unreference();
> return success;
> in the above code block we deserialize(old) without taking reference to the old memory, this can case seg faults when the old is reclaimed (free is called)
> Fix is to get the reference just for deserialization
> V oldValue;
> // reference old guy before de-serializing
> old.reference();
> try
> {
> oldValue = deserialize(old);
> }
> finally
> {
> old.unreference();
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira