Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. pointer is often invalid when dealing with atomic operations
Qt 6.11 is out! See what's new in the release blog

pointer is often invalid when dealing with atomic operations

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 537 Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    user4592357
    wrote on last edited by user4592357
    #1

    i'm looking at this article: https://woboq.com/blog/introduction-to-lockfree-programming.html
    and here's the code presented there: https://hastebin.com/xazimuyequ.cpp

    when i run it, it works 1/10 times, 9/10 times it crashes on line 60:
    while (!m_head.testAndSetOrdered(n, n->next));

    the exception is a read access violation for n->next. why does it behave like this?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Tried the code but no matter how many times i press the buttons, it does not crash.
      alt text

      1 Reply Last reply
      1
      • U Offline
        U Offline
        user4592357
        wrote on last edited by user4592357
        #3

        i wrote this in console application but that shouldn't be a problem, no?
        i tried with both visual studio and qt creator, both behave the same. qt creator crashes less often, though.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Can you share the version of everything you are currently using ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • U Offline
            U Offline
            user4592357
            wrote on last edited by
            #5

            @SGaist
            visual studio 2017 / qt creator 4.6.1
            qt 5.11.0
            windows 10

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved