Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bus error #8

Closed
1Marc opened this issue Jan 25, 2010 · 21 comments
Closed

bus error #8

1Marc opened this issue Jan 25, 2010 · 21 comments

Comments

@1Marc
Copy link

1Marc commented Jan 25, 2010

I'm on os x leapord and when I try to play a station I get "Bus error". Any ideas what could cause this?

|> Station "Yanni Radio" (149189365585733648)
(i) Receiving new playlist... Ok.
|> "Butterflies" by "Suzanne Ciani" on "Pianissimo III"
Bus error

@itsmeduncan
Copy link

I get the same issue on 10.5.8. Used the directions from the Reddit comment.

@qrush
Copy link

qrush commented Jan 25, 2010

Same here.

@PromyLOPh
Copy link
Owner

I've seen this once with the clang compiler on x86. Which compiler (and version) are you using? Can someone generate a backtrace, please?

cmake . -DCMAKE_BUILD_TYPE=Debug
make
your_debugger ./src/pianobar

edit: Can't reproduce the "bus error" with clang any more...

@qrush
Copy link

qrush commented Jan 27, 2010

Here's what I'm seeing:

gdb ./src/pianobar 
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin"...Reading symbols for shared libraries ...... done

(gdb) run
Starting program: /Users/qrush/Dev/c/pianobar/src/pianobar 
Reading symbols for shared libraries +++++.......................... done
Welcome to pianobar!
Reading symbols for shared libraries .. done
[?] Username: nick@quaran.to
[?] Password: 
(i) Login... Ok.
(i) Get stations... Ok.
        0) q   Bahston Rawk
        1) q   Classic RAWK!
        2)  Q  DrNick40's QuickMix
        3)     Pink Floyd Radio
        4) q   Red Barchetta
        5)     y2k
[?] Select station: 4
|>  Station "Red Barchetta" (70369594586271057)
(i) Receiving new playlist... Ok.
|>  "Presto" by "Rush" on "Presto"

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000038
0x94e54c03 in flockfile ()
(gdb) backtrace
#0  0x94e54c03 in flockfile ()
#1  0x94e9417f in fgetc ()
#2  0x000045b1 in main (argc=1, argv=0xbfffea78) at /Users/qrush/Dev/c/pianobar/src/main.c:303

@PromyLOPh
Copy link
Owner

Looks like curFd is NULL... Can you get a more detailed backtrace and paste it somewhere (gist)? Ubuntu has a nice guide: https://wiki.ubuntu.com/Backtrace#Generation (you might have to remove your password from this backtrace)

@qrush
Copy link

qrush commented Jan 27, 2010

yep, that seems like it was the case. I added a if curFd != NULL check in and got this beauty:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x000d9000
[Switching to process 2047 thread 0x1103]
0x00005a4a in BarPlayerAACCb (ptr=0xb018280b, size=9912, stream=0x17200) at /Users/qrush/Dev/c/pianobar/src/player.c:249
249                                             player->sampleSize[player->sampleSizeCurr] =
(gdb) backtrace   
#0  0x00005a4a in BarPlayerAACCb (ptr=0xb018280b, size=9912, stream=0x17200) at /Users/qrush/Dev/c/pianobar/src/player.c:249
#1  0x0000f1ff in WaitressFetchCall (waith=0x21ac0) at /Users/qrush/Dev/c/pianobar/libwaitress/src/waitress.c:453
#2  0x00006319 in BarPlayerThread (data=0x17200) at /Users/qrush/Dev/c/pianobar/src/player.c:454
#3  0x94e46155 in _pthread_start ()
#4  0x94e46012 in thread_start ()

I'll work on getting the more detailed backtrace together for you.

@PromyLOPh
Copy link
Owner

So, we have two independend bugs here. The first one seems to be trivial to fix, but I'm waiting for the backtrace, 'cause curFd == NULL is one of these "this simply cannot happen"-cases...

Bug two: AAC playback crashes. (Though this should not happen:) Have you tried mp3 playback? Add this line to your config file: audio_format = mp3. What machine architecture are you using? x86, x86_64, powerpc, ...? Big or little endian? The code assumes that int is always 4 bytes and byte order is always little endian -- which could break things...

