Yes, the main heroine was killed by a random slasher unknown to the main character.
The murderer's name was never mentioned in all media (light novel, live-action film, manga, anime movie), but it's the random slasher that has been mentioned a few times in the story (in the newspaper, on the TV news). It's unknown to the main character as he said,
Sakura Yamauchi got dragged into the random slasher (通り魔) case that has been disturbing the society since then. The culprit whom I don't know was quickly arrested.
Since this is a random slasher case, there's no particular reason why they were attacking someone: she was just happened to be in the wrong place at the wrong time.
That said, the point of that scene is not about who the murderer was or why she was murdered, but why it happened despite the main topic about "pancreas".