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. QImage::fromData SEGV
QtWS25 Last Chance

QImage::fromData SEGV

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 4 Posters 1.0k Views
  • 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.
  • JonBJ JonB

    @Creaperdown
    And what error do you run into where from what?
    If you call jpeg_CreateDecompress() what parameters do you pass in?
    If you pass JPEG_LIB_VERSION then the implication is the one you have included for compiling does not match the one the library was compiled with.

    C Offline
    C Offline
    Creaperdown
    wrote on last edited by
    #3

    @JonB I am not calling the above function directly. I am calling QImage::fromData which leads to a crash, stopping in this function.

    JonBJ 1 Reply Last reply
    0
    • C Creaperdown

      @JonB I am not calling the above function directly. I am calling QImage::fromData which leads to a crash, stopping in this function.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #4

      @Creaperdown
      I see. Then my question should have been "what parameters are passed to it from whatever calls it".

      Since it SEGVs if you run under debugger it should break at that statement. Depending on how it was compiled debug-wise, try to see what the value of version is. You may not be able to view JPEG_LIB_VERSION's value as it's probably a #define, but you could always drop into the generated assembler to see what two values are being compared.

      I don't know whether version comes from something inside the actual file being read or (more likely?) is compiled-in for the version of the JPEG decompressor library being used. It is clearly supposed to be the same as whatever JPEG_LIB_VERSION is. Assuming it comes from compiled code, I don't know whether the JPEG library is statically- or dynamically-compiled but could one machine be picking up a different version of this library than intended/the other machine does?

      C 1 Reply Last reply
      0
      • JonBJ JonB

        @Creaperdown
        I see. Then my question should have been "what parameters are passed to it from whatever calls it".

        Since it SEGVs if you run under debugger it should break at that statement. Depending on how it was compiled debug-wise, try to see what the value of version is. You may not be able to view JPEG_LIB_VERSION's value as it's probably a #define, but you could always drop into the generated assembler to see what two values are being compared.

        I don't know whether version comes from something inside the actual file being read or (more likely?) is compiled-in for the version of the JPEG decompressor library being used. It is clearly supposed to be the same as whatever JPEG_LIB_VERSION is. Assuming it comes from compiled code, I don't know whether the JPEG library is statically- or dynamically-compiled but could one machine be picking up a different version of this library than intended/the other machine does?

        C Offline
        C Offline
        Creaperdown
        wrote on last edited by
        #5

        @JonB version is 80 for me. I'll try finding the JPEG_LIB_VERSION #define

        SGaistS 1 Reply Last reply
        0
        • C Creaperdown

          @JonB version is 80 for me. I'll try finding the JPEG_LIB_VERSION #define

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @Creaperdown hi,

          Out of curiosity, why are you using the JPEG library since Qt already has an image plugin for that format ?

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

          C 1 Reply Last reply
          1
          • SGaistS SGaist

            @Creaperdown hi,

            Out of curiosity, why are you using the JPEG library since Qt already has an image plugin for that format ?

            C Offline
            C Offline
            ChrisW67
            wrote on last edited by
            #7

            @SGaist The OP is using QImage::fromData() and the result is a crash in the code embedded/called within the plugin. IIRC this JPEG code may be embedded in Qt or from a system library.

            My money is on passing an invalid buffer or size to the QImage function in the first place. "Works just fine on a different machine" is not a good reference if, for example, the buffer is a deleted temporary object that gets overwritten, or written to by an unsynchronised thread... these all come down to matters of timing and system load.

            C 1 Reply Last reply
            0
            • C ChrisW67

              @SGaist The OP is using QImage::fromData() and the result is a crash in the code embedded/called within the plugin. IIRC this JPEG code may be embedded in Qt or from a system library.

              My money is on passing an invalid buffer or size to the QImage function in the first place. "Works just fine on a different machine" is not a good reference if, for example, the buffer is a deleted temporary object that gets overwritten, or written to by an unsynchronised thread... these all come down to matters of timing and system load.

              C Offline
              C Offline
              Creaperdown
              wrote on last edited by
              #8

              @ChrisW67 Is there a way that I could test if that buffer contains valid data?

              JonBJ C 2 Replies Last reply
              0
              • C Creaperdown

                @ChrisW67 Is there a way that I could test if that buffer contains valid data?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #9

                @Creaperdown
                You have shown/claimed that this line is failing:

                if (version != JPEG_LIB_VERSION)

                From the stack trace where does the value of version passed into this function emanate from?

                Or are you not saying this is the cause of the SEGV? If that comes from accessing *cinfo that is a different issue.

                C 2 Replies Last reply
                0
                • JonBJ JonB

                  @Creaperdown
                  You have shown/claimed that this line is failing:

                  if (version != JPEG_LIB_VERSION)

                  From the stack trace where does the value of version passed into this function emanate from?

                  Or are you not saying this is the cause of the SEGV? If that comes from accessing *cinfo that is a different issue.

                  C Offline
                  C Offline
                  Creaperdown
                  wrote on last edited by
                  #10

                  @JonB Sadly QtCreator does not show me a stack trace. I only get the calling functions, then question marks right to the function I shared above.

                  JonBJ 1 Reply Last reply
                  0
                  • C Creaperdown

                    @JonB Sadly QtCreator does not show me a stack trace. I only get the calling functions, then question marks right to the function I shared above.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #11

                    @Creaperdown
                    Ah, OK. That is not a Creator limitation, it's gdb and the (lack of) source code/debug info.

                    If you get a SEGV rather than the ERREXIT2(...) in your original post, what is, say, the next line after that if statement? Is *cinfo implicated [oic, cinfo is passed to ERREXIT2] and/or is structsize an expected size?

                    C 1 Reply Last reply
                    0
                    • C Creaperdown

                      @ChrisW67 Is there a way that I could test if that buffer contains valid data?

                      C Offline
                      C Offline
                      ChrisW67
                      wrote on last edited by
                      #12

                      @Creaperdown Where does the data come from? How are you passing it to QImage::fromData()? Are there threads active in your program, or is all this happening in the main thread?

                      C 1 Reply Last reply
                      0
                      • C ChrisW67

                        @Creaperdown Where does the data come from? How are you passing it to QImage::fromData()? Are there threads active in your program, or is all this happening in the main thread?

                        C Offline
                        C Offline
                        Creaperdown
                        wrote on last edited by
                        #13

                        @ChrisW67 I am downloading the data from my server where I have previously uploaded it to. Right now I noticed that another part of my application, that has been working just fine before, fails because of the same error. I managed to find the version in the above snippet is 80 and JPEG_LIB_VERSION is 90.

                        1 Reply Last reply
                        0
                        • JonBJ JonB

                          @Creaperdown
                          Ah, OK. That is not a Creator limitation, it's gdb and the (lack of) source code/debug info.

                          If you get a SEGV rather than the ERREXIT2(...) in your original post, what is, say, the next line after that if statement? Is *cinfo implicated [oic, cinfo is passed to ERREXIT2] and/or is structsize an expected size?

                          C Offline
                          C Offline
                          Creaperdown
                          wrote on last edited by
                          #14

                          @JonB it steps into ERREXIT2(). The next line would be:

                          GLOBAL(void)
                          jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
                          {
                            int i;
                          
                            /* Guard against version mismatches between library and caller. */
                            cinfo->mem = NULL;		/* so jpeg_destroy knows mem mgr not called */
                            if (version != JPEG_LIB_VERSION)
                              ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
                            if (structsize != SIZEOF(struct jpeg_decompress_struct))
                              ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, 
                          	     (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize);
                          
                          1 Reply Last reply
                          0
                          • JonBJ JonB

                            @Creaperdown
                            You have shown/claimed that this line is failing:

                            if (version != JPEG_LIB_VERSION)

                            From the stack trace where does the value of version passed into this function emanate from?

                            Or are you not saying this is the cause of the SEGV? If that comes from accessing *cinfo that is a different issue.

                            C Offline
                            C Offline
                            Creaperdown
                            wrote on last edited by
                            #15

                            @JonB And now i get a stack trace
                            e42e39a6-24f5-45fe-bb7c-1d36dedd1551-image.png

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              Creaperdown
                              wrote on last edited by
                              #16

                              Ok, now I have done some system updates and jpegs work fine in debug mode, but running the application in release mode still causes the same crash.

                              1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                Creaperdown
                                wrote on last edited by
                                #17

                                I still didn't find a solution to this, does anyone have another idea?

                                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