@itsmeduncan
Copy link

This is what I am seeing. I am running Leopard 10.5.8 x86.

pianobar [master] $ gdb ./src/pianobar
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin"...Reading symbols for shared    libraries ...... done

(gdb) run
Starting program: /Users/duncan/Projects/pianobar/src/pianobar 
Reading symbols for shared libraries +++++.......................... done
Welcome to pianobar!
Reading symbols for shared libraries .. done
[?] Username: itsmeduncan@gmail.com
[?] Password: 
(i) Login... Ok.
(i) Get stations... Ok.
     0)     Icepick Radio
    1)  Q  itsmeduncan's QuickMix
    2)     Jay-Z Radio
    3)     Swollen Members Radio
    4)     The Doors Radio
    5) q   The National Radio
    6)     The Swell Season Radio
[?] Select station: 0
|>  Station "Icepick Radio" (177743261749833684)
(i) Receiving new playlist... Ok.
|>  "This Can Never Be Undone" by "Icepick" on "Violent Epiphany"

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000038
0x903c7c03 in flockfile ()
(gdb) backtrace
#0  0x903c7c03 in flockfile ()
#1  0x9040717f in fgetc ()
#2  0x000045b1 in main (argc=1, argv=0xbffff4a8) at       /Users/duncan/Projects/pianobar/src/main.c:303
(gdb)

@PromyLOPh
Copy link
Owner

Thanks, itsmeduncan, but I really need a full backtrace to find out what's going wrong, see my comment above.

@1Marc
Copy link
Author

1Marc commented Jan 31, 2010

@PromyLOPh: Is this what you need?

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000038
0x96650c03 in flockfile ()
(gdb) backtrace full
#0  0x96650c03 in flockfile ()
No symbol table info available.
#1  0x9669017f in fgetc ()
No symbol table info available.
#2  0x00004569 in main (argc=1, argv=0xbffff408) at /Users/marcgrabanski/src/pianobar/src/main.c:303
    curFd = (FILE *) 0x0
    i = 0
    ph = {
  waith = {
    host = "www.pandora.com", '\0' <repeats 84 times>, 
    port = "80\000\000\000", 
    path = "/radio/xmlrpc/v26?rid=4969165P&lid=67168272&method=getFragment&arg1=149189365585733648&arg2=0&arg3=&arg4=&arg5=aacplus&arg6=0&arg7=0", '\0' <repeats 867 times>, 
    method = WAITRESS_METHOD_POST, 
    extraHeaders = 0x12ffb "Content-Type: text/xml\r\n", 
    postData = 0x80a200 "9ebed1aacea9295ab1ab523568438752fe64a70592e6346627a06c221c3da2c873bfc2c1cf00a112c99b646c364e895a968e8d3e3047230211c128d3589585e8f43aa3b3a696004b9a05c314c256353307e03ddc04fb3e177482602199a804ddd2e8db6e"..., 
    contentLength = 16857, 
    contentReceived = 16857, 
    proxyHost = '\0' <repeats 99 times>, 
    proxyPort = "\000\000\000\000\000", 
    data = 0xbfffbba4, 
    callback = 0xe4e1 <WaitressFetchBufCb>, 
    socktimeout = 30000
  }, 
  routeId = "4969165P", 
  user = {
    webAuthToken = 0x102e10 "wKENObWFe+JD/Pu/U8eUM/e4uCtztoAsUM52GRNgNV/qFG8dLOVCzReaq6vq4lGov", 
    listenerId = 0x101d20 "67168272", 
    authToken = 0x102e60 "`C77CSsxm3omDVys7FzM85by/VbcYw7g4"
  }, 
  stations = 0x101d30, 
  genreStations = 0x0
}
    player = {
  buffer = '\0' <repeats 20479 times>, 
  bufferFilled = 0, 
  bufferRead = 0, 
  bytesReceived = 0, 
  mode = PLAYER_FREED, 
  audioFormat = PIANO_AF_AACPLUS, 
  songDuration = 0, 
  songPlayed = 0, 
  aacHandle = 0x0, 
  sampleSize = 0x0, 
  sampleSizeN = 0, 
  sampleSizeCurr = 0, 
  mp3Stream = {
    buffer = 0x0, 
    bufend = 0x0, 
    skiplen = 0, 
    sync = 0, 
    freerate = 0, 
    this_frame = 0x0, 
    next_frame = 0x0, 
    ptr = {
      byte = 0x0, 
      cache = 0, 
      left = 0
    }, 
    anc_ptr = {
      byte = 0x0, 
      cache = 0, 
      left = 0
    }, 
    anc_bitlen = 0, 
    main_data = 0x0, 
    md_len = 0, 
    options = 0, 
    error = MAD_ERROR_NONE
  }, 
  mp3Frame = {
    header = {
      layer = 0, 
      mode = MAD_MODE_SINGLE_CHANNEL, 
      mode_extension = 0, 
      emphasis = MAD_EMPHASIS_NONE, 
      bitrate = 0, 
      samplerate = 0, 
      crc_check = 0, 
      crc_target = 0, 
      flags = 0, 
      private_bits = 0, 
      duration = {
        seconds = 0, 
        fraction = 0
      }
    }, 
    options = 0, 
    sbsample = {{{0 <repeats 32 times>} <repeats 36 times>}, {{0 <repeats 32 times>} <repeats 36 times>}}, 
    overlap = 0x0
  }, 
  mp3Synth = {
    filter = {{{{{0, 0, 0, 0, 0, 0, 0, 0} <repeats 16 times>}, {{0, 0, 0, 0, 0, 0, 0, 0} <repeats 16 times>}}, {{{0, 0, 0, 0, 0, 0, 0, 0} <repeats 16 times>}, {{0, 0, 0, 0, 0, 0, 0, 0} <repeats 16 times>}}}, {{{{0, 0, 0, 0, 0, 0, 0, 0} <repeats 16 times>}, {{0, 0, 0, 0, 0, 0, 0, 0} <repeats 16 times>}}, {{{0, 0, 0, 0, 0, 0, 0, 0} <repeats 16 times>}, {{0, 0, 0, 0, 0, 0, 0, 0} <repeats 16 times>}}}}, 
    phase = 0, 
    pcm = {
      samplerate = 0, 
      channels = 0, 
      length = 0, 
      samples = {{0 <repeats 1152 times>}, {0 <repeats 1152 times>}}
    }
  }, 
  samplerate = 0, 
  channels = 0 '\0', 
  gain = 4.26999998, 
  scale = 0, 
  audioOutDevice = 0x0, 
  aoError = 0 '\0', 
  waith = {
    host = "audio-sjl-t1-1.pandora.com", '\0' <repeats 73 times>, 
    port = "80\000\000\000", 
    path = "/access/?version=4&lid=67168272&token=DiqrzuDWCBzaQAiO92RqK1skzFWwAtkU6qoj3%2BF%2BM4EhWdjxuIbxLOg2Kqhd2a7HGwLQOwK6GLoMDk1CPYgbfBzN8VDKpkEZ2Q5vjn%2FtTWZNmU2xNd%2BXl%2BK9UOa0eZKls0%2Bx31IcIaopp%2FpNOaWv"..., 
    method = WAITRESS_METHOD_GET, 
    extraHeaders = 0x0, 
    postData = 0x0, 
    contentLength = 0, 
    contentReceived = 0, 
    proxyHost = '\0' <repeats 99 times>, 
    proxyPort = "\000\000\000\000\000", 
    data = 0x0, 
    callback = 0, 
    socktimeout = 30000
  }, 
  doQuit = 0 '\0', 
  pauseMutex = {
    __sig = 0, 
    __opaque = '\0' <repeats 39 times>
  }
}
    settings = {
  username = 0x101b00 "m@marcgrabanski.com", 
  password = 0x101aa0 "******", 
  controlProxy = 0x0, 
  lastfmUser = 0x0, 
  lastfmPassword = 0x0, 
  lastfmScrobblePercent = 0 '\0', 
  enableScrobbling = 0 '\0', 
  keys = "?+-acdeghijmnpqrstux$", 
  audioFormat = PIANO_AF_AACPLUS, 
  autostartStation = 0x0, 
  eventCmd = 0x0, 
  history = 5
}
    playerThread = (pthread_t) 0xb0081000
    wh = {
  user = 0x0, 
  password = 0x0, 
  authToken = '\0' <repeats 99 times>, 
  postHost = '\0' <repeats 49 times>, 
  postPort = "\000\000\000\000\000", 
  postPath = '\0' <repeats 99 times>, 
  waith = {
    host = '\0' <repeats 99 times>, 
    port = "\000\000\000\000\000", 
    path = '\0' <repeats 999 times>, 
    method = WAITRESS_METHOD_GET, 
    extraHeaders = 0x0, 
    postData = 0x0, 
    contentLength = 0, 
    contentReceived = 0, 
    proxyHost = '\0' <repeats 99 times>, 
    proxyPort = "\000\000\000\000\000", 
    data = 0x0, 
    callback = 0, 
    socktimeout = 30000
  }
}
    playlist = (PianoSong_t *) 0x108ff0
    songHistory = (PianoSong_t *) 0x0
    curStation = (PianoStation_t *) 0x101af0
    scrobbleSong = {
  artist = 0x109910 "George Winston", 
  title = 0x101ab0 "Night Part I: Snow", 
  album = 0x101ad0 "December", 
  started = 1264969176, 
  length = 0
}
    doQuit = 0 '\0'
    ctlPath = "/Users/marcgrabanski/.config/pianobar/ctl", '\0' <repeats 982 times>
    ctlFd = (FILE *) 0x0
    polls = {{
    fd = 0, 
    events = 1, 
    revents = 32
  }, {
    fd = 0, 
    events = 0, 
    revents = 0
  }}
    pollsLen = 1
    buf = 0 '\0'
    termOrig = {
  c_iflag = 27394, 
  c_oflag = 3, 
  c_cflag = 19200, 
  c_lflag = 536872395, 
  c_cc = "\004??\027\025\022?\003\034\032\031\021\023\026\017\001\000\024?", 
  c_ispeed = 9600, 
  c_ospeed = 9600
}
(gdb) info registers
eax            0xa07f9720   -1602250976
ecx            0xbfffe35c   -1073749156
edx            0x1  1
ebx            0x96690161   -1771503263
esp            0xbfffe310   0xbfffe310
ebp            0xbfffe328   0xbfffe328
esi            0xa07f9720   -1602250976
edi            0x0  0
eip            0x96650c03   0x96650c03 <flockfile+22>
eflags         0x10282  66178
cs             0x17 23
ss             0x1f 31
ds             0x1f 31
es             0x1f 31
fs             0x0  0
gs             0x37 55

