Jump to content

Segmentation fault (core dumped) after sending value via tlm2.0 on the same address after some delay


Recommended Posts

Hello everyone,

so I'm feeding lut module with data via generator module. When I'm done, I'm sending to last address(that is location where my start is stored) value 1, and then after 20 ns value 0. So basically, I want to set start "signal" to be length of one clock period. When I detect that start is 1, I'm starting my calculation in lut.cpp module.

If i change wait to 10 ns on line 1575 in generator.cpp it is fine, but when I put it to 20, I get segmentation fault. I should mention that in both cases code is compiling without errors.

If anyone can explain to me why this error is occurring it will help me a lot 🙂 

Thank you in advance, Tom

generator.cpp generator.hpp lut.cpp lut.hpp main.cpp mem_manager.cpp mem_manager.hpp stim.cpp stim.hpp

Link to post
Share on other sites

Your memory management is wrong. At first you pull 1 tx from the memory manager and reuse it all the time. This means you are changing your transaction in the request phase while it is in the response phase of the previous access. So you need to use mm.alloc() for each off the accesses. The purpose of the memory manager is to take care when to release/re-use the transaction. And here your second issue comes: you should always call acquire()/release() in a balanced way  but your lut only calls release(). What happens then is that the transaction is pushed into the pls deque in the memory manager. Eventually you have 2x the payload in the queue and upon destruction the memory manager tries to free it 2 times. BY inserting a  pl.acquire() in line 42 of lut.cpp you do not get a segfault anymore. But you should also use pl = mm.alloc() for each transaction to be send. Otherwise you might run into hard to debug functional issues.

A few general comments:

  • For performance and readability reasons you should use std::copy instead of a for loop in lut.cpp lines 51ff and 56ff
  • Your generator needs quite some rework. Since you have always similar procedure to send a transaction extract this into some helper function (containing mm.alloc() ;-). Secondly you might think about a for loop generating the accesses as they are fairly regular

Best regards

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...