-
Hi, I added trace parser to the feed instruction from trace file to sparta_core_example's fetch stage. The ex_inst allocation in Fetch::fetchInstruction_() and inst vector emplace_back and sending retain the original version while assignments of some additional fields of ExampleInst are added. Running with some program trace with -r (--run-time) larger then the program's length (e.g. -r 10000000000 for a trace with around 1,400,000 insts), I bump into the following issue: Printing allocated_ and free_idx_ in allocate_() of SpartaSharedPointerAllocator() shows that before allocated__ is incremented to 40, there are only 4 times where free_idx_ is incremented by 1 and consumed at that allocation attempt, with the sequence of printing like: Another observation is if -r is specified with a number less than the trace inst count (or say #cycles), meaning the sim run is terminated before the trace feeding ends, this error will not be encountered. For sparta::allocate_sparta_shared_pointer allocation in fetch stage, everything remains as the original version. I also track the constructor's and destructor's unlink_() calls, but still not finding a way to identify the root cause more efficiently yet. Is there some suggestion on debugging this issue? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
So I'm assuming you know the cause of the seg fault; that's not your question. 😄 But rather, you're wondering why the error message from the Allocator? First of all, I'm pretty sure the Allocator isn't the cause of the seg fault, but without a full stack, I can't be certain. Are you observing the seg fault in a destruction of one of your data types? During a seg fault, there's the possibility that destruction of certain objects (like the seg faulting class) are not destroyed and any objects allocated will not be returned to the Allocator prior to the Allocator's destruction. Secondly, the variables
So if If the simulator is properly torn down by the framework (on a successful run) and the modeler did not leave resources on the heap that use the Allocator, then you will not see any error messages. The main reason this works: the Allocator is always destroyed last in simulation. This gives all resources an opportunity to release pointers held in buffers, queues, vectors, lists, etc back to the Allocator. Anytime this order is disturbed (like in a seg fault situation) the Allocator will complain if not all objects are return or a double-free situation might occur (seg fault) since the Allocator has deleted ALL backend memory AND THEN an allocated object from that Allocator is deleted.
I think in your case, you're either dealing with a Another idea for the double-free situation -- augment the
I might add this to the allocator, but I fear cutting into its performance. |
Beta Was this translation helpful? Give feedback.
-
The root cause issue is not related to the allocator in the error message of the original question but is due to my bug in trace ending parsing. Marked as answered. |
Beta Was this translation helpful? Give feedback.
The root cause issue is not related to the allocator in the error message of the original question but is due to my bug in trace ending parsing. Marked as answered.