@PromyLOPh
Copy link
Owner

Yes, thank you 1Marc. revents = 32 is the interesting thing. It indicates an invalid poll request. And the mac manpage for poll reveals, that this system call does not work on device files (stdin is such a device).

Well, I'll have to use the ugly select() call on OS X... Don't know how long it will take, though.

[edit]Please remove your password from the gdb output. Dunno why I can't edit your post :/[/edit]

@PromyLOPh
Copy link
Owner

Ok, here's a patch: http://gist.github.com/291786 Can someone test this on OS X, please?

@1Marc
Copy link
Author

1Marc commented Feb 1, 2010

I can't seem to build with the patch applied...

CMake Error in /Users/marcgrabanski/src/pianobar/CMakeFiles/CMakeTmp/CMakeLists.txt:
  Cannot find source file "poll_test.c".  Tried extensions .c .C .c++ .cc
  .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx


CMake Error: Internal CMake error, TryCompile generation of cmake failed
-- poll is broken, using select
-- Found libfaad, enabling aac decoding
-- Found libmad, enabling mp3 decoding
-- Configuring incomplete, errors occurred!

@PromyLOPh
Copy link
Owner

Ah, sorry, my fault. Gist has been updated, copy the file poll_test.c to src/build/poll_test.c (the directory does not exist yet).

@1Marc
Copy link
Author

1Marc commented Feb 1, 2010

cmake built fine, but when i tried to, "make"

