Author Topic: Segmentation fault on Ubuntu 18.04 but everything is fine on 14.04  (Read 96 times)

gosucherry

  • Posts: 16
I have this very weird situation, where the very same project working on Ubuntu 14.04 crashes on Ubuntu 18.04 (due to Segmentation fault). Exception occurs at "BASS_ChannelGetData" function in callback:

Code: [Select]
DWORD CALLBACK StreamProc(HSTREAM handle, BYTE *buffer, DWORD length, DWORD user){
    int count=length;
    while (count) {
        int r=BASS_ChannelGetData((*(Dzwiek *)user).loopHandle,buffer,count);
        if (r==-1){ // it's ended, go to start of loop
            BASS_ChannelSetPosition((*(Dzwiek *)user).loopHandle,((*(Dzwiek *)user).loopStart*4),BASS_POS_BYTE);
        }
        else {
            buffer+=r;
            count-=r;
        }
    }
    return length;
}

If I override (*(Dzwiek *)user).loopHandle with global variable handle everything works fine (but obviously, isnt a solution, because I have to retrieve loopHandle from "user"). Any ideas? The problem occured everytime, and the instalation of Ubuntu's are the very same (clear system + same basic programs).

Ian @ un4seen

  • Administrator
  • Posts: 21130
The "user" parameter should be a pointer rather than "DWORD". It won't make a difference in 32-bit processes but will in 64-bit.

Code: [Select]
DWORD CALLBACK StreamProc(HSTREAM handle, BYTE *buffer, DWORD length, void *user){
...

Does the crash still happen then?

gosucherry

  • Posts: 16
 Problem fixed by implementing your suggestion:

Code: [Select]
DWORD CALLBACK StreamProc(HSTREAM handle, BYTE *buffer, DWORD length, void *user){
...

Thank you mr. Ian for quick help! Had to check it by installing 18.04 again... Well that was really my bad :)