marc-grabanskis-macbook:pianobar marcgrabanski$ make clean
marc-grabanskis-macbook:pianobar marcgrabanski$ make
[  6%] Building C object libezxml/src/CMakeFiles/ezxml.dir/ezxml.o
Linking C static library libezxml.a
[  6%] Built target ezxml
[ 13%] Building C object libwaitress/src/CMakeFiles/waitress.dir/waitress.o
Linking C static library libwaitress.a
[ 13%] Built target waitress
[ 20%] Building C object libpiano/src/CMakeFiles/piano.dir/crypt.o
[ 26%] Building C object libpiano/src/CMakeFiles/piano.dir/http.o
[ 33%] Building C object libpiano/src/CMakeFiles/piano.dir/piano.o
[ 40%] Building C object libpiano/src/CMakeFiles/piano.dir/xml.o
Linking C static library libpiano.a
[ 40%] Built target piano
[ 46%] Building C object libwardrobe/src/CMakeFiles/wardrobe.dir/wardrobe.o
[ 53%] Building C object libwardrobe/src/CMakeFiles/wardrobe.dir/md5.o
Linking C static library libwardrobe.a
[ 53%] Built target wardrobe
[ 60%] Building C object src/CMakeFiles/pianobar.dir/main.o
/Users/marcgrabanski/src/pianobar/src/main.c: In function ‘main’:
/Users/marcgrabanski/src/pianobar/src/main.c:82: error: ‘fd_set’ undeclared (first use in this function)
/Users/marcgrabanski/src/pianobar/src/main.c:82: error: (Each undeclared identifier is reported only once
/Users/marcgrabanski/src/pianobar/src/main.c:82: error: for each function it appears in.)
/Users/marcgrabanski/src/pianobar/src/main.c:82: error: syntax error before ‘rfds’
/Users/marcgrabanski/src/pianobar/src/main.c:312: warning: implicit declaration of function ‘FD_ZERO’
/Users/marcgrabanski/src/pianobar/src/main.c:312: error: ‘rfds’ undeclared (first use in this function)
/Users/marcgrabanski/src/pianobar/src/main.c:313: warning: implicit declaration of function ‘FD_SET’
/Users/marcgrabanski/src/pianobar/src/main.c:321: warning: implicit declaration of function ‘select’
/Users/marcgrabanski/src/pianobar/src/main.c:328: warning: implicit declaration of function ‘FD_ISSET’
make[2]: *** [src/CMakeFiles/pianobar.dir/main.o] Error 1
make[1]: *** [src/CMakeFiles/pianobar.dir/all] Error 2
make: *** [all] Error 2

@PromyLOPh
Copy link
Owner

Looks like a missing include. The select(2) manpage says sys/select.h is correct -- strange, 'cause it works fine for me.

Maybe replacing #include <sys/select.h> (src/main.c) with

 #include <sys/types.h>
 #include <sys/time.h>
 #include <unistd.h>

helps?

[edit]#define _POSIX_C_SOURCE 1 could be wrong, too. #define _POSIX_C_SOURCE 200112L should be correct.[/edit]

@jordanlewis
Copy link
Contributor

I made an independent fix for this by replacing poll() with select. It's in my fork.

http://github.com/toft/pianobar

@PromyLOPh
Copy link
Owner

Thanks, but have you read select_tut(2), especially "select law" 10?

  1. The timeout value must be initialized with each new call to select(), since some operating systems modify the structure.

Additionally there already exists a patch (see above). I'm just waiting for someone who can confirm that the patch works (with the modifications pointed out in my last post) and fixes this issue.

@jordanlewis
Copy link
Contributor

Good point, I didn't see that - I updated it in my fork. I looked at your patch - why use poll() or select() conditionally based on the operating system? It seems like it might be cleaner to just stick with select().

@PromyLOPh
Copy link
Owner

Yeah, you're right. All these ifdefs are even more ugly than select itself. I applied your patch and performed some style tweaks (camelCase, renamed variables e.g.) -- thanks.

Closed, see commit a99bfd2

@qrush
Copy link

qrush commented Feb 5, 2010

Working great here! Thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants